diff options
author | sfan5 <sfan5@live.de> | 2016-12-21 14:26:24 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2016-12-21 14:26:24 +0100 |
commit | aa0e46d4e2095c4492a021e4056d612503358ce1 (patch) | |
tree | 5aec842c086e69abc443aa2c52b221ede4a27f87 | |
parent | 83288c969ee29a62f3babcb00cfa5fa5394d7c67 (diff) |
Handle failure of minetest.add_entity()
(see minetest/minetest#4923)
-rw-r--r-- | worldedit_commands/mark.lua | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/worldedit_commands/mark.lua b/worldedit_commands/mark.lua index 79451d6..9d41bda 100644 --- a/worldedit_commands/mark.lua +++ b/worldedit_commands/mark.lua @@ -83,24 +83,28 @@ worldedit.mark_region = function(name) --XY plane markers
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")
- marker:set_properties({
- 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)
+ if marker ~= nil then
+ marker:set_properties({
+ 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)
+ end
end
--YZ plane markers
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")
- marker:set_properties({
- 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
- table.insert(markers, marker)
+ if marker ~= nil then
+ marker:set_properties({
+ 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
+ table.insert(markers, marker)
+ end
end
worldedit.marker_region[name] = markers
|