you can also just connect the counter with itself (in addition to the door) and tell it to reset when activated (activate = reaches zero).Green Cube wrote:Don't worry, I love you all equally.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 ...
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:
Maybe it already worked though and I just screwed up.SpoilerShowCode: 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
Scripting Problem: Sequence Lock (solved)
- Montis
- Posts: 340
- Joined: Sun Apr 15, 2012 1:25 am
- Location: Grimrock II 2nd playthrough (hard/oldschool)
Re: Scripting Problem: Sequence Lock
Re: Scripting Problem: Sequence Lock (solved)
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!
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!
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Scripting Problem: Sequence Lock (solved)
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?
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?
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Scripting Problem: Sequence Lock (solved)
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)....
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??
SpoilerShow
Code: Select all
-- plate lever toggle
function platetoggle()
mylever:toggle()
end
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??
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Scripting Problem: Sequence Lock (solved)
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.
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.
Finished Dungeons - complete mods to play
Re: Scripting Problem: Sequence Lock (solved)
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
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
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Scripting Problem: Sequence Lock (solved)
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.
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.
Finished Dungeons - complete mods to play
Re: Scripting Problem: Sequence Lock (solved)
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....
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....
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Re: Scripting Problem: Sequence Lock (solved)
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.
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.
e.g.
Code: Select all
function checkPlate(self)
if self.id == "plate_A" then
-- do something here.
else
-- reset the puzzle here.
end
end
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: Scripting Problem: Sequence Lock (solved)
Very interesting, thanks again Grimwold haha!
I will have a muck around with this and repost when I have something decent...
I will have a muck around with this and repost when I have something decent...
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)