ID:155633
 
I'm trying to figure out how I can call Northeast(), rather than just North() or East(), when both the up and right keys are held. Either that, or finding out if the Up key is being held, and the Right key is being held, and adjust to that.

The Key_State resource goes over it, but it also goes over my head. It talks quite a bit about creating the macros dynamically, but I really only need the macros/procs to be called for a couple of hardcoded keys. How do I go about this?
client
var/dir_keys = 0
var/moving = 0

proc/MoveLoop()
while(dir_keys)
var/keys = dir_keys
// account for left+right, up+down both being held down
if((keys & 3) == 3) keys &= ~3
if((keys & 12) == 12) keys &= ~12
switch(keys)
if(NORTH) North()
if(SOUTH) South()
if(EAST) East()
if(NORTHEAST) Northeast()
if(SOUTHEAST) Southeast()
if(WEST) West()
if(NORTHWEST) Northwest()
if(SOUTHWEST) Southwest()
sleep(world.tick_lag)
moving = 0

verb/DirChange(move as num, stop as num)
set name = ".dir"
set instant = 1
dir_keys |= move
dir_keys &= ~stop
if(!moving)
moving = 1
spawn(-1) MoveLoop()


For your macros, you would define them like so:

North: .dir 1 0
North+UP: .dir 0 1
South: .dir 2 0
South+UP: .dir 0 2
East: .dir 4 0
East+UP: .dir 0 4
West: .dir 8 0
West+UP: .dir 0 8
In response to Lummox JR
Thank you very much. Playing with macros is very new to me. I've also learned turning "control_freak" on helps quite a bit, eheh.
In response to SqueakyReaper
I've got another question, if that's alright.

macro
west return "move -1 0"
east return "move 1 0"
north return "move 0 1"
south return "move 0 -1"

Simple enough to define macros like that. My question though is how would I make it so there's a macro for when a key is done being held? In .dmf files we can define "West+UP", but how would we do that in a .dms file?
In response to SqueakyReaper
The .dms is pretty much depreciated at this point since a .dmf can accomplish everything the .dms could do and much, much more.
In response to LordAndrew
Curses. I type a lot faster than I navigate menus, and I'm more comfortable with copying/pasting code over. Is there no way to define macros like these at run-time, or should I just go with the .dmf?
In response to SqueakyReaper
According to the skin reference, macros can indeed be created at runtime.

winset(usr, "myCtrlEmacro", "parent=macro1;name=Ctrl+E;command=exit")


This is an example it gives of creating them.
In response to LordAndrew
Wasn't quite able to make sense of that. I suppose I can always just use the .dmf file, eheh.
In response to SqueakyReaper
Bah. Why was the .dms file depreciated, anywho? It seems really easy to just go "macro/s return "blah 1 0" rather than fiddle with interface files. xD

Oh well. A lot of "simple key handling" libs aren't so simple, and there's a lot of mess everywhere when it comes to code. Upsetting.
Alright, here's another fun Macro related question.

I can now create a .dmf that's empty, and create macros at run time. The only thing there is that I have to have a macro list when the game starts. How do I create a new macro list at run time?