which entity to use for a master switch?

Discussion in 'Mapping Questions & Discussion' started by bob+M|M+, May 16, 2008.

  1. bob+M|M+

    bob+M|M+ L6: Sharp Member

    Messages:
    348
    Positive Ratings:
    185
    I have several func_buttons that last for 3 seconds each. When they are all activated at the same time within those 3 seconds, a master switch will activate. what do I use as the master?? sorry if this is a noob question =P

    thanks
    bob
     
  2. TheDarkerSideofYourShadow

    TheDarkerSideofYourShadow L10: Glamorous Member

    Messages:
    792
    Positive Ratings:
    144
    No idea if this would actually work, but:

    Have each button increment a counter, and decrement it after 3 seconds. After each button is pressed, it triggers a compare between the counter value and however many buttons you have. If they are correct, trigger the event.

    Like I said, I haven't tried this at all, I'm just looking at the way I would do something similar in a program.
     
    • Thanks Thanks x 1
  3. rt3407v06p909

    rt3407v06p909 L1: Registered

    Messages:
    30
    Positive Ratings:
    17
    A math_counter would work. When each button is pressed, add one. When each button resets, subtract one. Have the max value be 3. Leave the initial value at zero.

    Have the math_counter's OnHitMax do the "Master Switch" behavior.
     
    • Thanks Thanks x 3
  4. bob+M|M+

    bob+M|M+ L6: Sharp Member

    Messages:
    348
    Positive Ratings:
    185
    Thanks rt3407c06p909, that worked perfectly. btw what does your name mean? it's so hard to type...
     
  5. rt3407v06p909

    rt3407v06p909 L1: Registered

    Messages:
    30
    Positive Ratings:
    17
    I use a random name & password generator for all the forums I visit, so each one is unique. Just a habit I got into after seeing so much identity theft online.

    Put simply, the name means nothing, it's just different than all the other names. ;)
     
  6. AWESOME-O

    AWESOME-O L10: Glamorous Member

    Messages:
    782
    Positive Ratings:
    67
    lol you really took the time to write rt340.... etc? LOL
     
  7. Foreverkul

    Foreverkul L4: Comfortable Member

    Messages:
    157
    Positive Ratings:
    14
    Each time a button is pressed compare if the other buttons are pressed?
     
  8. rt3407v06p909

    rt3407v06p909 L1: Registered

    Messages:
    30
    Positive Ratings:
    17
    No, it should be an asynchronous event, that is, it should fire when the counter hits 3, so you should not have to compare/poll.

    I've attached a .VMF and .BSP that demonstrates this technique.
     
    Last edited: May 18, 2008
  9. Lord Ned

    Lord Ned L7: Fancy Member

    Messages:
    421
    Positive Ratings:
    174
    Does this mean you have sticky notes all over the monitor that say "tf2maps.net:rt3407v06p909;19476,passwordhere"?
    :w00t:
     
  10. TotalMark

    TotalMark L6: Sharp Member

    Messages:
    331
    Positive Ratings:
    40
    I've thought about that myself, but I don't have anything important enough to justify the effort.