var
list/__keydirs = list(NORTHEAST,SOUTHEAST,SOUTHWEST,NORTHWEST,WEST,NORTH,EAST,SOUTH)
#define key2dir(key) ((key in 33 to 40) ? __keydirs[key-32] : key==12 ? 0 : null)
#define key2alpha(key) ((key in 65 to 90) ? ascii2text(key) : null)
#define key2num(key) ((key in 48 to 57) ? key - 48 : null)
#define key2alphanum(key) ((key in 65 to 90) ? ascii2text(key) : (key in 48 to 57) ? key - 48 : null)
client
var
control_filter = null
last_key = null
list/binds = list()
verb
onKey(key as num)
set waitfor = 0
set instant = 1
last_key = key
switch(control_filter)
if(null)
if(key<1||key>binds.len) return 0
. = binds[key]
return .&&hascall(src,.)&&call(src,.)()
else
return 1
proc
setupBinds()
binds.len = 40
binds[12] = "center"
binds[33] = "northeast"
binds[34] = "southeast"
binds[35] = "southwest"
binds[36] = "northwest"
binds[37] = "west"
binds[38] = "north"
binds[39] = "east"
binds[40] = "south"
getInput(filter)
control_filter = filter
last_key = null
while(last_key==null&&control_filter==filter)
sleep(world.tick_lag)
switch(filter)
if("dir")
return key2dir(last_key)
if("alpha")
return key2alpha(last_key)
if("num")
return key2num(last_key)
if("alphanum")
return key2alphanum(last_key)
if("any")
return last_key
New()
. = ..()
if(.)
setupBinds()
ID:2117767
Jul 17 2016, 8:56 pm
|
|
Jul 17 2016, 10:36 pm
|
|
Overhaul:
|