More variable == nil checks.
This commit is contained in:
parent
a0fac75def
commit
4704b4cf2b
1 changed files with 9 additions and 0 deletions
|
@ -325,6 +325,9 @@ minetest.register_craft({
|
||||||
local function translocate(pos, node, clicker, itemstack, pointed_thing)
|
local function translocate(pos, node, clicker, itemstack, pointed_thing)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local id = meta:get_string('id')
|
local id = meta:get_string('id')
|
||||||
|
if not (id and tonumber(id)) then
|
||||||
|
return
|
||||||
|
end
|
||||||
local pair = fun_caves.db.translocators[tonumber(id)]
|
local pair = fun_caves.db.translocators[tonumber(id)]
|
||||||
if not pair or #pair < 2 then
|
if not pair or #pair < 2 then
|
||||||
return
|
return
|
||||||
|
@ -344,6 +347,9 @@ local function trans_use(itemstack, user, pointed_thing)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local data = minetest.deserialize(itemstack:get_metadata())
|
local data = minetest.deserialize(itemstack:get_metadata())
|
||||||
|
if not (data and data.id) then
|
||||||
|
return
|
||||||
|
end
|
||||||
local player_name = user:get_player_name()
|
local player_name = user:get_player_name()
|
||||||
minetest.chat_send_player(player_name, "You see a serial number: "..data.id)
|
minetest.chat_send_player(player_name, "You see a serial number: "..data.id)
|
||||||
end
|
end
|
||||||
|
@ -354,6 +360,9 @@ local function trans_place(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
|
|
||||||
local data = minetest.deserialize(itemstack:get_metadata())
|
local data = minetest.deserialize(itemstack:get_metadata())
|
||||||
|
if not (data and data.id) then
|
||||||
|
return
|
||||||
|
end
|
||||||
local pos = pointed_thing.above
|
local pos = pointed_thing.above
|
||||||
local pair = fun_caves.db.translocators[tonumber(data.id)]
|
local pair = fun_caves.db.translocators[tonumber(data.id)]
|
||||||
if #pair > 1 then
|
if #pair > 1 then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue