1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Welcome to the new Hive! Be advised that we're still working on the site. There are still many rough edges, so please bear with us.
    Dismiss Notice
  3. The 14th Icon Contest is still in progress (and may be extended). You can still make it in time.
    Dismiss Notice
  4. The 25th Texturing Contest has started! Contestants are to create a skin representing a dark elf person/being or any construct related to it using the vanilla models or the custom ones found on the site.
    Dismiss Notice
  5. The poll for Terraining Contest #18 is finally up! Play through the maps and cast your vote on your favourite.
    Dismiss Notice
  6. 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
  7. Voting squad, line up! Cast your vote on the poll for Modeling Contest #29 - Squads!
    Dismiss Notice
  8. 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
  9. The poll for the theme of our StarCraft II Terraining Contest is up. Cast your note now!
    Dismiss Notice
  10. The ninth Concept Art Contest has launched. Enter now!
    Dismiss Notice
  11. The member Kam is making HIVE coasters. Take a look. For every coaster you buy, Hive gets $1.
    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,096
    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,101
    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,365
    @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,101
    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,365
    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,101
    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,365
    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,365
    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,365
    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,365
    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,365
    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,365
    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.