1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Music Contest #8 - Hive Soundtrack is up! Create the soundtrack for the upcoming videos of Hive Workshop's YouTube Channel.
    Dismiss Notice
  3. Check out the entries of the latest Mini-Mapping Contest: Stealth! Cast your vote for here!
    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,217
    Resources:
    5
    Icons:
    1
    Spells:
    4
    Resources:
    5
    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,143
    Resources:
    3
    Spells:
    3
    Resources:
    3
    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,372
    Resources:
    0
    Resources:
    0
    @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,143
    Resources:
    3
    Spells:
    3
    Resources:
    3
    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,372
    Resources:
    0
    Resources:
    0
    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,143
    Resources:
    3
    Spells:
    3
    Resources:
    3
    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
    Resources:
    36
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    Resources:
    36
    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
    Resources:
    36
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    Resources:
    36
    Added working multiplayer version.
     
  9. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    0
    Resources:
    0
    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
    Resources:
    36
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    Resources:
    36
    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,372
    Resources:
    0
    Resources:
    0
    Also, TSA should be useless.
     
  12. D.O.G.

    D.O.G.

    Joined:
    Oct 20, 2007
    Messages:
    347
    Resources:
    36
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    Resources:
    36
    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,372
    Resources:
    0
    Resources:
    0
    Ok, however have you tried without TriggerSyncStart ?
     
  14. D.O.G.

    D.O.G.

    Joined:
    Oct 20, 2007
    Messages:
    347
    Resources:
    36
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    Resources:
    36
    Snippet updated.
    Without loops and TriggerSyncStart it works.
     
  15. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    0
    Resources:
    0
    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
    Resources:
    36
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    Resources:
    36
    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,372
    Resources:
    0
    Resources:
    0
    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
    Resources:
    36
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    Resources:
    36
    Snippet updated. Replaced periodic event with timer. Added RegisterAction function.
     
  19. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    0
    Resources:
    0
    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
    Resources:
    36
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    Resources:
    36
    Really? I used actions only because with conditions it asks for returning boolean. Will change to conditions.

    Challenge accepted! =)

    EDIT: Updated.