diff options
| author | Thomas--S <Thomas--S@users.noreply.github.com> | 2017-01-15 15:51:53 +0100 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-15 15:51:53 +0100 | 
| commit | 5f1919d2bc0f56f18cccfb1cf01beeb41422bbc5 (patch) | |
| tree | 6862bb086bcc488b41515888b1cf815618e1975f /technic_chests/common.lua | |
| parent | d39797aad83ad02ed717cb52af8a28747ae60b45 (diff) | |
Update has_locked_chest_privilege to current minetest_game function
Diffstat (limited to 'technic_chests/common.lua')
| -rw-r--r-- | technic_chests/common.lua | 28 | 
1 files changed, 26 insertions, 2 deletions
| diff --git a/technic_chests/common.lua b/technic_chests/common.lua index 47054f5..b8e30a4 100644 --- a/technic_chests/common.lua +++ b/technic_chests/common.lua @@ -65,7 +65,31 @@ function technic.chests.on_inv_take(pos, listname, index, stack, player)  		..minetest.pos_to_string(pos))  end -function has_locked_chest_privilege(meta, player) -	return player:get_player_name() == meta:get_string("owner") +local function has_locked_chest_privilege(meta, player) +	if player then +		if minetest.check_player_privs(player, "protection_bypass") then +			return true +		end +	else +		return false +	end + +	-- is player wielding the right key? +	local item = player:get_wielded_item() +	if item:get_name() == "default:key" then +		local key_meta = minetest.parse_json(item:get_metadata()) +		local secret = meta:get_string("key_lock_secret") +		if secret ~= key_meta.secret then +			return false +		end + +		return true +	end + +	if player:get_player_name() ~= meta:get_string("owner") then +		return false +	end + +	return true  end | 
