diff options
Diffstat (limited to 'builtin/client/pos.lua')
-rw-r--r-- | builtin/client/pos.lua | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/builtin/client/pos.lua b/builtin/client/pos.lua new file mode 100644 index 000000000..618c142e7 --- /dev/null +++ b/builtin/client/pos.lua @@ -0,0 +1,19 @@ +function core.parse_pos(param) + local p = {} + p.x, p.y, p.z = string.match(param, "^([~|%d.-]+)[, ] *([~|%d.-]+)[, ] *([~|%d.-]+)$") + for k, v in pairs(p) do + if p[k] == "~" then + p[k] = core.localplayer:get_pos()[k] + else + p[k] = tonumber(v) + end + end + if p.x and p.y and p.z then + local lm = 31000 + if p.x < -lm or p.x > lm or p.y < -lm or p.y > lm or p.z < -lm or p.z > lm then + return false, "Position out of Map bounds." + end + return true, p + end + return false, "Invalid position (" .. param .. ")" +end |