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):
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?
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-
Waldbaer
#6
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!
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
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
96 posts Belguim, Brussels, Jette, my street, my house, my PC joined
#8
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.
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!