1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2024-12-26 02:30:40 +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,6 +83,7 @@ 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")
if marker ~= nil then
marker:set_properties({ marker:set_properties({
visual_size={x=sizex * 2, y=sizey * 2}, visual_size={x=sizex * 2, y=sizey * 2},
collisionbox = {-sizex, -sizey, -thickness, sizex, sizey, thickness}, collisionbox = {-sizex, -sizey, -thickness, sizex, sizey, thickness},
@ -90,10 +91,12 @@ worldedit.mark_region = function(name)
marker:get_luaentity().player_name = name marker:get_luaentity().player_name = name
table.insert(markers, marker) 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")
if marker ~= nil then
marker:set_properties({ marker:set_properties({
visual_size={x=sizez * 2, y=sizey * 2}, visual_size={x=sizez * 2, y=sizey * 2},
collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez}, collisionbox = {-thickness, -sizey, -sizez, thickness, sizey, sizez},
@ -102,6 +105,7 @@ worldedit.mark_region = function(name)
marker:get_luaentity().player_name = name marker:get_luaentity().player_name = name
table.insert(markers, marker) table.insert(markers, marker)
end end
end
worldedit.marker_region[name] = markers worldedit.marker_region[name] = markers
end end