If you go the wrong way, the puzzle resets and you have to start over from the start.
All of the floor triggers should be numbered sequentially in the order they should be stepped on. The light near it should have the same number. All floor triggers just connect to the one function pathpuzzle()
Code: Select all
pathlighttable = {}
pathcount = 0
pathsolved = 0
function pathpuzzle()
if pathsolved == 0 then
local currentactivated = {}
for i = 1,8 do
currentactivated[i] = findEntity("pathtrigger"..i)
if currentactivated[i].floortrigger:isActivated() then
if i == pathcount + 1 then
pathlighttable[i] = 1
pathcount = pathcount + 1
pathlights()
if pathcount == 8 then
pathsecret.secret:activate()
dungeon_door_portcullis_23.door:open()
for p = 1, 4, 1 do
party.party:getChampion(p):gainExp(500)
end
hudPrint("500 XP")
pathsolved = 1
end
elseif i == pathcount then
--do nothing
elseif i == 1 then
--start reset
pathcount = 1
for i = 1,8 do
pathlighttable[i] = 0
end
pathlighttable[1] = 1
pathlights()
else
-- total reset
pathcount = 0
for i = 1,8 do
pathlighttable[i] = 0
end
pathlights()
end
end
end
end
end
function pathlights()
for i = 1,8 do
local pathlight = findEntity("pathlight"..i)
if pathlighttable[i] == 1 then
pathlight.light:enable()
pathlight.particle:enable()
else
pathlight.light:disable()
pathlight.particle:disable()
end
end
end