1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Snippet] Press Spacebar Event

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

  1. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,051
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Good luck getting users to download yet another thing to make your script work instead of putting the workaround in your script directly.

    Don't get me started on how JASS/vJass has already always been full of hacks...
     
  2. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Code (vJASS):
        globals
            private integer Local_I //= GetPlayerId(GetLocalPlayer())
            private string Local_S //= I2S(Local_I)
            private real array Space_X
            private real array Space_Y
            private real Sync_X
            private real Sync_Y
            private boolean Not_Sync = true
            private gamecache Cache
            private timer Space_Timer = CreateTimer()
            private player Space_Player
            private trigger Space_Actions = CreateTrigger()
        endglobals


    Space_Player, Sync_X and Sync_Y should be initialized to null, 0 and 0 respectively.

    Also, if it's possible, could we have the timer period configurable?
    (To give beginners the ability to easily modify the system without having to go through all the code and messing something up.)

    This is actually very well written. (I don't care if you repeated I2S(i) twice in the loop.)
     
  3. D.O.G.

    D.O.G.

    Joined:
    Oct 20, 2007
    Messages:
    348
    Resources:
    38
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    JASS:
    2
    Resources:
    38
    Done!
     
  4. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    The timer period is still not configurable, you just need to use a constant real in the top of your global block.

    Also why the return null in the AddSpaceBarAction, it seems completely useless, it even makes this function not inline friendly.
     
  5. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    That 'return null' line allows this to compile with Vexorian's JassHelper :p
     
  6. Troll-Brain

    Troll-Brain

    Joined:
    Apr 27, 2008
    Messages:
    2,372
    Resources:
    1
    JASS:
    1
    Resources:
    1
    Are you sure ?!

    We are not talking about a "return null" function which is used in a filter.
    I don't see how the "return null" would be needed, since TriggerAddCondition returns a triggercondition.
     
  7. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Trust me, we discussed this about 2-3 pages ago ;P

    edit
    Well, I really couldn't care less if the timer period isn't configurable.
    It's still just as fast as the native Unit-in-range event.

    Approved.
     
  8. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    Hey there,

    I recently started using this snippet, however it's not working great for my purposes. I was wondering if I just have to deal with that or if there's a way around it. Because I'm making a 2dimensional interface menu that's being controlled with the arrow keys. When I select a button in it I have to press the space bar.
    However... Since I have to lock my camera (or move it to the position on the map once every ~0.03 sec) it doesn't work anymore.
    Locking the camera completely made tracking the space button impossible while moving camera every 0.03sec triggered the action like once every 20 presses.

    So once again. Should I just forget using the spacebar with this purpose? Or is there something I could change to make it work for me?
     
  9. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,789
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    That's because camera positions only get updated once every 0.0x seconds (don't know the exact interval, but I think its somewhere around 0.1) in multiplayer (In singleplayer, it should happen more often).
     
  10. D.O.G.

    D.O.G.

    Joined:
    Oct 20, 2007
    Messages:
    348
    Resources:
    38
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    JASS:
    2
    Resources:
    38
    If you are locking camera using appropriate function, this definitely wouldn't work.
    However, using periodical camera panning should work, but I think in this case camera code should be put in the snippet code. I haven't tested my snippet very well. I don't have time to do it.
    Also multiplayer version shouldn't be used - it doesn't work correctly all the time - so it can cause desync in some cases (I think when pressing spacebar too often or pressed by 2 players in exactly one time)

    I have some ideas how to improve multiplayer version and add compatibility for camera locking.
    But I repeat: too bad I don't have time.((
     
  11. EmoBrother

    EmoBrother

    Joined:
    Dec 15, 2012
    Messages:
    554
    Resources:
    0
    Resources:
    0
    Useful event, +rep
    Good
    waiting for the Multiplayer version :D
     
  12. D.O.G.

    D.O.G.

    Joined:
    Oct 20, 2007
    Messages:
    348
    Resources:
    38
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    JASS:
    2
    Resources:
    38
    Local version has big update (6.0)!
    Backspace event added!
    Details in the main post.

    To moderators: is it possible to rename thread to "[System] Spacebar and Backspace events"?
     
    Last edited: Jul 4, 2013
  13. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,146
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
  14. D.O.G.

    D.O.G.

    Joined:
    Oct 20, 2007
    Messages:
    348
    Resources:
    38
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    JASS:
    2
    Resources:
    38
  15. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,146
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    It does work... lol
     
  16. D.O.G.

    D.O.G.

    Joined:
    Oct 20, 2007
    Messages:
    348
    Resources:
    38
    Models:
    27
    Icons:
    3
    Packs:
    1
    Tools:
    3
    Maps:
    2
    JASS:
    2
    Resources:
    38
    I mean together with mine.
     
  17. Nestharus

    Nestharus

    Joined:
    Jul 10, 2007
    Messages:
    6,146
    Resources:
    8
    Spells:
    3
    Tutorials:
    4
    JASS:
    1
    Resources:
    8
    You can make it work. You'd have to do it on a periodic timer, a listener for this event. From there, u'd run the actual event within the timer, not on actual response.

    You'd continue to check for a sync'd value.
     
  18. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    Is there any news on this and multiplayer?
    Also on locking the camera in multiplayer?

    I'd very much like to use this if I can somehow lock the camera to a specific point and use it in multiplayer.