Page 1 of 1

Help with scripting (destroying item from recipe)

Posted: Fri Oct 12, 2012 8:08 pm
by Mutman
Hi,
I am not good programmer so i need help. I made new recipe (which creates item) and i have a riddle in which you must put that item on altar and it spawns scroll with text. But then i need, as the scroll spawns, to destroy the item from recipe and i am unable to set that things ID to destroy it with script destroy(). Could anybody help please?

Re: Help with scripting (destroying item from recipe)

Posted: Fri Oct 12, 2012 9:46 pm
by crisman
Hi, so if I understood correctly, you want to put a special item on an altar, destroy it and then spawn a scroll on the same altar?
If it is right, then the script should be

Code: Select all

function spawnScroll()

for i in altar:containedItems() do
   if i.name == "item_name" then
      i:destroy()
      altar:insertItem(spawn("scroll"))
    end
end
end

Should work, I haven't tested - but you need to modify it for your necessity - altar must be your altar name, and item_name the name of your item.
If you have any other problems let me know ;)

Re: Help with scripting (destroying item from recipe)

Posted: Fri Oct 12, 2012 10:25 pm
by Mutman
It is exactly what i wanted :) and it is working perfectly :) thak you so much :)

Re: Help with scripting (destroying item from recipe)

Posted: Fri Oct 12, 2012 11:29 pm
by crisman
No problem ^^ Glad it helped :D