ID:155933
 
So I recently noticed this "demo" by ssj4justdale;

http://www.byond.com/developer/Ssj4justdale/diagnolmovement

It is supposed to be a way to allow diagonal movement using the four arrow keys. Of course, it doesn't work at all, for pretty obvious reasons if you look at the code.

I wasn't originally trying to tackle this problem, I just saw the demo and thought it would be a nice feature in my current project. My question is, has anyone demonstrated a working way to accomplish this? I'm not going to get into pixel-based movement. I was wondering about the ability to detect if a key is held down instead of just 'pressed' ... I didn't think there were built in functions for that.

Any thoughts?
you need custom macros.

client/proc/makeMacro(key,command)winset(src,url_encode(command),"parent=macro;name=[key];command=[url_encode(command)]")


Then you need a some the keyup and keydown verbs and make the macros.


mob/var/list/keys[0]
mob/verb
keyDown(key)keys+=key
keyUp(key)keys-=key
mob/Login()
..()
makeMacro("SOUTH","keyDown SOUTH")
makeMacro("SOUTH","keyUp SOUTH")
//...other dirs here
handleMovement()


then handle the keys.
mob/proc/handleMovement()
spawn while(src)
sleep(3)
if(!keys.len)continue
if("SOUTH" in keys)step(src,SOUTH)
if("EAST" in keys)step(src,EAST)
//...Other dirs here.

In response to Tubutasx1
Ah that makes total sense!

Thanks for the info, doesn't seem like such a quandary any more :)
haha sorry for the bump. My demo was simply Eliminating the primary arrow movements ie: Up, Down, Left and Right or if you perfer North, South West and East.

Instead, each key sends you in a different diagnol direction.