
I am trying to do what Desperate Gamers did in the 2nd level of their Mod. The below code works if the player puts the right torches in the right holders but if they put say torch2_1 into th1 the editor crashes. I do not know why. See torch2_1 has to go into th2 and so on.. The editor tries to delete torch1_1 for some reason...
When the player puts the right torches into the right holders, the holder and torch are destroyed to indicate they have used the right torch holders in the room. The exception is that their mod does not destroy the torch or holder..
Here is what I have ATM. This code works if the Torches are placed in the right Holders eg:
I have defined 4 new torches called (torch1 to torch4). The GUI Name for the torches are (Torches Of Light 1 to 4) that I have put into the (items.lua).
Holder Names = th1 to th4
Torch Names = torch1_1 to torch4_1
counter Name = unlock1Counter
------------------------------------------------------
The room has 4 torch holders, each torch holder needs a certain torch as above, here is the code that I modified from Desperate Gamers. Oh and the Torch Holders are set to activate not any.
----------------------------------------------------
unlock1Counter = 0
function addUnlock2()
playSound("secret")
unlock1Counter = unlock1Counter + 1
if unlock1Counter==1 then
hudPrint("Torch 1 lit.")
th1:destroy() ---Name of the Torch Holder---
torch1_1:destroy() ---Name of the Torch---
elseif unlock1Counter==2 then
hudPrint("Torch 2 lit.")
th2:destroy()
torch2_1:destroy()
elseif unlock1Counter==3 then
hudPrint("Torch 3 lit.")
th3:destroy()
torch3_1:destroy()
elseif unlock1Counter==4 then
hudPrint("Torch 4 lit.")
findEntity("dungeon_door_iron_3"):open()
hudPrint("VOICE: The way is open")
hudPrint("")
hudPrint("You gain 45 Xp")
for i = 1,4 do party:getChampion(i):gainExp(45)
end
playSound("level_up")
th4:destroy()
torch4_1:destroy()
end
end
Also if Torches are on the floor when the player puts a torch into one of the torch holders, some of the other torches are deleted from the editor.
The torches in this coding have to be placed in the correct order otherwise the editor crashes. I could put the torches and holders into separately locked rooms to avoid the error problem but I want them all in the one room.
At the end of the day all I want is when the player puts a torch into the holder text appears to tell them they lit the right torch and when all torches are lit the door opens, XP granted and they can continue..
I hope this makes sense to someone out there
