cap luaentities table entries to valid coords on load
(in case the file gets corrupted on write?)
This commit is contained in:
parent
c9c4b4cd15
commit
8d50c191c8
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user