summaryrefslogtreecommitdiff
path: root/library/lua/dfhack.lua
diff options
context:
space:
mode:
Diffstat (limited to 'library/lua/dfhack.lua')
-rw-r--r--library/lua/dfhack.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/library/lua/dfhack.lua b/library/lua/dfhack.lua
index e96bb0f4..baf0d42e 100644
--- a/library/lua/dfhack.lua
+++ b/library/lua/dfhack.lua
@@ -169,6 +169,23 @@ function xyz2pos(x,y,z)
end
end
+function pos2xy(pos)
+ if pos then
+ local x = pos.x
+ if x and x ~= -30000 then
+ return x, pos.y
+ end
+ end
+end
+
+function xy2pos(x,y)
+ if x then
+ return {x=x,y=y}
+ else
+ return {x=-30000,y=-30000}
+ end
+end
+
function safe_index(obj,idx,...)
if obj == nil or idx == nil then
return nil