better pos arg check for waypoint_compass.make_compass()
This commit is contained in:
parent
63bcd595ec
commit
185994da45
19
init.lua
19
init.lua
@ -440,17 +440,20 @@ minetest.register_craft_predict(waypoint_compass_copy_meta)
|
||||
-- owner_name is str
|
||||
-- label is str
|
||||
-- color is int in range [0,0xFFFFFF]
|
||||
local error_val = nil --ItemStack('apple') -- used this for testing with //lua
|
||||
local function make_compass(pos, owner_name, label, color)
|
||||
local itemstack = ItemStack("waypoint_compass:compass")
|
||||
local meta = itemstack:get_meta()
|
||||
if not (pos or {}).x or
|
||||
(type(owner_name) ~= 'string') or
|
||||
(type(label) ~= 'string') then
|
||||
return error_val
|
||||
end
|
||||
if not color or type(color) ~= 'number' or color < 0 or color > 0xFFFFFF then
|
||||
return error_val
|
||||
if not (pos and
|
||||
tonumber(pos.x) and
|
||||
tonumber(pos.y) and
|
||||
tonumber(pos.z) and
|
||||
type(owner_name) == 'string' and
|
||||
type(label) == 'string' and
|
||||
color and
|
||||
type(color) == "number" and
|
||||
color >= 0 and
|
||||
color <= 0xFFFFFF ) then
|
||||
return nil
|
||||
end
|
||||
set_compass_meta_pos(meta, pos)
|
||||
set_compass_meta_owner(meta, owner_name)
|
||||
|
Loading…
Reference in New Issue
Block a user