Combination Lock Script error

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Treybor
Posts: 93
Joined: Wed Jun 06, 2012 3:13 am

Combination Lock Script error

Post by Treybor »

Anyone with Script experience who can give me pointers would be a big help.
I created the follow combination lock script using pressure plates:

Code: Select all

function sequenceRiddle()
   local triggerEntity = "northern_dungeon_pressure_plate"
   local namingPattern = "sequenceLock_"
   local sequenceOfThings = {"1","3","2","4","1","3","2"}
   local sequenceCounterID = "SequenceCounter"
   local curSeq = #sequenceOfThings+1-findEntity(sequenceCounterID):getValue()
   for i in entitiesAt(party.level, party.x, party.y) do
      if i.name == triggerEntity then
         if i.id == namingPattern..sequenceOfThings[curSeq] then
            findEntity(sequenceCounterID):decrement()
         else
            findEntity(sequenceCounterID):reset()
         end
      end
   end
end
This is tied to a counter with an initial value of 7. The combination lock works, but throws a script error the next time the party steps on any of the plates. Is there a way to script around this?
Can the pressure plates be disabled or de-spawned once the combination is complete?
The only other way around this that I can think of would be to use objects to activte the combination rather than the party.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Combination Lock Script error

Post by msyblade »

I think you could hook your counter up to a 2nd script that just says

Function puzzleComplete()
sequence_plate_1: destroy --(or whatever it's named)
sequence_plate_2: destroy
sequence_plate_3: destroy
sequence_plate_4: destroy --just do it for all 7
sequence_plate_5: destroy
sequence_plate_6: destroy
sequence_plate_7: destroy

end

and when the sequence is complete, and counter activates, it will run this script and destroy your plates for you.
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Combination Lock Script error

Post by Komag »

you can just set a flag when it completes the first time, looks like you would have the counter do that, trigger a function like:

Code: Select all

function didpuz()
puzdone = 1
end
and add a short circuit at the start of your main function like:

Code: Select all

if puzdone == 1 then return end
you'll probably first need to add somewhere (not in a function) the line:

Code: Select all

puzdone = 0
Finished Dungeons - complete mods to play
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Combination Lock Script error

Post by msyblade »

Ooooh, dat nifty scripting ;)
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
Treybor
Posts: 93
Joined: Wed Jun 06, 2012 3:13 am

Re: Combination Lock Script error

Post by Treybor »

Thanks! I'll give these a try.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Combination Lock Script error

Post by Komag »

oh, and all those need to be in the same script entity
Finished Dungeons - complete mods to play
Post Reply