Help with scripting (destroying item from recipe)

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Mutman
Posts: 73
Joined: Sun Apr 08, 2012 9:57 pm
Location: Krupka, Czech Republic

Help with scripting (destroying item from recipe)

Post 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?
Runebooks: http://www.nexusmods.com/legendofgrimrock2/mods/13/? for Legend of Grimrock 2
Runebooks and books: http://grimrock.nexusmods.com/mods/217/ for Legend of Grimrock 1
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Help with scripting (destroying item from recipe)

Post 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 ;)
User avatar
Mutman
Posts: 73
Joined: Sun Apr 08, 2012 9:57 pm
Location: Krupka, Czech Republic

Re: Help with scripting (destroying item from recipe)

Post by Mutman »

It is exactly what i wanted :) and it is working perfectly :) thak you so much :)
Runebooks: http://www.nexusmods.com/legendofgrimrock2/mods/13/? for Legend of Grimrock 2
Runebooks and books: http://grimrock.nexusmods.com/mods/217/ for Legend of Grimrock 1
User avatar
crisman
Posts: 305
Joined: Sat Sep 22, 2012 9:23 pm
Location: Italy

Re: Help with scripting (destroying item from recipe)

Post by crisman »

No problem ^^ Glad it helped :D
Post Reply