mirror of
https://github.com/luanti-org/minetest_game.git
synced 2025-06-06 22:04:25 -04:00
Merge 19d5838dbf
into 1977ae19ae
This commit is contained in:
commit
bc9ef753b9
2 changed files with 79 additions and 3 deletions
|
@ -147,7 +147,12 @@ function _doors.door_toggle(pos, clicker)
|
|||
|
||||
if clicker and not minetest.check_player_privs(clicker, "protection_bypass") then
|
||||
local owner = meta:get_string("doors_owner")
|
||||
if owner ~= "" then
|
||||
local prot = meta:get_string("doors_protected")
|
||||
if prot ~= "" then
|
||||
if minetest.is_protected(pos, clicker:get_player_name()) then
|
||||
return false
|
||||
end
|
||||
elseif owner ~= "" then
|
||||
if clicker:get_player_name() ~= owner then
|
||||
return false
|
||||
end
|
||||
|
@ -394,7 +399,6 @@ function doors.register(name, def)
|
|||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
use_texture_alpha = true,
|
||||
walkable = true,
|
||||
is_ground_content = false,
|
||||
buildable_to = false,
|
||||
|
@ -427,7 +431,6 @@ function doors.register(name, def)
|
|||
paramtype = "light",
|
||||
paramtype2 = "facedir",
|
||||
sunlight_propagates = true,
|
||||
use_texture_alpha = true,
|
||||
walkable = true,
|
||||
is_ground_content = false,
|
||||
buildable_to = false,
|
||||
|
@ -695,6 +698,79 @@ minetest.register_craft({
|
|||
})
|
||||
|
||||
|
||||
-----key tool-----
|
||||
minetest.register_tool("doors:key", {
|
||||
description = "Key Tool",
|
||||
inventory_image = "doors_key.png",
|
||||
|
||||
on_use = function(itemstack, user, pointed_thing)
|
||||
|
||||
local pos = pointed_thing.under
|
||||
|
||||
if pointed_thing.type ~= "node"
|
||||
or not doors.get(pos) then
|
||||
return
|
||||
end
|
||||
|
||||
local player_name = user:get_player_name()
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = meta:get_string("doors_owner")
|
||||
local prot = meta:get_string("doors_protected")
|
||||
local ok = 0
|
||||
local infotext = ""
|
||||
|
||||
if prot == "" and owner == "" then
|
||||
-- flip normal to owned
|
||||
if minetest.is_protected(pos, player_name) then
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
else
|
||||
infotext = "Owned by" .. player_name
|
||||
owner = player_name
|
||||
prot = ""
|
||||
ok = 1
|
||||
end
|
||||
|
||||
elseif prot == "" and owner ~= "" then
|
||||
-- flip owned to protected
|
||||
if player_name == owner then
|
||||
infotext = "Protected by " .. player_name
|
||||
owner = ""
|
||||
prot = player_name
|
||||
ok = 1
|
||||
end
|
||||
|
||||
elseif prot ~= "" and owner == "" then
|
||||
-- flip protected to normal
|
||||
if player_name == prot then
|
||||
owner = ""
|
||||
prot = ""
|
||||
ok = 1
|
||||
end
|
||||
end
|
||||
|
||||
if ok == 1 then
|
||||
meta:set_string("infotext", infotext)
|
||||
meta:set_string("doors_owner", owner)
|
||||
meta:set_string("doors_protected", prot)
|
||||
if not minetest.setting_getbool("creative_mode") then
|
||||
itemstack:add_wear(65535 / 50)
|
||||
end
|
||||
end
|
||||
|
||||
return itemstack
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_craft({
|
||||
output = "doors:key",
|
||||
recipe = {
|
||||
{"", "", "default:steel_ingot"},
|
||||
{"default:steel_ingot", "default:steel_ingot", ""},
|
||||
{"default:steel_ingot", "default:steel_ingot", ""},
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
----fence gate----
|
||||
|
||||
function doors.register_fencegate(name, def)
|
||||
|
|
BIN
mods/doors/textures/doors_key.png
Normal file
BIN
mods/doors/textures/doors_key.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 198 B |
Loading…
Add table
Reference in a new issue