Page 3 of 3
Re: Scripting Problem: Sequence Lock
Posted: Tue Sep 18, 2012 6:51 pm
by Montis
Green Cube wrote:
With my new script you can actually make any sequence. E.g. pull lever 1,4,4,2,3,1,3,2,2,3,1 ...
Don't worry, I love you all equally.
There is a problem with the script however. If you pull more than how many levers were determined by the counter the game crashes with a nil value error. I "fixed" it like this:
Code: Select all
function sequenceRiddle()
local triggerEntity = "lever"
local namingPattern = "lever_"
local sequenceOfThings = {"1","2","3"}
local sequenceCounterID = "myCustomSequenceCounter"
local curSeq = #sequenceOfThings+1-myCustomSequenceCounter:getValue()
for i in entitiesAt(party.level, party.x, party.y) do
if i.name == triggerEntity then
if( myCustomSequenceCounter:getValue() == 0 ) then
myCustomSequenceCounter:reset()
sequence_door:close()
elseif i.id == namingPattern..sequenceOfThings[curSeq] then
findEntity(sequenceCounterID):decrement()
end
end
end
end
Maybe it already worked though and I just screwed up.
you can also just connect the counter with itself (in addition to the door) and tell it to reset when activated (activate = reaches zero).
Re: Scripting Problem: Sequence Lock (solved)
Posted: Fri Oct 05, 2012 10:08 am
by akroma222
Hey Peoplez,
Am I able to use this coding if my 3 activationh entities are different kinds of buttons?? (ie, a small secret button, a large secret button and a wall button)?? It has been mentioned that this coding is doable for levers or buttons (but not a mixture of both I assume?)
I have followed Montis' coding for this and followed the instructions word for word as above (THANK YOU SIR! - except for - sequenceSecretDoor1 and triggerEntity = "button") and I can not get it to work

.... obviously when I connect the activation entities, given they are buttons, I can only choose -event:toggle- not -event:activate- as instructed....
Hmmmmm
Right! So I changed all the different kinds of buttons to just levers (sequenceLever1-3 and obviously triggerEntity to "lever") and it works fine. So I guess the issue is the different kinds of buttons used in the same puzzle. Will leave it with levers for now
Further I guess it should be mentioned that these buttons/levers were sprayed around a room that supported 2 rotating teleporter maze puzzles...evidently not interferring with the sequencing.
Thanks again all of you!
Re: Scripting Problem: Sequence Lock (solved)
Posted: Sat Oct 06, 2012 12:47 pm
by akroma222
OK, so I have copied and pasted the coding from above and instead have used pressure plates (triggerEntity = "plate".. also tried "pressure_plate")... but ze door will not open!?
I have tried running over the plates and also leaving items on them (in order) but to no avail....
How would one need to change this coding for pressure plates?
Re: Scripting Problem: Sequence Lock (solved)
Posted: Tue Oct 23, 2012 8:51 am
by akroma222
In an attempt to ressurect my plate sequence riddle, I tried using Montis' sequence riddle code (the one posted up in the super thread) in conjunction with Komag's suggestion of connecting plates to scripts which then toggle a lever (then connecting the lever to the aforementioned riddle script)....
Code: Select all
-- plate lever toggle
function platetoggle()
mylever:toggle()
end
The idea behind this is that you can hide the levers elsewhere so it seems the plates are doing all the work (with no intermediate lever/scripting)
Unfortunately though, the sequence riddle script requires the party to be at the space of the lever for it to trigger the sequence solution.... (the levers are still toggled by the plates), hense, defeating the purpose of hiding the levers, which = doesn't work.
Has anyone else had any success with creating plate sequence puzzles??
Re: Scripting Problem: Sequence Lock (solved)
Posted: Tue Oct 23, 2012 10:39 am
by Komag
Can you explain a bit more detail about what you want to do exactly? If I have a better idea then I'm sure we can help with a good solution.
The idea to trigger levers was a very old one which I probably wouldn't do again now that I know more about how things work and about scripting.
Re: Scripting Problem: Sequence Lock (solved)
Posted: Tue Oct 23, 2012 11:04 am
by akroma222
Ahh for sure Komag!
I have a room, with six pressure plates and two secret doors.
I am trying to create a simple sequence puzzle with the pressure plates (correct sequence of 3 to open 1 door, another sequence of 3 to open the other).
As ^^mentioned, I tried using the plates to trigger the lever toggle script (1 script for each) you have posted on a diff thread. The levers were then connected to the sequence riddle script that has been refined in this thread by Montis/Green Cube etc. Except, the seqeunce riddle requires the party to standing on the space containing the lever (I am pretty sure after testing diff lever positions) - as such - using the plate script to toggle hidden levers does not work. The whole rig up worked fine when the levers were on the spaces with their corresponding pressure plates though... which defeats the purpose lol
In essence, I would like to use plates for a sequence riddle

Re: Scripting Problem: Sequence Lock (solved)
Posted: Tue Oct 23, 2012 11:13 am
by Komag
Are they entirely independent of each other? I mean, is it like you have plates A B C D E F, and to open door 1 you need to step on A, F, C, and to open door 2 you need to step on E, B, D, or something like that?
If so, it's easy to just set up each puzzle separately.
I have developed a decent sequence script, but it only applies to a sequence where each plate you have to step on in order is a different plate, with no repeats such as A, F, A.
If you have some overlap between the two puzzles, such as A, F, C for door 1 and E, F, D for door 2, that could make things a little more tricky, but not much. If you have repeats, like A, F, A, then my setup would have to be different, but not too much.
Re: Scripting Problem: Sequence Lock (solved)
Posted: Tue Oct 23, 2012 12:01 pm
by akroma222
Ahh very cool Komag!
I hadn't even started to set up the 2nd plate sequence yet, I was still stumped on making the 1st work lol - so unsure to answer the question.
Using the same plate in both sequences opens up more permutations (which is better for puzzlyness), but it would definitely be handy to know how to manage the coding without...
I was not planning on using the same plate in a single sequence, however, which makes things simpler....
Re: Scripting Problem: Sequence Lock (solved)
Posted: Tue Oct 23, 2012 12:28 pm
by Grimwold
It might be worth noting here that a connector to a function in a script entity passes the triggering entity as a variable so you can set up a function that checks which plate called the function.
e.g.
Code: Select all
function checkPlate(self)
if self.id == "plate_A" then
-- do something here.
else
-- reset the puzzle here.
end
end
so you could build a function up with multiple checks to see which plates have been previously pressed. You would need a way to store which plates have been pressed... either with variables defined outside the function, or by using counters tied to each step in the sequence.
Re: Scripting Problem: Sequence Lock (solved)
Posted: Tue Oct 23, 2012 2:40 pm
by akroma222
Very interesting, thanks again Grimwold haha!
I will have a muck around with this and repost when I have something decent...