summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2018-07-18 19:29:21 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2018-07-18 19:29:21 +0200
commitdd13f134fbce8ab7f1cc4a8fed6af8ce28f65359 (patch)
treee0a75bc4bfb11755e0e766544f70f67bafe67f2f
parent7da845d1d71e298141cedd252007a7d9577981b2 (diff)
Fix crash when protecting is not allowed
-rw-r--r--init.lua8
1 files changed, 6 insertions, 2 deletions
diff --git a/init.lua b/init.lua
index 78ba446..dec6498 100644
--- a/init.lua
+++ b/init.lua
@@ -337,6 +337,7 @@ local function protect_area(pos, dir, height, width, owner)
areas:save()
return id
end
+ minetest.chat_send_player(owner, errMsg)
return nil
end
@@ -449,9 +450,12 @@ minetest.register_node("towercrane:base", {
if no_area_violation(owner, pos) then
if dir ~= nil then
if check_space(table.copy(pos), dir, height, width, owner) then
- -- add protection area
- meta:set_int("id", protect_area(table.copy(pos), table.copy(dir), height, width, owner))
+ -- add protection area
+ id = protect_area(table.copy(pos), table.copy(dir), height, width, owner)
+ if id ~= nil then
+ meta:set_int("id", id)
construct_crane(table.copy(pos), table.copy(dir), height, width, owner)
+ end
else
chat(owner, "area is protected or too less space to raise up the crane!")
end