• 🏆 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!

-:- -:- -:- Press/Release [any key] Event -:- -:- -:-

Status
Not open for further replies.
Level 4
Joined
Nov 9, 2005
Messages
113
Hey guys, is there a way to make a JASS script that uses press/release events for any key on the keyboard.

Read this code (Press UP event):
Code:
function InitTrig_B0_Copy takes nothing returns nothing
    set gg_trg_B0 = CreateTrigger(  )
    call DisableTrigger( gg_trg_B0 )
    call TriggerRegisterPlayerKeyEventBJ( gg_trg_B0, Player(0), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_UP )
    call TriggerAddAction( gg_trg_B0, function Trig_B0_Actions )
endfunction

See the 'KEYEVENTKEY_UP'? Could there be a JASS name for another key on the keyboard. Of course 'KEYEVENTKEY_A' didn't work.
Has anyone ever worked with VisualBasic? There is a press/release function for any key where for example the A-key is like vb_50 (I know its not that or even like that, but the important thing is it's got a code). JASS should have sumthing like that, no?
 
Level 7
Joined
Jul 30, 2004
Messages
451
if there was don't you think this would have already been discovered?

just look through the JASS API, there should be some constants defined in there


infact i just did it for you

Code:
290 constant  integer bj_KEYEVENTKEY_DOWN  
288 constant  integer bj_KEYEVENTKEY_LEFT  
289 constant  integer bj_KEYEVENTKEY_RIGHT  
291 constant  integer bj_KEYEVENTKEY_UP  
284 constant  integer bj_KEYEVENTTYPE_DEPRESS  
285 constant  integer bj_KEYEVENTTYPE_RELEASE
 
Level 4
Joined
Jun 11, 2005
Messages
100
he gave u what u asked for...

290 constant integer bj_KEYEVENTKEY_DOWN
288 constant integer bj_KEYEVENTKEY_LEFT
289 constant integer bj_KEYEVENTKEY_RIGHT
291 constant integer bj_KEYEVENTKEY_UP
284 constant integer bj_KEYEVENTTYPE_DEPRESS
285 constant integer bj_KEYEVENTTYPE_RELEASE

those are what u were looking for.. or what u said where looking for.. if not, please inform us more of what u are looking for.. thx

Christ-
 
Level 10
Joined
Jul 14, 2004
Messages
463
I think he wants a similar event like the "KEYEVENTKEY_DOWN" for every single key, but as far as I know, there are really no such functions.
And that's exactly what raptor said, so his answer wasn't real help, just like mine here, but it is information on the topic you shouldn't ignore or even flame! :wink:
 
Level 7
Joined
Jul 30, 2004
Messages
451
well i guess i could have stated it directly, but basically what i tried to imply was something along the lines of

"these (insert list i previously had here) are the only keypress constants i found in the jass api, and hence i am under the assumption that the function would not be coded to handle any other ints besides the ones that are actually defined as bj_etc..."

i suppose if he -REALLY- wants to try (though i pretty much guarentee wasting of time), since the constants are just mapped to an integer, he could start throwing in random numbers...

...

actually forget i said that, i just looked up the actual function in the API, you can gander everything you need to know from it

Code:
function TriggerRegisterPlayerKeyEventBJ takes trigger trig, player whichPlayer, integer keType, integer keKey returns event
    if (keType == bj_KEYEVENTTYPE_DEPRESS) then
        // Depress event - find out what key
        if (keKey == bj_KEYEVENTKEY_LEFT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_LEFT_DOWN)
        elseif (keKey == bj_KEYEVENTKEY_RIGHT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_RIGHT_DOWN)
        elseif (keKey == bj_KEYEVENTKEY_DOWN) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_DOWN_DOWN)
        elseif (keKey == bj_KEYEVENTKEY_UP) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_UP_DOWN)
        else
            // Unrecognized key - ignore the request and return failure.
            return null
        endif
    elseif (keType == bj_KEYEVENTTYPE_RELEASE) then
        // Release event - find out what key
        if (keKey == bj_KEYEVENTKEY_LEFT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_LEFT_UP)
        elseif (keKey == bj_KEYEVENTKEY_RIGHT) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_RIGHT_UP)
        elseif (keKey == bj_KEYEVENTKEY_DOWN) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_DOWN_UP)
        elseif (keKey == bj_KEYEVENTKEY_UP) then
            return TriggerRegisterPlayerEvent(trig, whichPlayer, EVENT_PLAYER_ARROW_UP_UP)
        else
            // Unrecognized key - ignore the request and return failure.
            return null
        endif
    else
        // Unrecognized type - ignore the request and return failure.
        return null
    endif
endfunction
 
Level 4
Joined
Nov 9, 2005
Messages
113
yeah, ok, whatever...

Why do you are you giving me JASS codes that can be used in GUI anyways?
If Blizzard didn't make JASS 'understand' other keys..
WAIT A MINUTE! You see the hotkeys an abillity has? Is there a way to see how the key is called?
If so, you could try to put it instead of UP or those weird numbers? Sorry, but I'm not great at JASS. I barely use it.
 
Level 6
Joined
Feb 18, 2005
Messages
263
mh... i am not shure right now, but i took a look at the stuff. Here is a line that might be interesting

function TriggerRegisterPlayerKeyEventBJ trigger trig, player whichPlayer, integer keType, integer keKey

keKey is an integer which means it simply takes the code, assigned to each key.
Therefore, if you want another key as the triggering one, you simply have to use google (or any other ssearch engine) to get a list of keycodes.
Then simply compare them to the values of bj_KEYEVENTKEY_*
And as soon as you found the corect list - you got all the pretty little codes you might wana usse - if i remember corectly there are about 512 different ones, maybe a few less, dunno exactly
(this is NOT an asci-table - or at least it doesn't seem as though it is...)

i hope this helped you - and btw: it took me only a few seconds to look at the data-tybe of bj_KEYEVENTKEY_*
and once you see its integer, the rest should be clear.
Therefore: if you want to know something about a value, maybe take a look at the function you want it for too...

- Raszul

PS: i did not want to offend anyone, i just wanted to help!
 
Status
Not open for further replies.
Top