Page 3 of 3
Re: How to make pit puzzle, such as the chamber of pits?
Posted: Fri Sep 28, 2012 8:25 am
by antti
Komag wrote:the dungeon crashed when trying to load into the real game as a custom dungeon
"global" variables will be stored in save games and the datatypes that are supported in save games is limited. You cannot save tables or variables that contain game objects; they should only be used locally.
Unfortunately the save games and variables -article we have on the modding page is a little behind the times and in need of an update...
Re: How to make pit puzzle, such as the chamber of pits?
Posted: Fri Sep 28, 2012 4:25 pm
by Komag
Alright, then I've had to revert some aspects (including "steps") and rearrange a bit so it will work in game:
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
The customizing still happens near the top of each function this way, and now it works both in the editor and in the regular game!
Re: How to make pit puzzle, such as the chamber of pits?
Posted: Fri Sep 28, 2012 8:23 pm
by Obyvvatel
I made it without scripting, and now i'm just like how the heck that happend?
Re: How to make pit puzzle, such as the chamber of pits?
Posted: Fri Sep 28, 2012 8:40 pm
by Komag
impressive! Do you have the levers to reverse the order yet?
Re: How to make pit puzzle, such as the chamber of pits?
Posted: Fri Sep 28, 2012 8:46 pm
by Obyvvatel
No, I can put second button that makes the same sequence of events, but in reverse order (if I only used my crappy English correctly you will understand me)