Thanks for that. I Chose to use Isaacs Option since it´s pretty simple to do. I needed it for some shopkeepers to be invulnerable.
Now that i have the Shops, i also wanted to make a Money changing machine which can choose between 3 states.
1. Change in Gold
2. Change in silver
3. Change in copper
I wrote the following Code for it and i can´t figure out why it won´t work. To mention is that i have made this Thing up out of codes i found here on the Forum. Mostly the stuff Isaac already gave me for some other Problems i had
Code: Select all
function moneyinfo()
if kindcounter.counter:getValue() == 1 then
hudPrint("changing in gold coins")
end
if kindcounter.counter:getValue() == 2 then
hudPrint("changing in silver coins")
end
if kindcounter.counter:getValue() == 3 then
hudPrint("changing in copper coins")
end
if kindcounter.counter:getValue() >3 then
kindcounter.counter:setValue(0)
end
end
function surfaceContains(surface, item)
for v,i in surface.surface:contents() do
if i.go.name == item then return true
end
end
end
----------------------------------------------------------
--counts coins
function moneychange()
local coinscopper ={}
local coinssilver ={}
local coinsgold ={}
for v,i in moneychanger.surface:contents() do
surfaceContains(moneychanger, "dm_coin_copper")
if i then
coinscopper[#coinscopper+1] = i
end
surfaceContains(moneychanger, "dm_coin_silver")
if i then
coinssilver[#coinssilver+1] = i
end
surfaceContains(moneychanger, "dm_coin_copper")
if i then
coinsgold[#coinsgold+1] = i
end
end
----------------------------------------------------------
if kindcounter.counter:getValue() == 1 then
local copper=#coinscopper%4
local silver=((#coinscopper/4)+#coinssilver)%4
local gold=((silver%4)+#goldcoins)
silver=silver/4
end
----------------------------------------------------------
if kindcounter.counter:getValue() == 2 then
local copper=#coinscopper%4
local silver=#coinscopper/4+#coinssilver+#coinsgold*4
local gold=0
end
----------------------------------------------------------
if kindcounter.counter:getValue() == 3 then
local gold=0
local silver=#coinssilver+#coinsgold*4
local copper=silver*4
silver=0
end
----------------------------------------------------------
for x = 0, #coinscopper do
coinscopper[x].go:destroy()
end
for x = 0, #coinssilver do
coinssilver[x].go:destroy()
end
for x = 0, #coinsgold do
coinsgold[x].go:destroy()
end
for m=1,gold do
moneychanger.surface:addItem(spawn("dm_coin_gold").item)
end
for m=1,silver do
moneychanger.surface:addItem(spawn("dm_coin_silver").item)
end
for m=1,copper do
moneychanger.surface:addItem(spawn("dm_coin_copper").item)
end
end
Once again it would be nice if you could tell me what´i did wrong here.
I hope the mistake(s) i made aren´t to great, so i can use this script afterall.
In order to get to the other side of the pit you have to get hit by the fireball and die....
Yep.....moving on!