1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. The member Kam is making HIVE coasters. Take a look. For every coaster you buy, Hive gets $1.
    Dismiss Notice
  3. Buy it, use it, break it, fix it, trash it, change it, mail - upgrade it. Join (Optionally) Paired Techtree Contest #11 - Techno Magic now!
    Dismiss Notice
  4. Dismiss Notice
  5. Hero Contest #8 is up and running! This time it's a joint contest between artists and coders. Go here for team matchmaking.
    Dismiss Notice
  6. The ninth Concept Art Contest has launched. Enter now!
    Dismiss Notice
  7. Our first StarCraft contest, The Galaxy Terraining Contest #1 - World Wonders has started. Enter to show off your Galaxy Editor skills and win a custom rank icon among other things.
    Dismiss Notice
  8. Ever wanted to get your sets ready for fast texturing while still having fun? Now it is possible with our newest Mini-Texturing Contest.
    The Skeleton Units need your dire help!
    Dismiss Notice

[Snippet] Press Spacebar Event

Discussion in 'JASS Resources' started by D.O.G., Mar 18, 2012.

  1. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,121
    He calls this:
    call SetCameraQuickPosition(Space_X, Space_Y)


    So the spacebar should go to the point off screen, unless I'm mistaken.
     
  2. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,105
    Ah, my bad =). I've never used that native, so I wasn't sure what it did ;p.

    I just knew from experience that spacebar auto returns u to player start locations ^)^


    Then all this needs is the event stuff and it's good to go =D.


    Spacebar event will be a very useful event to have. It's too bad that it's local only for the moment.

    edit
    make this use timeout of .031250000 for more accurate event responses please =O. As such, please make this use CTL so that it's merged with other timers of that timeout =). All you need to do is make a TimerGroup ^_^.
     
  3. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    @D.O.G :

    Don't worry using CTL will never be a requirement for that. (In case you don't like/understand the API)
    Using one timer for that is enough fine here.
    Plus i'm not sure that even in a single player game cameras are that fast.
     
  4. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,105
    Awww, this is all u need

    call TimerGroup32.create(function Actions).start()


    You can get rid of your trigger and everything ;o.
     
  5. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    CTL is ugly to use for many of us :

    Plus, you can't get rid of the trigger action, at least not with the sync version.
    EDIT : But yeah for SpaceHandlerLocal you don't need a trigger, only a timer.
     
  6. Nestharus

    Nestharus
    Joined:
    Jul 10, 2007
    Messages:
    6,105
    Oh yea, this actually won't need recursive events. I don't see a spacebar event ever happening within a spacebar event, so you don't need to worry about the recursive stuff ;D.
     
  7. D.O.G.

    D.O.G.
    Joined:
    Oct 20, 2007
    Messages:
    347
    I'm not going to use your CTL. It doesn't add something to functionality of my snippet and is useless there. Also I don't want my snippet has any requirements
     
    Last edited: Apr 8, 2012
  8. D.O.G.

    D.O.G.
    Joined:
    Oct 20, 2007
    Messages:
    347
    Added working multiplayer version.
     
  9. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    So StoreReal with GetLocalPlayer doesn't work, you have to do a loop ?
    That doesn't really make sense, because with or without the loop it's already used in a local block for each player.

    Or have you done it just to be sure ?
     
  10. D.O.G.

    D.O.G.
    Joined:
    Oct 20, 2007
    Messages:
    347
    I've made it to be sure. I have tested - current version (4.0) works 100% with 2 players (must work with more players).

    EDIT: I've added untested version without loops. Hopefully, I could test it tonight.
     
  11. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    Also, TSA should be useless.
     
  12. D.O.G.

    D.O.G.
    Joined:
    Oct 20, 2007
    Messages:
    347
    No-no-no. Without TSA this doesn't work. I've tested without it.
     
  13. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    Ok, however have you tried without TriggerSyncStart ?
     
  14. D.O.G.

    D.O.G.
    Joined:
    Oct 20, 2007
    Messages:
    347
    Snippet updated.
    Without loops and TriggerSyncStart it works.
     
  15. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    Actually i meant without TSA and TriggerSyncStart together, instead of TriggerSyncStart + TSA. (still about the linked thread i gave)
    However, you're probably bored to do tests :p
    But this one is quite important, the TSA is lame.
    Btw you should use a timer instead.

    Also instead of leave SpacePressed "hardcoded" in the library, you should use a function interface, or the library Event.
    Else, you can't make it as a requirement in a public resource.
     
    Last edited: Apr 9, 2012
  16. D.O.G.

    D.O.G.
    Joined:
    Oct 20, 2007
    Messages:
    347
    I just realized that it works without TSA and TriggerSyncStart, but not always, if you press spacebar many times one after another it causes desync. Will try make longer timer timeout.

    Btw, why timer is better than perioddic event? One time I tryed timer - it was inaccurate.
     
  17. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    Timers are halt when the game is paused, which is not the case for TSA.
    And actually it's TSA which is innacurate and "random" with the same value, not timers.

    Also it's strange that it desync, as with the boolean two sync are not supposed to happen in the same time.

    Try with a timer instead of TSA, and check what happens.
     
  18. D.O.G.

    D.O.G.
    Joined:
    Oct 20, 2007
    Messages:
    347
    Snippet updated. Replaced periodic event with timer. Added RegisterAction function.
     
  19. Troll-Brain

    Troll-Brain
    Joined:
    Apr 27, 2008
    Messages:
    2,366
    TriggerClearActions doesn't deallocate memory used by the trigger actions, it just deactivate them, TriggerRemoveAction work as expected, but then you have to link trigger actions and the trigger.

    There is no problem with TriggerClearCondition, and in fact you don't have even to call it if you plan to destroy a trigger.
    So you could simply use trigger conditions, you can even use a function that takes and returns nothing (even if pjass won't allow that so easily, but if the argument is a code it won't cry).
    Also, for some reasons triggers conditions are faster than trigger actions and still open a new thread, but the script efficiency is not a problem here anyway, it's just a plus, it's not like you can hit the spacebar 100 times per second.
     
  20. D.O.G.

    D.O.G.
    Joined:
    Oct 20, 2007
    Messages:
    347
    Really? I used actions only because with conditions it asks for returning boolean. Will change to conditions.

    Challenge accepted! =)

    EDIT: Updated.