ID:161426
 
is there any way to determine what key was pressed by a user without defining a specific macro for that key? From what I've seen its not. This would be incredibly usefull for setting up in-game hotkeys without having to code the same thing multiple times for multiple keys, and depending on how it worked possibly even for some kind of on-screen/in-game data entry system
mob/verb
F5()
set hidden=1
var/Skill2Use=src.HotKeys["F5"];src.UseSkillProc(Skill2Use)

I basicaly have to have that exact same code for keys F5-F8 because from what I've seen theres no way to determine which key was pressed
I don't think that this is in the suite internally but you can make it in the game with some clever programming.

George Gough
You can take advantage of the fact that macros are just manual calls to the command line. Therefore, you can call a verb and send various arguments. What you can do is define a single verb to handle your set of key macros, and send a different value parameter depending on the key being pressed.

mob/verb
hotkey(cmd as text)
set hidden = 1
switch(cmd)
if("F1")
src << "You pressed F1!"
if("F2")
src << "You pressed F2!"
// ...
DoSomething(cmd)


You would call this verb by assigning the macro as "hotkey [mycommand]". For example, you could assign F1 to call "hotkey F1", and the verb would be called with the param as "F1". This will allow you to define one central verb to handle your macros, not requiring you to define many verbs for different hotkey commands.
In response to Unknown Person
i see, not 100% what i was looking for, but it should work much better then the way im doing it now, thanks =)
In response to Falacy
EH dont move my topic! this is still a feature request!
In response to Falacy
Falacy wrote:
EH dont move my topic! this is still a feature request!

What are you requesting? You do realize you can just add macros at runtime yes? So all you have to do is loop through ASCII numbers and do ascii2text() to convert them to a letter. Then make that letter a macro.

-- Data