Trapdoor Hallway.

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Chuck_ChuckRazool
Posts: 2
Joined: Fri Nov 23, 2012 11:29 pm

Trapdoor Hallway.

Post by Chuck_ChuckRazool »

I'm trying to put in a classic sort of trap door feature where there's a single width hallway with a bunch of trap doors. They open one by one in sequence and reset themselves all at once. The player has to wait for them to be all closed and then dash forward with the doors opening up behind them. Classic dungeon stuff and it also cuts the player off from the previous area because it's impossible to go in reverse without falling in a pit.

I'm having a hard time figuring out the scripting though. The reset is easy enough just connect a timer to a script entity so it activates this script every five or so seconds.
function halltrap()
if halltrap1:isOpen() and
halltrap2:isOpen() and
halltrap3:isOpen then
halltrapreset:activate()
end
end
Halltrapreset would probably be a hidden pressure plate that closes all the trap doors. The opening of the doors would be on increasing timers 1;2;3;etc. what I can't quite figure out is how keep them from getting out of sequence. I was thinking of maybe doing a second timed script that checks the doors every half second and deactivates the door timers if the door is open. It's also possible that I'm going about this completely wrong, I think that script would look like this
function halltraprun()
if halltrap1:isOpen() then
halltimer1:deactivate()
else
halltimer1:activate()
end
end
Also is there a way to make that one script check all of the traps or would I need a separate one for each? I have no scripting experience all I know is what I've read in the script reference page and from watching those komag youtube videos.
User avatar
J. Trudel
Posts: 117
Joined: Tue Aug 28, 2012 3:05 pm
Location: Montreal, Canada

Re: Trapdoor Hallway.

Post by J. Trudel »

Link this function to a single timer and it should do the trick. Make sure you trapdoors are named as trapdoor1 ... trapdoor2 etc etc
SpoilerShow

Code: Select all

count = 0
function traphall()
  if count == 1 then
    trapdoor1:open()
  elseif count == 2 then
    trapdoor2:open()
  elseif count == 3 then
    trapdoor3:open()
  elseif count == 4 then
    trapdoor1:close()
    trapdoor2:close()
    trapdoor3:close()
    count = 0
    return
end
  count = count + 1
end
Last edited by J. Trudel on Sat Nov 24, 2012 4:00 am, edited 2 times in total.
The Lurker
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Trapdoor Hallway.

Post by Komag »

Yes, do that, and set the timer to maybe 1 second or 1.5 seconds.

(except keep the name of the counter the same, such as this:

Code: Select all

trapCount = 0
function trapHall()
  if trapCount == 1 then
    trapDoor1:open()
  elseif trapCount == 2 then
    trapDoor2:open()
  elseif trapCount == 3 then
    trapDoor3:open()
  elseif trapCount == 4 then
    trapDoor1:close()
    trapDoor2:close()
    trapDoor3:close()
    trapCount = 0
    return
  end
  trapCount = trapCount + 1
end
Finished Dungeons - complete mods to play
User avatar
J. Trudel
Posts: 117
Joined: Tue Aug 28, 2012 3:05 pm
Location: Montreal, Canada

Re: Trapdoor Hallway.

Post by J. Trudel »

Thanks for noticing my error Komag, it's corrected.
The Lurker
Chuck_ChuckRazool
Posts: 2
Joined: Fri Nov 23, 2012 11:29 pm

Re: Trapdoor Hallway.

Post by Chuck_ChuckRazool »

Thanks alot guys. Worked like a charm. 1.5 seconds is super slow though. I set it to .75
User avatar
Komag
Posts: 3654
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: Trapdoor Hallway.

Post by Komag »

Okay, whatever feels good to you, but keep in mind that many players on older hardware will have a harder time moving fast enough, so it's good to test it on a weaker computer if you can, or have a friend try it who has a weak laptop, etc.
Finished Dungeons - complete mods to play
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: Trapdoor Hallway.

Post by Neikun »

I'm fairly certain that without thunderstuck, you can't walk over a pit successfully if it toggling faster than one second. If that.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
Post Reply