diff options
author | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-07-06 15:50:55 +0200 |
---|---|---|
committer | Elias Fleckenstein <eliasfleckenstein@web.de> | 2020-07-06 15:50:55 +0200 |
commit | e610149c0cc3516b61115541f2f4f78344a0bb2c (patch) | |
tree | b1205a15af51db02c9301f4ab8ecdd7527d13c10 /builtin/client/pos.lua | |
parent | a87805a9445f280ca71da322c4b32cf357744511 (diff) | |
download | dragonfireclient-e610149c0cc3516b61115541f2f4f78344a0bb2c.tar.xz |
Initial Commit
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 |