diff options
author | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-04-09 03:18:56 -0400 |
---|---|---|
committer | Vanessa Ezekowitz <vanessaezekowitz@gmail.com> | 2017-04-09 03:18:56 -0400 |
commit | 8d50c191c89ad390cf6b870e11aaf8fd42b2c3d6 (patch) | |
tree | 7d2d84ad52a0c783a62235a064a07daa54ea4597 | |
parent | c9c4b4cd150dade811793c0795e7f6c875a5dd59 (diff) | |
download | pipeworks-8d50c191c89ad390cf6b870e11aaf8fd42b2c3d6.tar pipeworks-8d50c191c89ad390cf6b870e11aaf8fd42b2c3d6.tar.gz pipeworks-8d50c191c89ad390cf6b870e11aaf8fd42b2c3d6.tar.bz2 pipeworks-8d50c191c89ad390cf6b870e11aaf8fd42b2c3d6.tar.xz pipeworks-8d50c191c89ad390cf6b870e11aaf8fd42b2c3d6.zip |
cap luaentities table entries to valid coords on load
(in case the file gets corrupted on write?)
-rw-r--r-- | luaentity.lua | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/luaentity.lua b/luaentity.lua index 0105c91..ab7280c 100644 --- a/luaentity.lua +++ b/luaentity.lua @@ -24,6 +24,22 @@ end local function read_entities() local t = read_file() for _, entity in pairs(t) do + + local x=entity.start_pos.x + local y=entity.start_pos.y + local z=entity.start_pos.z + + x=math.max(-30912,x) + y=math.max(-30912,y) + z=math.max(-30912,z) + x=math.min(30927,x) + y=math.min(30927,y) + z=math.min(30927,z) + + entity.start_pos.x = x + entity.start_pos.y = y + entity.start_pos.z = z + setmetatable(entity, luaentity.registered_entities[entity.name]) end return t |