Page 1 of 1

Combination Lock Script error

Posted: Tue Dec 18, 2012 4:14 am
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.

Re: Combination Lock Script error

Posted: Tue Dec 18, 2012 5:33 am
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.

Re: Combination Lock Script error

Posted: Tue Dec 18, 2012 6:43 am
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

Re: Combination Lock Script error

Posted: Tue Dec 18, 2012 8:18 am
by msyblade
Ooooh, dat nifty scripting ;)

Re: Combination Lock Script error

Posted: Tue Dec 18, 2012 8:39 am
by Treybor
Thanks! I'll give these a try.

Re: Combination Lock Script error

Posted: Wed Dec 19, 2012 4:30 am
by Komag
oh, and all those need to be in the same script entity