• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Return Key being pressed

Status
Not open for further replies.
Level 3
Joined
Nov 3, 2008
Messages
44
Howdy again folks.
I've searched a while through the forums and tons of Google pages but couldn't find any proper answers.

The trigger I'm "dreaming" of looks like the following:
  • Events
    • Player - (Player(1)) Presses the Left Arrow key
    • Player - (Player(1)) Presses the Right Arrow key
  • Conditions
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Pressed key) Equal to Right Arrow Key
      • Then - Actions
      • Else - Actions
My problem: There is no function (at least GUI-wise) that could return the key being pressed.
Do I need to create a trigger for each of the inputs or can you help me?
I would be very grateful if you could post a Custom Script which returns it somehow.


btw.: You forum admins are stunningly helpful and active all the time! :aht::ab:
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
There is the GetTriggerEventId-function in jass which returns another value for each key triggering. But separation is not too cumbersome since there are only a few possibilities here and you can easily forge your custom event.

  • Events
    • Player - (Player(1)) Presses the Left Arrow key
  • Conditions
  • Actions
    • Set KEY_PRESSED = KEY_LEFT
    • Trigger - Run KeyPress <gen> (ignoring conditions)
  • Events
    • Player - (Player(1)) Presses the Right Arrow key
  • Conditions
  • Actions
    • Set KEY_PRESSED = KEY_RIGHT
    • Trigger - Run KeyPress <gen> (ignoring conditions)
  • KeyPress
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • KEY_PRESSED Equal To KEY_LEFT
        • 'THEN'-Actions
        • 'ELSE'-Actions
All variables being integers, LEFT and RIGHT initialized with different values.
 
Level 3
Joined
Nov 3, 2008
Messages
44
I think we misunderstood each other right there.
Yes, for sure. As I can tell from the implemented Events, there is only a few keys that can trigger something.

In the WEUnlimited there is a Condition doing the following:
  • (Get the event that fired the trigger) Equal to (my_eventid())
Before one starts to tell me WEU would screw up, I'd like to state that Im aware of it and not using it.
Still, the WEU can only make possible what could be done by script anyways.

Therefor my question:
Can I refer to the event with a Custom Script or even return the key just been pressed?
 
Level 3
Joined
Nov 3, 2008
Messages
44
There is the GetTriggerEventId-function in jass which returns another value for each key triggering. But separation is not too cumbersome since there are only a few possibilities here and you can easily forge your custom event.

  • Events
    • Player - (Player(1)) Presses the Left Arrow key
  • Conditions
  • Actions
    • Set KEY_PRESSED = KEY_LEFT
    • Trigger - Run KeyPress <gen> (ignoring conditions)
  • Events
    • Player - (Player(1)) Presses the Right Arrow key
  • Conditions
  • Actions
    • Set KEY_PRESSED = KEY_RIGHT
    • Trigger - Run KeyPress <gen> (ignoring conditions)
  • KeyPress
    • Events
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • 'IF'-Conditions
          • KEY_PRESSED Equal To KEY_LEFT
        • 'THEN'-Actions
        • 'ELSE'-Actions
All variables being integers, LEFT and RIGHT initialized with different values.

Wops, there we go.
Okay, you're right. Not worth the Custom Script.
Will do it that way.

Thanks to you! :)
 
Level 3
Joined
Nov 3, 2008
Messages
44
Never mind. :)

For anybody else having Jass knowledge and time to waste.
I'd be still interested in how I have to use the custom script.
This is what I know so far:
  • Custom script: if GetTriggerEventId() == "Check Key" then
  • "Key 1 - Actions"
  • Custom script: endif
What is "Check Key" supposed to be when I'm trying to return the left arrow key?
 
Status
Not open for further replies.
Top