mirror of
https://github.com/mt-mods/homedecor_modpack.git
synced 2024-12-23 00:20:17 +01:00
spawn lockable nodes for "inventory = { lockable = true }", and migrate all lockable nodes to this mechanism, but the furnaces
This commit is contained in:
parent
cc79b5fc03
commit
29f61bb899
@ -171,6 +171,7 @@ for _, w in pairs({"mahogany", "oak"}) do
|
|||||||
infotext=S("One-drawer Nightstand"),
|
infotext=S("One-drawer Nightstand"),
|
||||||
inventory = {
|
inventory = {
|
||||||
size=8,
|
size=8,
|
||||||
|
lockable=true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -196,6 +197,7 @@ for _, w in pairs({"mahogany", "oak"}) do
|
|||||||
infotext=S("Two-drawer Nightstand"),
|
infotext=S("Two-drawer Nightstand"),
|
||||||
inventory = {
|
inventory = {
|
||||||
size=16,
|
size=16,
|
||||||
|
lockable=true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -54,7 +54,8 @@ end
|
|||||||
-- inventory = {
|
-- inventory = {
|
||||||
-- size = 16,
|
-- size = 16,
|
||||||
-- formspec = …,
|
-- formspec = …,
|
||||||
-- locked = true,
|
-- locked = false,
|
||||||
|
-- lockable = true,
|
||||||
-- }
|
-- }
|
||||||
--
|
--
|
||||||
function homedecor.handle_inventory(name, def, original_def)
|
function homedecor.handle_inventory(name, def, original_def)
|
||||||
@ -88,20 +89,15 @@ function homedecor.handle_inventory(name, def, original_def)
|
|||||||
))
|
))
|
||||||
end
|
end
|
||||||
|
|
||||||
local locked = def.locked
|
local locked = inventory.locked
|
||||||
def.locked = nil
|
|
||||||
|
|
||||||
if locked then
|
if locked then
|
||||||
local description = def.description
|
|
||||||
-- def.description = S("%s (Locked)"):format(description)
|
|
||||||
|
|
||||||
local after_place_node = def.after_place_node
|
local after_place_node = def.after_place_node
|
||||||
def.after_place_node = function(pos, placer)
|
def.after_place_node = function(pos, placer)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local owner = placer:get_player_name() or ""
|
local owner = placer:get_player_name() or ""
|
||||||
|
|
||||||
meta:set_string("owner", owner)
|
meta:set_string("owner", owner)
|
||||||
meta:set_string("infotext", S("%s (owned by %s)"):format(def.infotext or description, owner))
|
meta:set_string("infotext", S("%s (owned by %s)"):format(def.infotext or def.description, owner))
|
||||||
return after_place_node and after_place_node(pos, placer)
|
return after_place_node and after_place_node(pos, placer)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -113,7 +109,7 @@ function homedecor.handle_inventory(name, def, original_def)
|
|||||||
|
|
||||||
if (playername ~= owner) then
|
if (playername ~= owner) then
|
||||||
minetest.log("action", string.format("%s tried to access a %s belonging to %s at %s",
|
minetest.log("action", string.format("%s tried to access a %s belonging to %s at %s",
|
||||||
playername, infotext, owner, minetest.pos_to_string(pos)
|
playername, name, owner, minetest.pos_to_string(pos)
|
||||||
))
|
))
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
@ -130,7 +126,7 @@ function homedecor.handle_inventory(name, def, original_def)
|
|||||||
|
|
||||||
if (playername ~= owner) then
|
if (playername ~= owner) then
|
||||||
minetest.log("action", string.format("%s tried to access a %s belonging to %s at %s",
|
minetest.log("action", string.format("%s tried to access a %s belonging to %s at %s",
|
||||||
playername, infotext, owner, minetest.pos_to_string(pos)
|
playername, name, owner, minetest.pos_to_string(pos)
|
||||||
))
|
))
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
@ -146,7 +142,7 @@ function homedecor.handle_inventory(name, def, original_def)
|
|||||||
|
|
||||||
if (playername ~= owner) then
|
if (playername ~= owner) then
|
||||||
minetest.log("action", string.format("%s tried to access a %s belonging to %s at %s",
|
minetest.log("action", string.format("%s tried to access a %s belonging to %s at %s",
|
||||||
playername, infotext, owner, minetest.pos_to_string(pos)
|
playername, name, owner, minetest.pos_to_string(pos)
|
||||||
))
|
))
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
@ -154,4 +150,23 @@ function homedecor.handle_inventory(name, def, original_def)
|
|||||||
or stack:get_count()
|
or stack:get_count()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local lockable = inventory.lockable
|
||||||
|
if lockable then
|
||||||
|
local locked_def = table.copy(original_def)
|
||||||
|
locked_def.description = S("%s (Locked)"):format(def.infotext or def.description)
|
||||||
|
|
||||||
|
local locked_inventory = locked_def.inventory
|
||||||
|
locked_inventory.locked = true
|
||||||
|
locked_inventory.lockable = nil -- avoid loops of locked locked stuff
|
||||||
|
|
||||||
|
local locked_name = name .. "_locked"
|
||||||
|
homedecor.register(locked_name, locked_def)
|
||||||
|
minetest.register_craft({
|
||||||
|
type = "shapeless",
|
||||||
|
output = "homedecor:" .. locked_name,
|
||||||
|
recipe = { "homedecor:" .. name, "default:steel_ingot" }
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -115,32 +115,6 @@ local function create_locked ( name, infotext )
|
|||||||
end
|
end
|
||||||
|
|
||||||
local items = {
|
local items = {
|
||||||
{ "refrigerator_white",
|
|
||||||
"Refrigerator" },
|
|
||||||
{ "refrigerator_steel",
|
|
||||||
"Refrigerator (stainless steel)" },
|
|
||||||
{ "kitchen_cabinet",
|
|
||||||
"Cabinet" },
|
|
||||||
{ "kitchen_cabinet_steel",
|
|
||||||
"Cabinet (stainless steel top)" },
|
|
||||||
{ "kitchen_cabinet_granite",
|
|
||||||
"Cabinet (granite top)" },
|
|
||||||
{ "kitchen_cabinet_marble",
|
|
||||||
"Cabinet (marble top)" },
|
|
||||||
{ "kitchen_cabinet_half",
|
|
||||||
"Cabinet" },
|
|
||||||
{ "kitchen_cabinet_with_sink",
|
|
||||||
"Cabinet" },
|
|
||||||
{ "nightstand_oak_one_drawer",
|
|
||||||
"Nightstand" },
|
|
||||||
{ "nightstand_oak_two_drawers",
|
|
||||||
"Nightstand" },
|
|
||||||
{ "nightstand_mahogany_one_drawer",
|
|
||||||
"Nightstand" },
|
|
||||||
{ "nightstand_mahogany_two_drawers",
|
|
||||||
"Nightstand" },
|
|
||||||
{ "filing_cabinet",
|
|
||||||
"Filing cabinet" },
|
|
||||||
{ "oven",
|
{ "oven",
|
||||||
"Oven" },
|
"Oven" },
|
||||||
{ "oven_active",
|
{ "oven_active",
|
||||||
|
@ -35,7 +35,7 @@ homedecor.register("refrigerator_white", {
|
|||||||
infotext=S("Refrigerator"),
|
infotext=S("Refrigerator"),
|
||||||
inventory = {
|
inventory = {
|
||||||
size=50,
|
size=50,
|
||||||
lockable=true
|
lockable=true,
|
||||||
},
|
},
|
||||||
on_rotate = screwdriver.rotate_simple
|
on_rotate = screwdriver.rotate_simple
|
||||||
})
|
})
|
||||||
|
@ -29,6 +29,7 @@ for _, mat in ipairs(counter_materials) do
|
|||||||
infotext=S("Kitchen Cabinet"),
|
infotext=S("Kitchen Cabinet"),
|
||||||
inventory = {
|
inventory = {
|
||||||
size=24,
|
size=24,
|
||||||
|
lockable=true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
@ -51,6 +52,7 @@ homedecor.register("kitchen_cabinet_half", {
|
|||||||
infotext=S("Kitchen Cabinet"),
|
infotext=S("Kitchen Cabinet"),
|
||||||
inventory = {
|
inventory = {
|
||||||
size=12,
|
size=12,
|
||||||
|
lockable=true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -68,6 +70,7 @@ homedecor.register("kitchen_cabinet_with_sink", {
|
|||||||
infotext=S("Under-sink cabinet"),
|
infotext=S("Under-sink cabinet"),
|
||||||
inventory = {
|
inventory = {
|
||||||
size=16,
|
size=16,
|
||||||
|
lockable=true,
|
||||||
},
|
},
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
|
@ -13,6 +13,7 @@ homedecor.register("filing_cabinet", {
|
|||||||
infotext=S("Filing cabinet"),
|
infotext=S("Filing cabinet"),
|
||||||
inventory = {
|
inventory = {
|
||||||
size=16,
|
size=16,
|
||||||
|
lockable=true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user