Code: Select all
steps = 9 -- CUSTOMIZE: HOW MANY STEPS YOU HAVE
namepart = "pitpuz" -- CUSTOMIZE: PARTIAL ID OF PITS (WITHOUT THE NUMBER)
time = 1
function pitSequence()
local thetimer = pitpuztimer -- CUSTOMIZE: ID OF THE TIMER
local sequence = { pitpuz7, pitpuz4, pitpuz1, pitpuz2, pitpuz3, pitpuz6, pitpuz5, pitpuz8, pitpuz9 } -- CUSTOMIZE: IDS OF THE PITS YOU WANT TO CLOSE, IN ORDER
if levercount == 2 then
if time < steps + 1 then
sequence[time]:deactivate() --close a pit in the sequence
end
if time > 2 then
sequence[time-2]:activate() --and then open a pit again two steps behind
end
time = time + 1
if time == steps + 3 then
time = 1
thetimer:deactivate()
end
elseif levercount == 1 then
if time > 2 then
sequence[time-2]:deactivate() --close a pit in the sequence
end
if time < steps + 1 then
sequence[time]:activate() --and then open a pit again two steps behind
end
time = time - 1
if time == 0 then
time = steps + 2
thetimer:deactivate()
end
end
end
levercount = 2
function leverPull()
local thetimer = pitpuztimer -- CUSTOMIZE: ID OF THE TIMER
local thelever1 = pitpuzlever1 -- CUSTOMIZE: ID OF THE FIRST LEVER
local thelever2 = pitpuzlever2 -- CUSTOMIZE: ID OF THE SECOND LEVER
if thelever1:getLeverState() == "activated" and
thelever2:getLeverState() == "activated" then
levercount = 2
time = 1
elseif thelever1:getLeverState() == "deactivated" and
thelever2:getLeverState() == "deactivated" then
levercount = 2
time = 1
else
levercount = 1
time = steps + 2
end
for i=1,steps do
local pit = findEntity(namepart..i)
if pit then
pit:activate()
end
end
thetimer:deactivate()
end
Source:
viewtopic.php?f=14&t=3381&start=10#p34279