Garage Door Scripting Question

Discussion in 'Halo and Forge Discussion' started by leegeorgeton, Mar 24, 2015.

  1. leegeorgeton

    leegeorgeton Forerunner
    Senior Member

    Messages:
    406
    Likes Received:
    88
    I want to be able to make a garage door open and close on a continuous loop, and I want to be able to use a toggle switch (or a combo of on and off switches that acts a toggle) to turn the loop off and then turn it back on. It is imperative that the garage door stops in the open (on) position when I turn off the continuous loop with the switch. I have created a setup that does the continuous loop and I can toggle this loop on and off, but when I turn the loop off, the garage door ends up in the closed (off) position. Here are the components of the system I've come up with. If you know how I can get the garage door to stop in the open (on) position, let me know.

    Garage Door: Scripting > Broadcast Channel = 2
    Switch: Toggle: Broadcast Channel = 1
    Timer: On Once: Power Channel = 1, Broadcast Channel = 2
    Timer: On: Power Channel = 1, Broadcast Channel = 2, Timer/User Data = 18
    Timer: Off Once: Power Channel = 2, Broadcast Channel = 2, Timer/User Data = 9

    I'm not positive how it works, but it does exactly what I want it to do except I need it to be reversed some how so the door stops in the open (on) position when I hit the toggle switch to stop the continuous loop. I must also be able to start the loop up again using the same switch that stopped it. If you're wondering why the Timer: On Once is in there, it's so that when the player hits the switch there is immediate visual feedback. Without that timer, the door takes quite a while to begin moving.

    It is not as simple as just flipping the door around. The purpose of this contraption is as a component in a puzzle map I'm creating, and it is important that the correct side of the door be shown/used. Any help from some of you Scripting geniuses would be appreciated.
     
  2. buddhacrane

    buddhacrane Ancient
    Senior Member

    Messages:
    1,204
    Likes Received:
    116
    You had me at "puzzle map", even if that was near the end of the post...

    I've actually done something similar to this before (scripting logic wise) with a light and proximity triggers - I had it so that when players entered the area, the light would flash on and off on a 1 second loop, and then when players left the area, the light would stop flashing and always end up turned off. So your situation is the same, just with switches and a garage door, instead of proximity triggers and a light.

    One of the main concepts you'll need to use here, is the idea of a more "Advanced" Toggle Switch, because what you essentially want to do here is have behaviour when you toggle the Switch on, but also when you toggle the Switch off (that behaviour being to make sure you open the Garage Door). With a regular toggle you can't add behaviour when you toggle "off", so that's why we want a more advanced Toggle Switch; you setup an advanced Toggle Switch like this:
    • Switch: On - Broadcast Channel 1 (Place this switch in the exact same position as the 2nd switch - also think of this as your "toggle on" switch)
    • Timer: Off Once - Power Channel 1, Broadcast Channel 0
    • Switch: On - Power Channel 1, Broadcast Channel 0 (Place this switch in the exact same position as the 1st switch - also think of this as your "toggle off" switch)
    • Timer: Off Once - Power Channel 0, Broadcast Channel 1
    I have a video about this kind of Toggle here if you want more background, but what's basically happening is that we're toggling two Broadcast Channels at the same time, and one channel is always in the opposite state to the other (when 0 is on, 1 is off, and when 0 is off, 1 is on):

    The setup I've given you here is ever so slightly different so that your Garage door doesn't initially start off "open", before anyone has activated the switches.

    Next we add the behaviour you want to this Toggle:
    • Garage Door - Broadcast Channel 2
    • Timer: On Once - Power Channel 1, Broadcast Channel 2 (initially opens door when your "toggle on" switch is activated)
    • Timer: Toggle - Power Channel 1, Broadcast Channel 2, Timer/User Data 9 (opens/closes door every 9 seconds after "toggle on" switch is activated - will stop when "toggle off" switch is activated)
    • Timer: On - Power Channel 0, Broadcast Channel 2 (ensures the garage door is open when "toggle off" switch is activated)

    Edit: Ah, so I'm actually unsure if what you really wanted was to let the continuous loop "run its course" and be the thing to make sure the door ends up open, rather than have the door immediately open when "toggling off" the switch. Just in case, here's how you could put different Scripting logic on the Advanced Toggle, to give you that behaviour (you do this instead of the behaviour above, but still using the Advanced Toggle):
    • Garage Door - Broadcast Channel 3
    • Timer: On Once - Power Channel 1, Broadcast Channel 3 (initially open door)
    • Timer: On - Power Channel 1, Broadcast Channel 2 (kick off the looping timer)
    • Timer: Toggle - Power Channel 2, Broadcast Channel 3, Timer/User Data 9 (the looping timer)
    • Timer: Off - Spawn Channel 0, Can Despawn True, Spawn Timer Never, Place at Start False, Power Channel 3, Broadcast Channel 2 (when switch "toggled off" and door is open, kills the looping timer)
     
    #2 buddhacrane, Mar 24, 2015
    Last edited: Mar 24, 2015
    Buddy Jumps and a Chunk like this.
  3. leegeorgeton

    leegeorgeton Forerunner
    Senior Member

    Messages:
    406
    Likes Received:
    88
    Thanks,

    I'll try it out and see if it'll work like I need it to. It seems promising.
     

Share This Page