update 3 nodes doors code with 2 nodes doors changes from default doors.
replace function doors.door_toggle() with door_toggle() from nalc_doors(double doors gestion) replace function doors.on_skeleton_key_use() with new copied function in nalc_doors(double doors gestion)
This commit is contained in:
parent
c5437a4b3d
commit
e83afa9961
@ -9,7 +9,7 @@ doors.register(
|
|||||||
tiles = { "doors_door_tin.png" },
|
tiles = { "doors_door_tin.png" },
|
||||||
description = S("Tin Door"),
|
description = S("Tin Door"),
|
||||||
inventory_image = "doors_item_tin.png",
|
inventory_image = "doors_item_tin.png",
|
||||||
groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1},
|
groups = {node=1,snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1},
|
||||||
protected = true,
|
protected = true,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
sunlight = false,
|
sunlight = false,
|
||||||
@ -28,9 +28,11 @@ if minetest.get_modpath("darkage") then
|
|||||||
tiles = { "doors_door_prison.png" },
|
tiles = { "doors_door_prison.png" },
|
||||||
description = S("Prison Door"),
|
description = S("Prison Door"),
|
||||||
inventory_image = "doors_item_prison.png",
|
inventory_image = "doors_item_prison.png",
|
||||||
groups = {snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1},
|
groups = {node=1,snappy=1,bendy=2,cracky=1,melty=2,level=2,door=1},
|
||||||
protected = true,
|
protected = true,
|
||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
|
sound_open = "doors_steel_door_open",
|
||||||
|
sound_close = "doors_steel_door_close",
|
||||||
recipe = {
|
recipe = {
|
||||||
{"darkage:iron_stick", "darkage:iron_stick"},
|
{"darkage:iron_stick", "darkage:iron_stick"},
|
||||||
{"darkage:iron_stick", "darkage:iron_stick"},
|
{"darkage:iron_stick", "darkage:iron_stick"},
|
||||||
@ -47,7 +49,7 @@ if minetest.get_modpath("dye") then
|
|||||||
tiles = { "doors_door_gardengate_white.png" },
|
tiles = { "doors_door_gardengate_white.png" },
|
||||||
description = S("Garden Gate White Door"),
|
description = S("Garden Gate White Door"),
|
||||||
inventory_image = "doors_item_gardengate_white.png",
|
inventory_image = "doors_item_gardengate_white.png",
|
||||||
groups = {choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1},
|
groups = {node=1,choppy=2,oddly_breakable_by_hand=2,flammable=2,door=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
recipe = {
|
recipe = {
|
||||||
{"dye:white", "group:stick", ""},
|
{"dye:white", "group:stick", ""},
|
||||||
@ -213,12 +215,18 @@ function _doors.door_toggle(pos, node, clicker)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local dir = node.param2
|
local dir = node.param2
|
||||||
minetest.swap_node(
|
|
||||||
pos,
|
-- It's possible param2 is messed up, so, validate before using
|
||||||
{
|
-- the input data. This indicates something may have rotated
|
||||||
name = name .. transform[state + 1][dir+1].v,
|
-- the door, even though that is not supported.
|
||||||
param2 = transform[state + 1][dir+1].param2
|
if not transform[state + 1] or not transform[state + 1][dir + 1] then
|
||||||
})
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.swap_node(pos, {
|
||||||
|
name = name .. transform[state + 1][dir+1].v,
|
||||||
|
param2 = transform[state + 1][dir+1].param2
|
||||||
|
})
|
||||||
meta:set_int("state", state)
|
meta:set_int("state", state)
|
||||||
|
|
||||||
--MFF double porte
|
--MFF double porte
|
||||||
@ -239,14 +247,20 @@ function _doors.door_toggle(pos, node, clicker)
|
|||||||
-- /double porte
|
-- /double porte
|
||||||
|
|
||||||
if state % 2 == 0 then
|
if state % 2 == 0 then
|
||||||
minetest.sound_play(def.door.sounds[1], {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play(def.door.sounds[1],
|
||||||
|
{pos = pos, gain = def.door.gains[1], max_hear_distance = 10}, true)
|
||||||
else
|
else
|
||||||
minetest.sound_play(def.door.sounds[2], {pos = pos, gain = 0.3, max_hear_distance = 10})
|
minetest.sound_play(def.door.sounds[2],
|
||||||
|
{pos = pos, gain = def.door.gains[2], max_hear_distance = 10}, true)
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local old_doors_toggle = doors.door_toggle -- unused now
|
||||||
|
doors.door_toggle = _doors.door_toggle
|
||||||
|
|
||||||
local function on_place_node(place_to, newnode, placer, oldnode, itemstack, pointed_thing)
|
local function on_place_node(place_to, newnode, placer, oldnode, itemstack, pointed_thing)
|
||||||
-- Run script hook
|
-- Run script hook
|
||||||
for _, callback in ipairs(minetest.registered_on_placenodes) do
|
for _, callback in ipairs(minetest.registered_on_placenodes) do
|
||||||
@ -276,6 +290,70 @@ local function can_dig_door(pos, digger)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function on_skeleton_key_use(pos, player, newsecret)
|
||||||
|
replace_old_owner_information(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local owner = meta:get_string("owner")
|
||||||
|
local pname = player:get_player_name()
|
||||||
|
|
||||||
|
-- verify placer is owner of lockable door
|
||||||
|
if owner ~= pname then
|
||||||
|
minetest.record_protection_violation(pos, pname)
|
||||||
|
minetest.chat_send_player(pname, S("You do not own this locked door."))
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local secret = meta:get_string("key_lock_secret")
|
||||||
|
if secret == "" then
|
||||||
|
secret = newsecret
|
||||||
|
meta:set_string("key_lock_secret", secret)
|
||||||
|
|
||||||
|
--MFF double porte
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
local def = minetest.registered_nodes[node.name]
|
||||||
|
local b = string.sub(node.name, -1)
|
||||||
|
local dir = node.param2
|
||||||
|
local state = meta:get_string("state")
|
||||||
|
if state == "" then
|
||||||
|
if node.name:sub(-2) == "_b" then
|
||||||
|
state = 2
|
||||||
|
else
|
||||||
|
state = 0
|
||||||
|
end
|
||||||
|
else
|
||||||
|
state = tonumber(state)
|
||||||
|
end
|
||||||
|
local pos2 = get_double_doors(pos, dir, state, b)
|
||||||
|
if pos2 then
|
||||||
|
local node2 = minetest.get_node_or_nil(pos2)
|
||||||
|
if node2 and string.sub(node2.name, 0, -3) == string.sub(node.name, 0, -3) then
|
||||||
|
if b ~= string.sub(node2.name, -1) then
|
||||||
|
local state2 = minetest.get_meta(pos2):get_int("state")
|
||||||
|
if (state % 2) == (state2 % 2) then
|
||||||
|
local meta2 = minetest.get_meta(pos2)
|
||||||
|
meta2:set_string("key_lock_secret", secret)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- /double porte
|
||||||
|
end
|
||||||
|
|
||||||
|
return secret, S("a locked door"), owner
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- / rewrite function of default protected doors, keys open double doors
|
||||||
|
minetest.register_on_mods_loaded(function()
|
||||||
|
for n in pairs(doors.registered_doors) do
|
||||||
|
local def = minetest.registered_nodes[n]
|
||||||
|
if def and def.on_skeleton_key_use then
|
||||||
|
def.on_skeleton_key_use = on_skeleton_key_use
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
-- door 3 nodes
|
-- door 3 nodes
|
||||||
function doors.register3(name, def)
|
function doors.register3(name, def)
|
||||||
if not name:find(":") then
|
if not name:find(":") then
|
||||||
@ -283,155 +361,150 @@ function doors.register3(name, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- replace old doors of this type automatically
|
-- replace old doors of this type automatically
|
||||||
minetest.register_lbm(
|
minetest.register_lbm({
|
||||||
{
|
name = ":doors:replace_" .. name:gsub(":", "_"),
|
||||||
name = ":doors:replace_" .. name:gsub(":", "_"),
|
nodenames = {name.."_b_1", name.."_b_2"},
|
||||||
nodenames = {name.."_b_1", name.."_b_2"},
|
action = function(pos, node)
|
||||||
action = function(pos, node)
|
local l = tonumber(node.name:sub(-1))
|
||||||
local l = tonumber(node.name:sub(-1))
|
local meta = minetest.get_meta(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local h = meta:get_int("right") + 1
|
||||||
local h = meta:get_int("right") + 1
|
local p2 = node.param2
|
||||||
local p2 = node.param2
|
local replace = {
|
||||||
local replace = {
|
{{type = "a", state = 0}, {type = "a", state = 3}},
|
||||||
{{type = "a", state = 0}, {type = "a", state = 3}},
|
{{type = "b", state = 1}, {type = "b", state = 2}}
|
||||||
{{type = "b", state = 1}, {type = "b", state = 2}}
|
}
|
||||||
}
|
local new = replace[l][h]
|
||||||
local new = replace[l][h]
|
-- retain infotext and doors_owner fields
|
||||||
-- retain infotext and doors_owner fields
|
minetest.swap_node(pos, {name = name .. "_" .. new.type, param2 = p2})
|
||||||
minetest.swap_node(pos, {name = name .. "_" .. new.type, param2 = p2})
|
meta:set_int("state", new.state)
|
||||||
meta:set_int("state", new.state)
|
-- properly place doors:hidden at the right spot
|
||||||
-- properly place doors:hidden at the right spot
|
local p3 = p2
|
||||||
local p3 = p2
|
if new.state >= 2 then
|
||||||
|
p3 = (p3 + 3) % 4
|
||||||
|
end
|
||||||
|
if new.state % 2 == 1 then
|
||||||
if new.state >= 2 then
|
if new.state >= 2 then
|
||||||
|
p3 = (p3 + 1) % 4
|
||||||
|
else
|
||||||
p3 = (p3 + 3) % 4
|
p3 = (p3 + 3) % 4
|
||||||
end
|
end
|
||||||
if new.state % 2 == 1 then
|
|
||||||
if new.state >= 2 then
|
|
||||||
p3 = (p3 + 1) % 4
|
|
||||||
else
|
|
||||||
p3 = (p3 + 3) % 4
|
|
||||||
end
|
|
||||||
end
|
|
||||||
-- wipe meta on top node as it's unused
|
|
||||||
minetest.set_node(
|
|
||||||
{x = pos.x, y = pos.y + 1, z = pos.z},
|
|
||||||
{name = "doors:hidden", param2 = p3}
|
|
||||||
)
|
|
||||||
minetest.set_node(
|
|
||||||
{x = pos.x, y = pos.y + 2, z = pos.z},
|
|
||||||
{name = "doors:hidden", param2 = p3}
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
})
|
-- wipe meta on top node as it's unused
|
||||||
|
minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z},
|
||||||
minetest.register_craftitem(
|
{name = "doors:hidden", param2 = p3})
|
||||||
":" .. name,
|
minetest.set_node({x = pos.x, y = pos.y + 2, z = pos.z},
|
||||||
{
|
{name = "doors:hidden", param2 = p3})
|
||||||
description = def.description,
|
end
|
||||||
inventory_image = def.inventory_image,
|
})
|
||||||
groups = table.copy(def.groups),
|
|
||||||
|
minetest.register_craftitem(":" .. name, {
|
||||||
on_place = function(itemstack, placer, pointed_thing)
|
description = def.description,
|
||||||
local pos
|
inventory_image = def.inventory_image,
|
||||||
|
groups = table.copy(def.groups),
|
||||||
if not pointed_thing.type == "node" then
|
|
||||||
return itemstack
|
on_place = function(itemstack, placer, pointed_thing)
|
||||||
end
|
local pos
|
||||||
|
|
||||||
local node = minetest.get_node(pointed_thing.under)
|
if pointed_thing.type ~= "node" then
|
||||||
local pdef = minetest.registered_nodes[node.name]
|
|
||||||
if pdef and pdef.on_rightclick and
|
|
||||||
not placer:get_player_control().sneak then
|
|
||||||
return pdef.on_rightclick(pointed_thing.under,
|
|
||||||
node, placer, itemstack, pointed_thing)
|
|
||||||
end
|
|
||||||
|
|
||||||
if pdef and pdef.buildable_to then
|
|
||||||
pos = pointed_thing.under
|
|
||||||
else
|
|
||||||
pos = pointed_thing.above
|
|
||||||
node = minetest.get_node(pos)
|
|
||||||
pdef = minetest.registered_nodes[node.name]
|
|
||||||
if not pdef or not pdef.buildable_to then
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
|
||||||
local top_node = minetest.get_node_or_nil(above)
|
|
||||||
local topdef = top_node and minetest.registered_nodes[top_node.name]
|
|
||||||
|
|
||||||
if not topdef or not topdef.buildable_to then
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
local above2 = { x = pos.x, y = pos.y + 2, z = pos.z }
|
|
||||||
local top_node2 = minetest.get_node_or_nil(above2)
|
|
||||||
local topdef2 = top_node2 and minetest.registered_nodes[top_node2.name]
|
|
||||||
|
|
||||||
if not topdef2 or not topdef2.buildable_to then
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
local pn = placer:get_player_name()
|
|
||||||
if minetest.is_protected(pos, pn) or minetest.is_protected(above, pn) or minetest.is_protected(above2, pn) then
|
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
|
|
||||||
local dir = minetest.dir_to_facedir(placer:get_look_dir())
|
|
||||||
|
|
||||||
local ref = {
|
|
||||||
{x = -1, y = 0, z = 0},
|
|
||||||
{x = 0, y = 0, z = 1},
|
|
||||||
{x = 1, y = 0, z = 0},
|
|
||||||
{x = 0, y = 0, z = -1},
|
|
||||||
}
|
|
||||||
|
|
||||||
local aside = {
|
|
||||||
x = pos.x + ref[dir + 1].x,
|
|
||||||
y = pos.y + ref[dir + 1].y,
|
|
||||||
z = pos.z + ref[dir + 1].z,
|
|
||||||
}
|
|
||||||
|
|
||||||
local state = 0
|
|
||||||
if minetest.get_item_group(minetest.get_node(aside).name, "door") == 1 then
|
|
||||||
state = state + 2
|
|
||||||
minetest.set_node(pos, {name = name .. "_b", param2 = dir})
|
|
||||||
minetest.set_node(above, {name = "doors:hidden", param2 = (dir + 3) % 4})
|
|
||||||
minetest.set_node(above2, {name = "doors:hidden", param2 = (dir + 3) % 4})
|
|
||||||
else
|
|
||||||
minetest.set_node(pos, {name = name .. "_a", param2 = dir})
|
|
||||||
minetest.set_node(above, {name = "doors:hidden", param2 = dir})
|
|
||||||
minetest.set_node(above2, {name = "doors:hidden", param2 = dir})
|
|
||||||
end
|
|
||||||
|
|
||||||
local meta = minetest.get_meta(pos)
|
|
||||||
meta:set_int("state", state)
|
|
||||||
|
|
||||||
if def.protected then
|
|
||||||
meta:set_string("owner", pn)
|
|
||||||
meta:set_string("infotext", S("Owned by @1", pn))
|
|
||||||
end
|
|
||||||
|
|
||||||
if not (creative and creative.is_enabled_for and creative.is_enabled_for(pn)) then
|
|
||||||
itemstack:take_item()
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.sound_play(def.sounds.place, {pos = pos})
|
|
||||||
|
|
||||||
on_place_node(pos, minetest.get_node(pos), placer, node, itemstack, pointed_thing)
|
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
})
|
|
||||||
|
local doorname = itemstack:get_name()
|
||||||
|
local node = minetest.get_node(pointed_thing.under)
|
||||||
|
local pdef = minetest.registered_nodes[node.name]
|
||||||
|
if pdef and pdef.on_rightclick and
|
||||||
|
not (placer and placer:is_player() and
|
||||||
|
placer:get_player_control().sneak) then
|
||||||
|
return pdef.on_rightclick(pointed_thing.under,
|
||||||
|
node, placer, itemstack, pointed_thing)
|
||||||
|
end
|
||||||
|
|
||||||
|
if pdef and pdef.buildable_to then
|
||||||
|
pos = pointed_thing.under
|
||||||
|
else
|
||||||
|
pos = pointed_thing.above
|
||||||
|
node = minetest.get_node(pos)
|
||||||
|
pdef = minetest.registered_nodes[node.name]
|
||||||
|
if not pdef or not pdef.buildable_to then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local above = {x = pos.x, y = pos.y + 1, z = pos.z}
|
||||||
|
local top_node = minetest.get_node_or_nil(above)
|
||||||
|
local topdef = top_node and minetest.registered_nodes[top_node.name]
|
||||||
|
|
||||||
|
if not topdef or not topdef.buildable_to then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
local above2 = { x = pos.x, y = pos.y + 2, z = pos.z }
|
||||||
|
local top_node2 = minetest.get_node_or_nil(above2)
|
||||||
|
local topdef2 = top_node2 and minetest.registered_nodes[top_node2.name]
|
||||||
|
|
||||||
|
if not topdef2 or not topdef2.buildable_to then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
local pn = placer and placer:get_player_name() or ""
|
||||||
|
if minetest.is_protected(pos, pn) or minetest.is_protected(above, pn) or minetest.is_protected(above2, pn) then
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
|
||||||
|
local dir = placer and minetest.dir_to_facedir(placer:get_look_dir()) or 0
|
||||||
|
|
||||||
|
local ref = {
|
||||||
|
{x = -1, y = 0, z = 0},
|
||||||
|
{x = 0, y = 0, z = 1},
|
||||||
|
{x = 1, y = 0, z = 0},
|
||||||
|
{x = 0, y = 0, z = -1},
|
||||||
|
}
|
||||||
|
|
||||||
|
local aside = {
|
||||||
|
x = pos.x + ref[dir + 1].x,
|
||||||
|
y = pos.y + ref[dir + 1].y,
|
||||||
|
z = pos.z + ref[dir + 1].z,
|
||||||
|
}
|
||||||
|
|
||||||
|
local state = 0
|
||||||
|
if minetest.get_item_group(minetest.get_node(aside).name, "door") == 1 then
|
||||||
|
state = state + 2
|
||||||
|
minetest.set_node(pos, {name = doorname .. "_b", param2 = dir})
|
||||||
|
minetest.set_node(above, {name = "doors:hidden", param2 = (dir + 3) % 4})
|
||||||
|
minetest.set_node(above2, {name = "doors:hidden", param2 = (dir + 3) % 4})
|
||||||
|
else
|
||||||
|
minetest.set_node(pos, {name = name .. "_a", param2 = dir})
|
||||||
|
minetest.set_node(above, {name = "doors:hidden", param2 = dir})
|
||||||
|
minetest.set_node(above2, {name = "doors:hidden", param2 = dir})
|
||||||
|
end
|
||||||
|
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
meta:set_int("state", state)
|
||||||
|
|
||||||
|
if def.protected then
|
||||||
|
meta:set_string("owner", pn)
|
||||||
|
meta:set_string("infotext", def.description .. "\n" .. S("Owned by @1", pn))
|
||||||
|
end
|
||||||
|
|
||||||
|
if not (creative and creative.is_enabled_for and creative.is_enabled_for(pn)) then
|
||||||
|
itemstack:take_item()
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.sound_play(def.sounds.place, {pos = pos}, true)
|
||||||
|
|
||||||
|
on_place_node(pos, minetest.get_node(pos),
|
||||||
|
placer, node, itemstack, pointed_thing)
|
||||||
|
|
||||||
|
return itemstack
|
||||||
|
end
|
||||||
|
})
|
||||||
def.inventory_image = nil
|
def.inventory_image = nil
|
||||||
|
|
||||||
if def.recipe then
|
if def.recipe then
|
||||||
minetest.register_craft(
|
minetest.register_craft({
|
||||||
{
|
output = name,
|
||||||
output = name,
|
recipe = def.recipe,
|
||||||
recipe = def.recipe,
|
})
|
||||||
})
|
|
||||||
end
|
end
|
||||||
def.recipe = nil
|
def.recipe = nil
|
||||||
|
|
||||||
@ -447,24 +520,36 @@ function doors.register3(name, def)
|
|||||||
def.sound_close = "doors_door_close"
|
def.sound_close = "doors_door_close"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not def.gain_open then
|
||||||
|
def.gain_open = 0.3
|
||||||
|
end
|
||||||
|
|
||||||
|
if not def.gain_close then
|
||||||
|
def.gain_close = 0.3
|
||||||
|
end
|
||||||
|
|
||||||
def.groups.not_in_creative_inventory = 1
|
def.groups.not_in_creative_inventory = 1
|
||||||
def.groups.door = 1
|
def.groups.door = 1
|
||||||
def.drop = name
|
def.drop = name
|
||||||
def.door = {
|
def.door = {
|
||||||
name = name,
|
name = name,
|
||||||
sounds = { def.sound_close, def.sound_open },
|
sounds = {def.sound_close, def.sound_open},
|
||||||
|
gains = {def.gain_close, def.gain_open},
|
||||||
}
|
}
|
||||||
|
if not def.on_rightclick then
|
||||||
def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
def.on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
_doors.door_toggle(pos, node, clicker)
|
_doors.door_toggle(pos, node, clicker)
|
||||||
return itemstack
|
return itemstack
|
||||||
|
end
|
||||||
end
|
end
|
||||||
def.after_dig_node = function(pos, node, meta, digger)
|
def.after_dig_node = function(pos, node, meta, digger)
|
||||||
minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z})
|
minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z})
|
||||||
minetest.remove_node({x = pos.x, y = pos.y + 2, z = pos.z})
|
minetest.remove_node({x = pos.x, y = pos.y + 2, z = pos.z})
|
||||||
minetest.check_for_falling({x = pos.x, y = pos.y + 2, z = pos.z})
|
minetest.check_for_falling({x = pos.x, y = pos.y + 2, z = pos.z})
|
||||||
end
|
end
|
||||||
def.on_rotate = false
|
def.on_rotate = function(pos, node, user, mode, new_param2)
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
if def.protected then
|
if def.protected then
|
||||||
def.can_dig = can_dig_door
|
def.can_dig = can_dig_door
|
||||||
@ -473,27 +558,9 @@ function doors.register3(name, def)
|
|||||||
local door = doors.get(pos)
|
local door = doors.get(pos)
|
||||||
door:toggle(player)
|
door:toggle(player)
|
||||||
end
|
end
|
||||||
def.on_skeleton_key_use = function(pos, player, newsecret)
|
def.on_skeleton_key_use = on_skeleton_key_use
|
||||||
replace_old_owner_information(pos)
|
|
||||||
local meta = minetest.get_meta(pos)
|
def.node_dig_prediction = ""
|
||||||
local owner = meta:get_string("owner")
|
|
||||||
local pname = player:get_player_name()
|
|
||||||
|
|
||||||
-- verify placer is owner of lockable door
|
|
||||||
if owner ~= pname then
|
|
||||||
minetest.record_protection_violation(pos, pname)
|
|
||||||
minetest.chat_send_player(pname, S("You do not own this locked door."))
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
|
|
||||||
local secret = meta:get_string("key_lock_secret")
|
|
||||||
if secret == "" then
|
|
||||||
secret = newsecret
|
|
||||||
meta:set_string("key_lock_secret", secret)
|
|
||||||
end
|
|
||||||
|
|
||||||
return secret, S("a locked door"), owner
|
|
||||||
end
|
|
||||||
else
|
else
|
||||||
def.on_blast = function(pos, intensity)
|
def.on_blast = function(pos, intensity)
|
||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
@ -518,15 +585,24 @@ function doors.register3(name, def)
|
|||||||
def.buildable_to = false
|
def.buildable_to = false
|
||||||
def.selection_box = {type = "fixed", fixed = {-1/2,-1/2,-1/2,1/2,2.5,-6/16}}
|
def.selection_box = {type = "fixed", fixed = {-1/2,-1/2,-1/2,1/2,2.5,-6/16}}
|
||||||
def.collision_box = {type = "fixed", fixed = {-1/2,-1/2,-1/2,1/2,2.5,-6/16}}
|
def.collision_box = {type = "fixed", fixed = {-1/2,-1/2,-1/2,1/2,2.5,-6/16}}
|
||||||
|
def.use_texture_alpha = def.use_texture_alpha or "clip"
|
||||||
|
|
||||||
def.mesh = "door3_a.obj"
|
def.mesh = "door3_a.obj"
|
||||||
minetest.register_node(":" .. name .. "_a", def)
|
minetest.register_node(":" .. name .. "_a", table.copy(def))
|
||||||
|
|
||||||
def.mesh = "door3_b.obj"
|
def.mesh = "door3_b.obj"
|
||||||
minetest.register_node(":" .. name .. "_b", def)
|
minetest.register_node(":" .. name .. "_b", table.copy(def))
|
||||||
|
|
||||||
|
def.mesh = "door3_b.obj"
|
||||||
|
minetest.register_node(":" .. name .. "_c", table.copy(def))
|
||||||
|
|
||||||
|
def.mesh = "door3_a.obj"
|
||||||
|
minetest.register_node(":" .. name .. "_d", table.copy(def))
|
||||||
|
|
||||||
_doors.registered_doors3[name .. "_a"] = true
|
_doors.registered_doors3[name .. "_a"] = true
|
||||||
_doors.registered_doors3[name .. "_b"] = true
|
_doors.registered_doors3[name .. "_b"] = true
|
||||||
|
_doors.registered_doors3[name .. "_c"] = true
|
||||||
|
_doors.registered_doors3[name .. "_d"] = true
|
||||||
end
|
end
|
||||||
|
|
||||||
doors.register3(
|
doors.register3(
|
||||||
@ -535,7 +611,9 @@ doors.register3(
|
|||||||
tiles = {{ name = "doors_door3_wood.png", backface_culling = true }},
|
tiles = {{ name = "doors_door3_wood.png", backface_culling = true }},
|
||||||
description = S("Wooden Door 3 Nodes"),
|
description = S("Wooden Door 3 Nodes"),
|
||||||
inventory_image = "doors3_item_wood.png",
|
inventory_image = "doors3_item_wood.png",
|
||||||
groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 2 },
|
groups = {node = 1, choppy = 2, oddly_breakable_by_hand = 2, flammable = 2 },
|
||||||
|
gain_open = 0.06,
|
||||||
|
gain_close = 0.13,
|
||||||
recipe = {
|
recipe = {
|
||||||
{"", "", ""},
|
{"", "", ""},
|
||||||
{"", "doors:door_wood", ""},
|
{"", "doors:door_wood", ""},
|
||||||
@ -556,7 +634,7 @@ doors.register3(
|
|||||||
description = S("Steel Door 3 Nodes"),
|
description = S("Steel Door 3 Nodes"),
|
||||||
inventory_image = "doors3_item_steel.png",
|
inventory_image = "doors3_item_steel.png",
|
||||||
protected = true,
|
protected = true,
|
||||||
groups = {cracky = 1, level = 2},
|
groups = {node = 1, cracky = 1, level = 2},
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
sound_open = "doors_steel_door_open",
|
sound_open = "doors_steel_door_open",
|
||||||
sound_close = "doors_steel_door_close",
|
sound_close = "doors_steel_door_close",
|
||||||
@ -579,7 +657,7 @@ doors.register3(
|
|||||||
tiles = { "doors_door3_glass.png"},
|
tiles = { "doors_door3_glass.png"},
|
||||||
description = S("Glass Door 3 Nodes"),
|
description = S("Glass Door 3 Nodes"),
|
||||||
inventory_image = "doors3_item_glass.png",
|
inventory_image = "doors3_item_glass.png",
|
||||||
groups = {cracky=3, oddly_breakable_by_hand=3},
|
groups = {node=1, cracky=3, oddly_breakable_by_hand=3},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
sound_open = "doors_glass_door_open",
|
sound_open = "doors_glass_door_open",
|
||||||
sound_close = "doors_glass_door_close",
|
sound_close = "doors_glass_door_close",
|
||||||
@ -602,7 +680,7 @@ doors.register3(
|
|||||||
tiles = { "doors_door3_obsidian_glass.png" },
|
tiles = { "doors_door3_obsidian_glass.png" },
|
||||||
description = S("Obsidian Glass Door 3 Nodes"),
|
description = S("Obsidian Glass Door 3 Nodes"),
|
||||||
inventory_image = "doors3_item_obsidian_glass.png",
|
inventory_image = "doors3_item_obsidian_glass.png",
|
||||||
groups = {cracky=3},
|
groups = {node=1,cracky=3},
|
||||||
sounds = default.node_sound_glass_defaults(),
|
sounds = default.node_sound_glass_defaults(),
|
||||||
sound_open = "doors_glass_door_open",
|
sound_open = "doors_glass_door_open",
|
||||||
sound_close = "doors_glass_door_close",
|
sound_close = "doors_glass_door_close",
|
||||||
@ -627,7 +705,7 @@ if minetest.get_modpath("cherry_tree") then
|
|||||||
tiles = { "doors_door3_cherry.png" },
|
tiles = { "doors_door3_cherry.png" },
|
||||||
description = S("Cherry Door 3 Nodes"),
|
description = S("Cherry Door 3 Nodes"),
|
||||||
inventory_image = "doors3_item_cherry.png",
|
inventory_image = "doors3_item_cherry.png",
|
||||||
groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2, door=1},
|
groups = {node=1, choppy=2, oddly_breakable_by_hand=2, flammable=2, door=1},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
recipe = {
|
recipe = {
|
||||||
{"", "", ""},
|
{"", "", ""},
|
||||||
@ -660,7 +738,7 @@ if minetest.get_modpath("darkage") then
|
|||||||
description = S("Prison Door 3 Nodes"),
|
description = S("Prison Door 3 Nodes"),
|
||||||
inventory_image = "doors3_item_prison.png",
|
inventory_image = "doors3_item_prison.png",
|
||||||
protected = true,
|
protected = true,
|
||||||
groups = {cracky = 1, level = 2},
|
groups = {node = 1, cracky = 1, level = 2},
|
||||||
sounds = default.node_sound_metal_defaults(),
|
sounds = default.node_sound_metal_defaults(),
|
||||||
sound_open = "doors_steel_door_open",
|
sound_open = "doors_steel_door_open",
|
||||||
sound_close = "doors_steel_door_close",
|
sound_close = "doors_steel_door_close",
|
||||||
|
Loading…
Reference in New Issue
Block a user