Backlog

by Ter13
Welcome to my brain's backwash
ID:2117767
 
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()
Overhaul:

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]
if(.)
var/list/l = splittext(.," ")
if(l.len>1)
var/func = l[1]
if(hascall(src,func))
for(var/pos in 2 to l.len)
. = l[pos]
if(findtext(.,"\[",1,2)&&findtext(.,"]",-1))
. = getInput(copytext(.,2,-1))
if(.==null)
return
l[pos] = .
l.Cut(1,2)
return call(src,func)(arglist(l))
else if(hascall(src,.))
return call(src,.)()
return 0
else
return 1
proc
setupBinds()
binds.len = 128
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"
binds[67] = "Interact \[dir] close"
binds[79] = "Interact \[dir] open"

getInput(filter)
control_filter = filter
last_key = null
while(last_key==null&&control_filter==filter)
sleep(world.tick_lag)
control_filter = null
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

Interact(target,action)
mob.Interact(target,action)