reinitialise a scrip when used

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
bongobeat
Posts: 1076
Joined: Thu May 16, 2013 5:58 pm
Location: France

reinitialise a scrip when used

Post by bongobeat »

Halli, hallo,

well another problem (linked to the spawn/destroy item post" viewtopic.php?f=14&t=5597

How can I re-initialize the following script to use it again?

actually, when I put 2 specific items on the altar it spawns another item, destroy the 2 specific items, and that's all (used to forge a particular armor).
But it can't be used more, what's a pity!
I ve tried many things, but I think I'm not god enough to script this :(

can anyone help me please?
SpoilerShow

Code: Select all

function check()
   local valid = {"adamantite_enriched", "adamantite_enriched"}
	local counter = 0   

   for i in afor05:containedItems() do
      local ok = false
      for j = 1,#valid do
         if i.name == valid[j] then
            counter = counter + 1
            ok = true
            break
         end
      end
      if not ok then
         counter = -1
         break
      end
   end
   
  -- print(counter)
   
   if counter == 2 then
if findEntity("afor05") ~= nil then
for i in afor05:containedItems() do
i:destroy()
end
afor05:destroy()
spawn("deep_temple_altar", 20, 2, 16, 1, "afor05")
playSound("Volcano")
spawn("fireburst", 20, 2, 16, 1)
spawn("shockburst", 20, 2, 16, 1)
afor05:addItem(spawn("adamantite_cuirass"))
playSound("discover_spell")
hudPrint("You have forged a cuirass!")
hudPrint("But the forge seems to be damaged now!")
   end
end

end
My asset pack: viewtopic.php?f=22&t=9320

Log1 mod : Toorum Manor: viewtopic.php?f=14&t=5505
Post Reply