Add support for ownerless locked chests
This commit is contained in:
parent
b897440d5d
commit
b38d7373c1
@ -22,6 +22,10 @@ function locks.is_owner(meta, player)
|
|||||||
return name == owner
|
return name == owner
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function locks.has_owner(meta)
|
||||||
|
return meta:get_string("lock_owner") ~= ""
|
||||||
|
end
|
||||||
|
|
||||||
function locks.is_locked(meta, player)
|
function locks.is_locked(meta, player)
|
||||||
if all_unlocked then
|
if all_unlocked then
|
||||||
return false
|
return false
|
||||||
@ -133,6 +137,7 @@ minetest.register_node(
|
|||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_float("last_lock_pick", -1)
|
meta:set_float("last_lock_pick", -1)
|
||||||
|
meta:set_string("infotext", S("Locked Chest"))
|
||||||
|
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
inv:set_size("main", 8 * 4)
|
inv:set_size("main", 8 * 4)
|
||||||
@ -195,7 +200,7 @@ minetest.register_node(
|
|||||||
can_dig = function(pos, player)
|
can_dig = function(pos, player)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local inv = meta:get_inventory()
|
local inv = meta:get_inventory()
|
||||||
return inv:is_empty("main") and locks.is_owner(meta, player)
|
return inv:is_empty("main") and (locks.is_owner(meta, player) or (not locks.has_owner(meta)))
|
||||||
end,
|
end,
|
||||||
write_name = function(pos, text)
|
write_name = function(pos, text)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
Loading…
Reference in New Issue
Block a user