-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.lua
73 lines (68 loc) · 1.24 KB
/
util.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
local mod = {}
function mod.parse_exit(dir)
local ndir = ""
local rdir = ""
local dx = 0
local dy = 0
local dz = 0
if dir == "n" or dir == "north" then
dy = -1
rdir = "s"
ndir = "n"
elseif dir == "s" or dir == "south" then
dy = 1
rdir = "n"
ndir = "s"
elseif dir == "e" or dir == "east" then
dx = 1
rdir = "w"
ndir = "e"
elseif dir == "w" or dir == "west" then
dx = -1
rdir = "e"
ndir = "w"
elseif dir == "ne" or dir == "northeast" then
dy = -1
dx = 1
rdir = "sw"
ndir = "ne"
elseif dir == "nw" or dir == "northwest" then
dy = -1
dx = -1
rdir = "se"
ndir = "nw"
elseif dir == "se" or dir == "southeast" then
dy = 1
dx = 1
rdir = "nw"
ndir = "se"
elseif dir == "sw" or dir == "southwest" then
dy = 1
dx = -1
rdir = "ne"
ndir = "sw"
elseif dir == "u" or dir == "up" then
dz = 1
rdir = "d"
ndir = "u"
elseif dir == "d" or dir == "down" then
dz = -1
rdir = "u"
ndir = "d"
else
info("MAPPER", "Unknown direction: " .. dir)
end
return ndir, { dx, dy, dz }, rdir
end
function mod.info(cat, ...)
local msgs = {...}
for _,msg in ipairs(msgs) do
print(cformat(
"<bwhite>[<reset><bgreen>%s<reset><bwhite>]:<reset> %s",
cat:upper(),
msg
)
)
end
end
return mod