Simpler Path/Sequence puzzle script

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
arasoi
Posts: 1
Joined: Fri Oct 17, 2014 6:07 am

Simpler Path/Sequence puzzle script

Post by arasoi »

Pardon if my searchFu has failed me, but after much digging around in these forums and else where I could not find a nice small and simple script to handle a path based puzzle . Most of what I found was a bit more complex then I thought it needed to be and was very much more advanced then I am able to deal with this early into modding :D

In the end I figured out a way to get what I was looking for which is a simple pressure plate puzzle where you have to walk a set path to open the door. Stray from the path puzzle resets.

You will need to have the connector target the script and run the checkStep function.

Code:

Code: Select all


i= 1
path = {"p2","p7","p8","p9","p4","p5","p10","p15","p20","p19","p14","p13","p18"} -- This is the list of IDs in the order you wish to trigger them. Though this could also work for buttons , levers, and such

function checkStep(sender)
   if path[i] == sender.id then  -- If the object calling this function (the sender) has An id = to the current array item then  check to see if it is the end or move to next item in array 
      checkOpen()
      spawn("fx", party.level, party.x, party.y, 0):setParticleSystem("teleporter") -- you can toss any effects  or other things you would want here as well 
      i = i + 1
   else
      resetPuzzle()  -- umm reset the puzzle Jim you done got it wrong. 
   end
end

function resetPuzzle()
   spawn("fx", party.level, party.x, party.y, 0):setParticleSystem("fireball_hit")
   i = 1 -- this will do a full reset though you could add a check to reset the puzzle to any point on the path.
end

function checkOpen() 
   if i == table.getn(path) then   -- Checks to see if we have stepped through the whole array. 
      dungeon_secret_door_4:open() -- do your thing here. In this case open the secret door. 
      i = 14
   end
end

Hopefully this helps someone else :)
Post Reply