1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2024-12-25 18:20:38 +01:00

Handle failure of minetest.add_entity()

(see minetest/minetest#4923)
This commit is contained in:
sfan5 2016-12-21 14:26:24 +01:00
parent 83288c969e
commit aa0e46d4e2

View File

@ -83,24 +83,28 @@ worldedit.mark_region = function(name)
--XY plane markers --XY plane markers
for _, z in ipairs({pos1.z - 0.5, pos2.z + 0.5}) do for _, z in ipairs({pos1.z - 0.5, pos2.z + 0.5}) do
local marker = minetest.add_entity({x=pos1.x + sizex - 0.5, y=pos1.y + sizey - 0.5, z=z}, "worldedit:region_cube") local marker = minetest.add_entity({x=pos1.x + sizex - 0.5, y=pos1.y + sizey - 0.5, z=z}, "worldedit:region_cube")
marker:set_properties({ if marker ~= nil then
visual_size={x=sizex * 2, y=sizey * 2}, marker:set_properties({
collisionbox = {-sizex, -sizey, -thickness, sizex, sizey, thickness}, visual_size={x=sizex * 2, y=sizey * 2},
}) collisionbox = {-sizex, -sizey, -thickness, sizex, sizey, thickness},
marker:get_luaentity().player_name = name })
table.insert(markers, marker) marker:get_luaentity().player_name = name
table.insert(markers, marker)
end
end end
--YZ plane markers --YZ plane markers
for _, x in ipairs({pos1.x - 0.5, pos2.x + 0.5}) do for _, x in ipairs({pos1.x - 0.5, pos2.x + 0.5}) do
local marker = minetest.add_entity({x=x, y=pos1.y + sizey - 0.5, z=pos1.z + sizez - 0.5}, "worldedit:region_cube") local marker = minetest.add_entity({x=x, y=pos1.y + sizey - 0.5, z=pos1.z + sizez - 0.5}, "worldedit:region_cube")
marker:set_properties({ if marker ~= nil then
visual_size={x=sizez * 2, y=sizey * 2}, marker:set_properties({
collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez}, visual_size={x=sizez * 2, y=sizey * 2},
}) collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez},
marker:setyaw(math.pi / 2) })
marker:get_luaentity().player_name = name marker:setyaw(math.pi / 2)
table.insert(markers, marker) marker:get_luaentity().player_name = name
table.insert(markers, marker)
end
end end
worldedit.marker_region[name] = markers worldedit.marker_region[name] = markers