How to script a gate?

Discussion in 'Halo and Forge Discussion' started by ItzClementine, Jun 15, 2017.

  1. ItzClementine

    ItzClementine ONI Agent

    Messages:
    26
    Likes Received:
    2
    How to script a gate, I want the gate to go up and down like a door, for my football map how do i do that?
     
  2. ExTerrestr1al

    ExTerrestr1al Legendary
    Senior Member

    Messages:
    2,386
    Likes Received:
    2,506
    you can be very simple, or very complex with doors.

    Please be more specific about the exact type of behavior you want it to have. Is it simply a switch up/down type thing?
     
  3. ItzClementine

    ItzClementine ONI Agent

    Messages:
    26
    Likes Received:
    2
    We so far I did script to make the gates go down but I can't get it to go back up sadly, it's automatic gate, when I step on pressure play it goes down. But when I come off it don't go back up
     
  4. ExTerrestr1al

    ExTerrestr1al Legendary
    Senior Member

    Messages:
    2,386
    Likes Received:
    2,506
    Check out this write up I did which is a modification of another person's idea further up the page.

    The "pressure plate" idea may be outdated, depending on how you are doing it.

    As you'll see from my post, you need a little more sophistication added to the door to make it behave the way you really want, which is to fully open, then fully close each time, no matter whether you are still standing there or not.
     
    qrrby likes this.
  5. Ascend Hyperion

    Ascend Hyperion The Homeslice
    Staff Member Forge Critic

    Messages:
    1,099
    Likes Received:
    3,060
  6. ExTerrestr1al

    ExTerrestr1al Legendary
    Senior Member

    Messages:
    2,386
    Likes Received:
    2,506
    yes, they are all listed in that thread too. they were a great help
     
  7. ItzClementine

    ItzClementine ONI Agent

    Messages:
    26
    Likes Received:
    2
    I'm still having problems with teleport scripting please help
     
  8. ExTerrestr1al

    ExTerrestr1al Legendary
    Senior Member

    Messages:
    2,386
    Likes Received:
    2,506
    i'm not a mod, but there is no need to duplicate post... these things take time. be patient ;)
     
    qrrby likes this.
  9. Yumudas Beegbut

    Yumudas Beegbut Spartan II
    Wiki Contributor

    Messages:
    391
    Likes Received:
    349
    For this one, there's a nice trick @Agent Zero85 came up with using Boundary Check.
    • Add a Script Brain (or similar object) and set its boundary to cover the "pressure plate" area. Add the following script to it.
    • Add a 2nd Brain (called [TargetBrain] where the base point of the door should move to when it opens. Do something to make it filterable, like add a user:yankee label. No scripts for it.
    • Add a label or set something to the [Door] to make it filterable, such as add a user:xray label.

    Code:
    Condition: Boundary Check, Check=Continuous, Filter=Players, Repeat=0.40
    A1: Move Offset: OBJECTS=[Door],
    TARGETS=[TargetBrain], 0.00, 0.00, 0.00, Local=Off, Time=0.30
    A2: Wait 0.20
    A3: Position/Rotation Reset: OBJECTS=[Door], Time=0.30, Position=On, Orientation=On
    

    You can use whatever times you want for Move Offset, Position/Rotation Reset, and the Wait. It should work nicely as long as the 2nd check occurs in the Wait time & the 3rd check happens after A3 is done.
     
    #9 Yumudas Beegbut, Jun 20, 2017
    Last edited: Jun 20, 2017
  10. ExTerrestr1al

    ExTerrestr1al Legendary
    Senior Member

    Messages:
    2,386
    Likes Received:
    2,506
    not that it matters, but I may have been the first to post about using targets to open doors back on Dec. 12th. The thread linked above... Agent did have the great idea to use the Continuous On, Wait, Off method for detecting and closing, though. I then posted about how if you add one more channel check, it makes the doors perfect. Worth a read.

    Note, the thread was a discovery of the best auto-door functionality, so not all suggestions made on the pages are ideal.
     
  11. Yumudas Beegbut

    Yumudas Beegbut Spartan II
    Wiki Contributor

    Messages:
    391
    Likes Received:
    349
    I'll need to check it out when my thinking clears up a bit & piece it all together with Agent's suggestion and see what I can learn there.

    Yeah, I think the one weakness in the version I posted is that when a player steps back into the boundary while the door closes, the door will start going back up, but still take the full 0.30 seconds to get up there... so it'll move a bit slower.

    I think if we change it so that it uses a long time between each Boundary Check, the door will have time to close. If the check time is longer than the open and close times, it'll wait until the next check time to update, so both open and close can finish.

    I'm gonna update the script code above to have a Repeat=0.40 (instead of 0.35), which means it'll check to see if any players are inside right in the middle of the Wait 0.20, and if no players are there, it'll finish running the script and check again right at the very end.

    Haven't tried this exact method out yet, so if anyone gets it working (or it totally bombs) check back and let me know if you feel like it.
     
  12. ExTerrestr1al

    ExTerrestr1al Legendary
    Senior Member

    Messages:
    2,386
    Likes Received:
    2,506
    the extra channel clears that up. it makes sure that a second channel gets changed when the door is finished opening/closing. then, BOTH need to be in the desired state (one on, one off) before it can close/open again.

    I also have a map on the backburner that goes a few steps further and makes auto-doors even more perfect. I hope to get around to posting that map soon, as it is a pretty cool scripting demo.

    I think in total there are 16 auto-doors in that map, but they use a slighting enhanced method I'll talke about later...
     
    Yumudas Beegbut likes this.
  13. Yumudas Beegbut

    Yumudas Beegbut Spartan II
    Wiki Contributor

    Messages:
    391
    Likes Received:
    349
    OK, I see it now. Yeah, that method locks down control of it nice and clean. Are the Wait actions needed to fix something, or a preference kind of thing? Seems like it'd be OK to let the Power Set happen right after the Move or Reset finishes, but sometimes it seems like the Move actions don't like having something else happen right at the end.

    I would see if you can come up with a scheme to use object numbers instead to save the 2 power channels per door... Or maybe your enhanced method already does something like that? There's gotta be some tricks to do it with 1 or 0 power channels, but I can't think of 'em right now. Wait...

    Maybe a Move-Target script that has a target for open and one for closed? You can set the Spawn Order of the "open" target to 1 and the close target to 0. Then have a control script that moves the door to the one that matches the door's number, which gets toggled between 0 and 1.

    1-Action Number Toggle Trick
    Code:
    Number Change: Scope=Object, OBJECTS=[add the door], Set,
        Object Count, COUNT=[add the door + Number include 0], Value=0
    
    You can replace the 0 in Number include 0 and Value=0 with N to toggle between N and N+1
    
    That can be the 1st action and the 2nd can be the Move-Target action where OBJECTS=[add the door] and TARGETS=[add both targets + Order THIS Number include].

    I think if Condition Interrupt=Off, it'll wait until it finishes the move to either position so it won't get interrupted. Using the TARGETS in Move Offset means it'll only go to the two targets. Not sure which condition to go with.

    I don't really know... It's just fun to try to come up with stuff.
     
  14. ExTerrestr1al

    ExTerrestr1al Legendary
    Senior Member

    Messages:
    2,386
    Likes Received:
    2,506
    The wait action and allowing it to be interrupted, works in conjunction with the "continuous" detection within the boundary, so that the script cannot finish if there is still someone present. If/when they exit, a small interval passes, and the door closes.

    yes, my new method does this. It uses a number variable to take the door through a sequence of events. In order to get perfect behavior, however, it is more complex than 1s and 0s. I hope to get some time to post about that soon...

    I did think of something similar, but my aim was to use as few channels (hence the num vars) and as few labels as possible so that one map could have as many doors as possible. Each door is a two piece slider. Each door would need two or three targets and labels. To consolidate these (and what I did), one can instead start the map with the doors open, reverse the "polarity" of the open/close logic, and then force all doors closed at the start of the map. This then requires only one label, for an invis object target placed at the centerpoint of the door pieces when in its closed state.

    I literally worked for months on just this! LOL I got a perfect door and then built a map around it!

    That may work. The piece of that I do like is using object nums rather than global vars. I haven't revisited my scripts in a couple months, and have since learned how to use object nums. I plan to go back and possibly revise the doors to use object nums rather than global. This may free up some more variables that I can use for other scripts, perhaps. Or, it may turn out that there is a logistical reason why this swap will not work for my particular map, which is insanely complex in terms of scripting. It might break something else.

    Yes, it definitely is fun. It is my favorite aspect of forge, for sure!

    The Condition interrupt may work for a different scheme, but using Agent's "Continuous On, Wait, Off" (or number equivalent) requires that it is interrupted, which I tihnk creates a very elegant solution.

    Now, I am very motivated to get that map published!
     
    Yumudas Beegbut likes this.

Share This Page