mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-06-06 13:54:25 -04:00
Merge 0038a6eae6
into dfee51c21e
This commit is contained in:
commit
c2c4444fe4
1 changed files with 54 additions and 50 deletions
|
@ -2,10 +2,11 @@
|
|||
-- See README.txt for licensing and other information.
|
||||
|
||||
bones = {}
|
||||
bones.enable = true -- enabled by default, can be changed by mods
|
||||
|
||||
local function is_owner(pos, name)
|
||||
local owner = minetest.get_meta(pos):get_string("owner")
|
||||
if owner == "" or owner == name or minetest.check_player_privs(placer, "protection_bypass") then
|
||||
if owner == "" or owner == name then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
|
@ -43,11 +44,7 @@ minetest.register_node("bones:bones", {
|
|||
|
||||
can_dig = function(pos, player)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local name = ""
|
||||
if player then
|
||||
name = player:get_player_name()
|
||||
end
|
||||
return is_owner(pos, name) and inv:is_empty("main")
|
||||
return is_owner(pos, player:get_player_name()) and inv:is_empty("main")
|
||||
end,
|
||||
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
|
@ -76,11 +73,11 @@ minetest.register_node("bones:bones", {
|
|||
end,
|
||||
|
||||
on_punch = function(pos, node, player)
|
||||
if(not is_owner(pos, player:get_player_name())) then
|
||||
if not is_owner(pos, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
|
||||
if(minetest.get_meta(pos):get_string("infotext") == "") then
|
||||
if minetest.get_meta(pos):get_string("infotext") == "" then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -153,8 +150,14 @@ local function may_replace(pos, player)
|
|||
return node_definition.buildable_to and not minetest.is_protected(pos, player:get_player_name())
|
||||
end
|
||||
|
||||
if minetest.setting_getbool("creative_mode") == true then
|
||||
return
|
||||
end
|
||||
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
if minetest.setting_getbool("creative_mode") then
|
||||
|
||||
-- are bones enabled?
|
||||
if bones.enable ~= true then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -175,7 +178,8 @@ minetest.register_on_dieplayer(function(player)
|
|||
if (not may_replace(pos, player)) then
|
||||
if (may_replace({x = pos.x, y = pos.y + 1, z = pos.z}, player)) then
|
||||
-- drop one node above if there's space
|
||||
-- this should solve most cases of protection related deaths in which players dig straight down
|
||||
-- this should solve most cases of protection related deaths
|
||||
-- in which players dig straight down
|
||||
-- yet keeps the bones reachable
|
||||
pos.y = pos.y + 1
|
||||
else
|
||||
|
|
Loading…
Add table
Reference in a new issue