moving portal mechanic?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
roachburn
Posts: 17
Joined: Wed Sep 19, 2012 11:22 am

moving portal mechanic?

Post by roachburn » Fri Sep 21, 2012 9:16 am

You guys probably remember this puzzle from the main game that used this mechanic. So you got a 3X3 square room with a pit in the middle and 2 portals on opposite ends rotating around the room counter clockwise. There are some other elements about the room but that's irrelevant according to what I need to accomplish in my own version of the puzzle. How would I implement this portal rotation? I thought I had a way by putting portals on all squares inside the room and using timers, but the way I had it in my head got too confusing and used too many timers. Any ideas on what to use, be it timers, counters or script? I am definitely interested in multiple way to do it too. Here is a slide show illustration of what I mean if anyone is unable to understand my description. The portals should change every 1 second in a continuous rotation around the room. I want it to be triggered with a hidden pressure plate when entering the room and stopped by another pressure plate on the other end.
Image

User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: moving portal mechanic?

Post by petri » Fri Sep 21, 2012 9:34 am

Hint: there are four states, so you need a ticker that goes 0,1,2,3,0,1,2,3,...

User avatar
Shroom
Posts: 98
Joined: Tue Mar 27, 2012 6:37 pm
Location: UK

Re: moving portal mechanic?

Post by Shroom » Fri Sep 21, 2012 9:35 am

an easy way to code it - not elegant but fairly straight forward, would be to use a single timer connected to a lua script with a setting of 1

the script would have a function

Code: Select all

step = 1

function cycleTeleports()

if step==1 then
  telport1:activate()
  telport4:deactivate()
  telport5:activate()
  telport8:deactivate()
  step = 2
else if step==2 then
  telport1:deactivate()
  telport2:activate()
  telport5:deactivate()
  telport6:activate()
  step = 3
else if step==3 then
  telport2:deactivate()
  telport3:activate()
  telport6:deactivate()
  telport7:activate()
  step = 4
else
  telport3:deactivate()
  telport4:activate()
  telport7:deactivate()
  telport8:activate()
  step = 1
end
All we are really doing is building a counter into the script and then turning off two and turning on two each tick of the timer.

The pressure pads would activate and deacivate the timer - you would also have them deactivate all the teleports

Code: Select all


function resetTeleports()
  telport1:deactivate()
  telport2:deactivate()
  telport3:deactivate()
  telport4:deactivate()
  telport5:deactivate()
  telport6:deactivate()
  telport7:deactivate()
  telport8:deactivate()
  step = 1
end
this would need to be in the same script entity as the first script.

Am unable to test this, but it should work - if the second script cant see step, then link it to a counter instead

User avatar
Grimwold
Posts: 508
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: moving portal mechanic?

Post by Grimwold » Fri Sep 21, 2012 11:04 am

I tested this and it worked well, although I needed to fix a couple of minor mistakes in the script (easily done when writing untested code). I also changed the names of the teleporters in the script to the convention used by the editor when placing them.

Code: Select all

step = 1

function cycleTeleports()
    if step==1 then
      teleporter_1:activate()
      teleporter_4:deactivate()
      teleporter_5:activate()
      teleporter_8:deactivate()
      step = 2
    elseif step==2 then
      teleporter_1:deactivate()
      teleporter_2:activate()
      teleporter_5:deactivate()
      teleporter_6:activate()
      step = 3
    elseif step==3 then
      teleporter_2:deactivate()
      teleporter_3:activate()
      teleporter_6:deactivate()
      teleporter_7:activate()
      step = 4
    elseif step==4 then
      teleporter_3:deactivate()
      teleporter_4:activate()
      teleporter_7:deactivate()
      teleporter_8:activate()
      step = 1
    end
end

function resetTeleports()
  teleporter_1:deactivate()
  teleporter_2:deactivate()
  teleporter_3:deactivate()
  teleporter_4:deactivate()
  teleporter_5:deactivate()
  teleporter_6:deactivate()
  teleporter_7:deactivate()
  teleporter_8:deactivate()
  step = 1
end
In addition to the script you will need

- a timer with interval 1 second and with action point at the script entity cycleTeleports
- start pressure plate with 2 CONNECTORS
---- one to the script entity resetTeleporters
---- one to the timer with an activate action
- end pressure plate
with 2 CONNECTORS
---- one to the script entity resetTeleporters
---- one to the timer with an deactivate action

User avatar
Komag
Posts: 3639
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: moving portal mechanic?

Post by Komag » Fri Sep 21, 2012 4:19 pm

Yeah, it's threads like this that really peel back the curtain ;)

and this would probably make a decent addition to the Useful scripts repository
Finished Dungeons - complete mods to play

roachburn
Posts: 17
Joined: Wed Sep 19, 2012 11:22 am

Re: moving portal mechanic?

Post by roachburn » Sat Sep 22, 2012 6:28 am

Thanks for all the advice guys. I managed to get this to work. I was also able to adapt it to some other puzzles I made. This dungeon is coming along nicely!

User avatar
akroma222
Posts: 1025
Joined: Thu Oct 04, 2012 10:08 am

Re: moving portal mechanic?

Post by akroma222 » Fri Oct 05, 2012 7:37 am

Thank you guys!! rotating teleporters are now on the menu ;)

bravocharlie
Posts: 1
Joined: Mon Jan 21, 2013 12:48 pm

Re: moving portal mechanic?

Post by bravocharlie » Mon Jan 21, 2013 12:49 pm

can we play wwe with tihs?

User avatar
Komag
Posts: 3639
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: moving portal mechanic?

Post by Komag » Mon Jan 21, 2013 4:45 pm

what's wwe?
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: moving portal mechanic?

Post by Neikun » Tue Jan 22, 2013 2:22 am

I think it's just a typo. "Can we play with this?"
"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