Checking Variables on Interaction (or Other Event)

Discussion in 'Halo and Forge Discussion' started by Starship Forge, Dec 10, 2016.

  1. Starship Forge

    Starship Forge Recruit
    Senior Member

    Messages:
    183
    Likes Received:
    140
    The new variable options we have are awesome. We can assign variables, and dynamically check them against some number (or other variables). This is quite easy when you simply want something to happen as soon as a variable matches some criteria, but what about the times we want to check a variable at the time some event happens, like say a user interaction? The game doesn't give us any way to link two conditions. I mean, we have message/power multi, but that's only good for binary checks, and still can't be linked directly to events like user interactions.

    Well, I found a way. You put the variable check script into a script brain, disable "Always Run" for that script, then set the script brain to despawn at match start, and include one final script to allow it to respawn using either a message or a power channel.

    Then, when the event occurs(say for example a player interacts with a switch), then as one of the script actions, you would spawn in that script brain.
     
  2. Captain Punch

    Captain Punch Content Contributor
    Staff Member Administrator Wiki Contributor Senior Member The Scripter's Guild

    Messages:
    130
    Likes Received:
    228
    I just have variable checks set power channels.

    For example, how to attach a Number: Check with a Count function to a Logic Gate.

    1| (Timer, 0.0, 0.05)
    _| <Number [Global.{1}, Set, Object Count: Boundary.THIS[add], THIS[remove]; 0, OFF]
    2| (Number [Global.{1}, 0, >, Constant, 0])
    _| <Power.{1}=ON>
    3| (Number [Global.{1}, 0, ==, Constant, 0])
    _| <Power.{1}=OFF>


    This would set Power Channel {1} to be on if anything is in an object's boundary, removing that object itself from the count.
     
    ExTerrestr1al likes this.
  3. ExTerrestr1al

    ExTerrestr1al Promethean
    Senior Member

    Messages:
    2,387
    Likes Received:
    2,515
    Captain, I t ried to implement your code above into a door script, which would be automatic via counting players in a zone. Where more than 0, open, when 0, close.
    Here is the thread:
    https://www.forgehub.com/threads/halo-5-forge-proximity-triggers.149633/

    can you tell me if the above is already perfect for such a thing? I think I interpreted your instructions correctly, but it didn't work.

    One question I have - is there a difference between POWER channels and VARIABLE channels?

    I have the above scripts set to open/close door using Echo Power channel, but am counting using the alpha var chan.

    Thanks!
     
  4. Captain Punch

    Captain Punch Content Contributor
    Staff Member Administrator Wiki Contributor Senior Member The Scripter's Guild

    Messages:
    130
    Likes Received:
    228
    Power and Variable channels are separate. Power is only ON/OFF (and the toggle event), while Variables store numbers. You have to use number check scripts to translate Variables and Variable Events into Power Channel States first. You also can't use Number Checks directly in Multi Scripts, which can be really annoying, but translation still works.
     
    ExTerrestr1al likes this.
  5. ExTerrestr1al

    ExTerrestr1al Promethean
    Senior Member

    Messages:
    2,387
    Likes Received:
    2,515
    thanks, that helps clarify the channels issue.

    hmm... I wonder what I missed in setting up what you have laid out in the previous post, then?

    could I trouble you with writing the code out in more of the typical language used by the forge UI? I think I interpreted it correctly (have done some coding etc. myself in the past ) but perhaps I did something wrong...
     
  6. Captain Punch

    Captain Punch Content Contributor
    Staff Member Administrator Wiki Contributor Senior Member The Scripter's Guild

    Messages:
    130
    Likes Received:
    228
    Replace the {1} with the first available Channel. Power.{1} would be for a Power Channel, Global.{1} would be for the first Number Channel in the Global set.

    I mistyped the thing and Number.{1} should just be number and the Global in that line should be Global.{1}.
    (I'm going to edit this, so you're not crazy that it has changed)

    You may just have something triggering the filter in the COUNT menu. Try adding Players[Include] to the filter to filter out everything that isn't a Player.

    I'm working on giving an explanation for the syntax and style guide I use for writing up scripts so they can be shared on the forums more easily, but the basic parts are pretty obvious and everything is in the order you see it as much as possible.

    If you're still having issues, it could be that you put it on a Team Script Brain (which would only detect the team it is set to) or something similar.
     
  7. ExTerrestr1al

    ExTerrestr1al Promethean
    Senior Member

    Messages:
    2,387
    Likes Received:
    2,515
    I got it. it took some testing, but I now have a nearly perfect auto door! I say nearly perfect because the two door pieces don't always revert to original position. they would need respawning when out of view of players to be perfect. that is something I almost had figured out before we got all these new tools, so I'm sure I can get that now.

    I need to make a video of this demo map, because it is pretty cool.
     

Share This Page