many worldgen mods and gonna try technic now
No files matched your search
@@ -0,0 +1,24 @@
|
||||
Technic chests
|
||||
==============
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (C) 2012-2014 Maciej Kasatkin (RealBadAngel)
|
||||
|
||||
Technic chests code is licensed under the GNU LGPLv2+.
|
||||
|
||||
Texture licenses:
|
||||
|
||||
VanessaE: (WTFPL)
|
||||
* technic\_pencil\_icon.png
|
||||
* technic\_checkmark\_icon.png
|
||||
* technic\_chest\_overlay\_*.png
|
||||
* technic\_*\_chest\_lock\_overlay.png
|
||||
|
||||
sdzen (Elise Staudter) modified by VanessaE (CC BY-SA 3.0):
|
||||
* copper, iron, silver, gold, mithril chest textures 16x16
|
||||
|
||||
RealBadAngel: (WTFPL)
|
||||
* Everything else.
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
|
||||
local function register_chests(name, data)
|
||||
for _,t in pairs({"", "_locked", "_protected"}) do
|
||||
local data_copy = {}
|
||||
for k, v in pairs(data) do
|
||||
data_copy[k] = v
|
||||
end
|
||||
data_copy.locked = t == "_locked"
|
||||
data_copy.protected = t == "_protected"
|
||||
technic.chests.register_chest(name, data_copy)
|
||||
end
|
||||
end
|
||||
|
||||
local function register_crafts(name, material, base_open, base_locked, base_protected)
|
||||
name = name:lower()
|
||||
if minetest.registered_items[material] then
|
||||
if minetest.registered_items[base_open] then
|
||||
minetest.register_craft({
|
||||
output = "technic:"..name.."_chest",
|
||||
recipe = {
|
||||
{material, material, material},
|
||||
{material, base_open, material},
|
||||
{material, material, material},
|
||||
}
|
||||
})
|
||||
end
|
||||
if minetest.registered_items[base_locked] then
|
||||
minetest.register_craft({
|
||||
output = "technic:"..name.."_locked_chest",
|
||||
recipe = {
|
||||
{material, material, material},
|
||||
{material, base_locked, material},
|
||||
{material, material, material},
|
||||
}
|
||||
})
|
||||
end
|
||||
if minetest.registered_items[base_protected] then
|
||||
minetest.register_craft({
|
||||
output = "technic:"..name.."_protected_chest",
|
||||
recipe = {
|
||||
{material, material, material},
|
||||
{material, base_protected, material},
|
||||
{material, material, material},
|
||||
}
|
||||
})
|
||||
end
|
||||
end
|
||||
minetest.register_craft({
|
||||
output = "technic:"..name.."_locked_chest",
|
||||
type = "shapeless",
|
||||
recipe = {"basic_materials:padlock","technic:"..name.."_chest"}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "technic:"..name.."_protected_chest",
|
||||
type = "shapeless",
|
||||
recipe = {"default:copper_ingot", "technic:"..name.."_chest"}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "technic:"..name.."_chest",
|
||||
type = "shapeless",
|
||||
recipe = {"technic:"..name.."_locked_chest"}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "technic:"..name.."_chest",
|
||||
type = "shapeless",
|
||||
recipe = {"technic:"..name.."_protected_chest"}
|
||||
})
|
||||
end
|
||||
|
||||
-- Iron
|
||||
register_chests("Iron", {
|
||||
width = 9,
|
||||
height = 5,
|
||||
sort = true,
|
||||
infotext = true,
|
||||
})
|
||||
register_crafts(
|
||||
"Iron",
|
||||
minetest.get_modpath("technic_worldgen") and "technic:cast_iron_ingot" or "default:steel_ingot",
|
||||
"default:chest",
|
||||
"default:chest_locked",
|
||||
"protector:chest"
|
||||
)
|
||||
|
||||
-- Copper
|
||||
register_chests("Copper", {
|
||||
width = 12,
|
||||
height = 5,
|
||||
sort = true,
|
||||
infotext = true,
|
||||
autosort = true,
|
||||
})
|
||||
register_crafts(
|
||||
"Copper",
|
||||
"default:copper_ingot",
|
||||
"technic:iron_chest",
|
||||
"technic:iron_locked_chest",
|
||||
"technic:iron_protected_chest"
|
||||
)
|
||||
|
||||
-- Silver
|
||||
register_chests("Silver", {
|
||||
width = 12,
|
||||
height = 6,
|
||||
sort = true,
|
||||
infotext = true,
|
||||
autosort = true,
|
||||
quickmove = true,
|
||||
})
|
||||
register_crafts(
|
||||
"Silver",
|
||||
"moreores:silver_ingot",
|
||||
"technic:copper_chest",
|
||||
"technic:copper_locked_chest",
|
||||
"technic:copper_protected_chest"
|
||||
)
|
||||
|
||||
-- Gold
|
||||
register_chests("Gold", {
|
||||
width = 15,
|
||||
height = 6,
|
||||
sort = true,
|
||||
infotext = true,
|
||||
autosort = true,
|
||||
quickmove = true,
|
||||
color = true,
|
||||
})
|
||||
register_crafts(
|
||||
"Gold",
|
||||
"default:gold_ingot",
|
||||
minetest.get_modpath("moreores") and "technic:silver_chest" or "technic:copper_chest",
|
||||
minetest.get_modpath("moreores") and "technic:silver_locked_chest" or "technic:copper_locked_chest",
|
||||
minetest.get_modpath("moreores") and "technic:silver_protected_chest" or "technic:copper_protected_chest"
|
||||
)
|
||||
|
||||
-- Mithril
|
||||
register_chests("Mithril", {
|
||||
width = 15,
|
||||
height = 6,
|
||||
sort = true,
|
||||
infotext = true,
|
||||
autosort = true,
|
||||
quickmove = true,
|
||||
digilines = true,
|
||||
})
|
||||
register_crafts(
|
||||
"Mithril",
|
||||
"moreores:mithril_ingot",
|
||||
"technic:gold_chest",
|
||||
"technic:gold_locked_chest",
|
||||
"technic:gold_protected_chest"
|
||||
)
|
||||
@@ -0,0 +1,93 @@
|
||||
|
||||
function technic.chests.send_digiline_message(pos, event, player, items)
|
||||
local set_channel = minetest.get_meta(pos):get_string("channel")
|
||||
local player_name = player and player:get_player_name() or ""
|
||||
digilines.receptor_send(pos, digilines.rules.default, set_channel, {
|
||||
event = event,
|
||||
items = items,
|
||||
player = player_name,
|
||||
pos = pos
|
||||
})
|
||||
end
|
||||
|
||||
local function item_matches(item, stack)
|
||||
-- Same macthing as pipeworks filter injector
|
||||
local name = stack:get_name()
|
||||
local wear = stack:get_wear()
|
||||
return (not item.name or name == item.name)
|
||||
and (not item.group or (type(item.group) == "string" and minetest.get_item_group(name, item.group) ~= 0))
|
||||
and (not item.wear or (type(item.wear) == "number" and wear == item.wear) or (type(item.wear) == "table"
|
||||
and (not item.wear[1] or (type(item.wear[1]) == "number" and item.wear[1] <= wear))
|
||||
and (not item.wear[2] or (type(item.wear[2]) == "number" and wear < item.wear[2]))))
|
||||
and (not item.metadata or (type(item.metadata) == "string" and stack:get_metadata() == item.metadata))
|
||||
end
|
||||
|
||||
function technic.chests.digiline_effector(pos, _, channel, msg)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local set_channel = meta:get_string("channel")
|
||||
if channel ~= set_channel then
|
||||
return
|
||||
end
|
||||
if type(msg) ~= "table" or not msg.command then
|
||||
return
|
||||
end
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
if msg.command == "sort" then
|
||||
technic.chests.sort_inv(inv, meta:get_int("sort_mode"))
|
||||
|
||||
elseif msg.command == "is_empty" then
|
||||
local empty = inv:is_empty("main")
|
||||
digilines.receptor_send(pos, digilines.rules.default, set_channel, empty)
|
||||
|
||||
elseif msg.command == "get_list" then
|
||||
local inv_table = {}
|
||||
local list = inv:get_list("main")
|
||||
if list then
|
||||
for _,stack in ipairs(list) do
|
||||
if not stack:is_empty() then
|
||||
table.insert(inv_table, stack:get_name().." "..stack:get_count())
|
||||
else
|
||||
table.insert(inv_table, "")
|
||||
end
|
||||
end
|
||||
end
|
||||
digilines.receptor_send(pos, digilines.rules.default, set_channel, inv_table)
|
||||
|
||||
elseif msg.command == "get_stack" and type(msg.index) == "number" then
|
||||
local stack = inv:get_stack("main", msg.index):to_table()
|
||||
digilines.receptor_send(pos, digilines.rules.default, set_channel, stack)
|
||||
|
||||
elseif msg.command == "contains_item" and (type(msg.item) == "string" or type(msg.item) == "table") then
|
||||
local contains = inv:contains_item("main", msg.item)
|
||||
digilines.receptor_send(pos, digilines.rules.default, set_channel, contains)
|
||||
|
||||
elseif msg.command == "room_for_item" and (type(msg.item) == "string" or type(msg.item) == "table") then
|
||||
local room = inv:room_for_item("main", msg.item)
|
||||
digilines.receptor_send(pos, digilines.rules.default, set_channel, room)
|
||||
|
||||
elseif msg.command == "count_item" and (type(msg.item) == "string" or type(msg.item) == "table") then
|
||||
local count = 0
|
||||
local list = inv:get_list("main")
|
||||
if list then
|
||||
if type(msg.item) == "string" then
|
||||
local itemstack = ItemStack(msg.item)
|
||||
msg.item = {
|
||||
name = itemstack:get_name(),
|
||||
count = itemstack:get_count(),
|
||||
wear = string.match(msg.item, "%S*:%S*%s%d%s(%d)") and itemstack:get_wear(),
|
||||
metadata = string.match(msg.item, "%S*:%S*%s%d%s%d(%s.*)") and itemstack:get_meta():get_string("")
|
||||
}
|
||||
end
|
||||
for _,stack in pairs(list) do
|
||||
if not stack:is_empty() and item_matches(msg.item, stack) then
|
||||
count = count + stack:get_count()
|
||||
end
|
||||
end
|
||||
if msg.item.count and type(msg.item.count) == "number" and msg.item.count > 1 then
|
||||
count = math.floor(count / msg.item.count)
|
||||
end
|
||||
end
|
||||
digilines.receptor_send(pos, digilines.rules.default, set_channel, count)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,256 @@
|
||||
|
||||
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
|
||||
--local S = minetest.get_translator("technic_chests")
|
||||
|
||||
local has_pipeworks = minetest.get_modpath("pipeworks")
|
||||
|
||||
local function get_pipeworks_fs(x, y, meta)
|
||||
-- Use a container to reposition the pipeworks button.
|
||||
return "container["..x..","..(y - 4.3).."]"..
|
||||
pipeworks.fs_helpers.cycling_button(
|
||||
meta,
|
||||
pipeworks.button_base,
|
||||
"splitstacks",
|
||||
{
|
||||
pipeworks.button_off,
|
||||
pipeworks.button_on
|
||||
}
|
||||
)..pipeworks.button_label.."container_end[]"
|
||||
end
|
||||
|
||||
local function get_color_fs(x, y, meta)
|
||||
local fs = ""
|
||||
for a = 0, 3 do
|
||||
for b = 0, 3 do
|
||||
fs = fs.."image_button["..(x + b * 0.73)..","..(y + 0.1 + a * 0.79)..";0.8,0.8;"..
|
||||
"technic_colorbutton"..(a * 4 + b)..".png;color_button"..(a * 4 + b + 1)..";]"
|
||||
end
|
||||
end
|
||||
local selected = meta:get_int("color")
|
||||
local color
|
||||
if technic.chests.colors[selected] then
|
||||
color = technic.chests.colors[selected][2]
|
||||
else
|
||||
color = S("None")
|
||||
end
|
||||
return fs.."label["..(x + 0.1)..","..(y + 3.4)..";"..S("Selected Color: %s"):format(color).."]"
|
||||
end
|
||||
|
||||
local function get_quickmove_fs(x, y)
|
||||
return "button["..x..","..y..";3,1;existing_to_chest;"..S("Move existing to Chest").."]"..
|
||||
"label["..(x + 0.1)..","..(y + 1.15)..";"..S("Move specific")..":\n("..S("Drop to move")..")]"..
|
||||
"list[context;quickmove;"..(x + 1.8)..","..(y + 1.15)..";1,1]"..
|
||||
"button["..x..","..(y + 2.3)..";3,1;all_to_chest;"..S("Move all to Chest").."]"..
|
||||
"button["..x..","..(y + 3.2)..";3,1;all_to_inv;"..S("Move all to Inventory").."]"
|
||||
end
|
||||
|
||||
local function get_digilines_fs(x, y, meta)
|
||||
local channel = minetest.formspec_escape(meta:get_string("channel"))
|
||||
local put = meta:get_int("send_put") == 1 and "true" or "false"
|
||||
local take = meta:get_int("send_take") == 1 and "true" or "false"
|
||||
local inject = meta:get_int("send_inject") == 1 and "true" or "false"
|
||||
local pull = meta:get_int("send_pull") == 1 and "true" or "false"
|
||||
local overflow = meta:get_int("send_overflow") == 1 and "true" or "false"
|
||||
return "field["..(x + 0.3)..","..(y + 0.5)..";3,1;channel;Digiline Channel:;"..channel.."]"..
|
||||
"button["..(x + 0.5)..","..(y + 1.1)..";2,1;save_channel;Save Channel]"..
|
||||
"checkbox["..(x + 0.1)..","..(y + 1.8)..";send_put;"..S("Send player put messages")..";"..put.."]"..
|
||||
"checkbox["..(x + 0.1)..","..(y + 2.2)..";send_take;"..S("Send player take messages")..";"..take.."]"..
|
||||
"checkbox["..(x + 0.1)..","..(y + 2.6)..";send_inject;"..S("Send tube inject messages")..";"..inject.."]"..
|
||||
"checkbox["..(x + 0.1)..","..(y + 3.0)..";send_pull;"..S("Send tube pull messages")..";"..pull.."]"..
|
||||
"checkbox["..(x + 0.1)..","..(y + 3.4)..";send_overflow;"..S("Send overflow messages")..";"..overflow.."]"
|
||||
end
|
||||
|
||||
local function get_infotext_fs(editing, meta)
|
||||
local infotext = minetest.formspec_escape(meta:get_string("infotext"))
|
||||
if editing then
|
||||
return "image_button[0,0.1;0.8,0.8;technic_checkmark_icon.png;save_infotext;]"..
|
||||
"field[1,0.3;4,1;infotext;;"..infotext.."]"
|
||||
else
|
||||
return "image_button[0,0.1;0.8,0.8;technic_pencil_icon.png;edit_infotext;]"..
|
||||
"label[1,0;"..infotext.."]"
|
||||
end
|
||||
end
|
||||
|
||||
local function get_autosort_fs(x, meta)
|
||||
if meta:get_int("autosort") == 1 then
|
||||
return "button["..x..",0;2,1;autosort;"..S("Auto-sort is On").."]"
|
||||
else
|
||||
return "button["..x..",0;2,1;autosort;"..S("Auto-sort is Off").."]"
|
||||
end
|
||||
end
|
||||
|
||||
local function get_sort_fs(x, meta)
|
||||
local mode = meta:get_int("sort_mode")
|
||||
local fs = "button["..(x + 2)..",0;1,1;sort;"..S("Sort").."]"
|
||||
if mode == 1 then
|
||||
return fs.."button["..x..",0;2,1;sort_mode;"..S("Sort by Quantity").."]"
|
||||
elseif mode == 2 then
|
||||
return fs.."button["..x..",0;2,1;sort_mode;"..S("Sort by Type").."]"
|
||||
elseif mode == 3 then
|
||||
return fs.."button["..x..",0;2,1;sort_mode;"..S("Sort by Wear").."]"
|
||||
else
|
||||
return fs.."button["..x..",0;2,1;sort_mode;"..S("Sort by Item").."]"
|
||||
end
|
||||
end
|
||||
|
||||
function technic.chests.get_formspec(data)
|
||||
local formspec = {}
|
||||
local top_width = (data.infotext and 6 or 0) + (data.autosort and 2 or 0) + (data.sort and 3 or 0)
|
||||
local bottom_width = (data.quickmove and 3 or 0) + ((data.color or data.digilines) and 3 or 0) + 8
|
||||
local width = math.max(top_width, bottom_width, data.width)
|
||||
local padding = (width - bottom_width) / 2
|
||||
if data.quickmove and (data.color or data.digilines) then
|
||||
padding = (width - bottom_width) / 4
|
||||
elseif data.quickmove or data.color or data.digilines then
|
||||
padding = (width - bottom_width) / 3
|
||||
end
|
||||
local player_inv_left = padding
|
||||
if data.quickmove then
|
||||
player_inv_left = padding + 3 + padding
|
||||
end
|
||||
local player_inv_top = data.height + (has_pipeworks and 1.6 or 1.3)
|
||||
local height = data.height + (has_pipeworks and 5.4 or 5.1)
|
||||
local chest_inv_left = (width - data.width) / 2
|
||||
formspec.base =
|
||||
"size["..width..","..height.."]"..
|
||||
"list[context;main;"..chest_inv_left..",1;"..data.width..","..data.height..";]"..
|
||||
"list[current_player;main;"..player_inv_left..","..player_inv_top..";8,4;]"..
|
||||
"listring[context;main]"..
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(player_inv_left, player_inv_top)
|
||||
if data.quickmove then
|
||||
formspec.base = formspec.base..get_quickmove_fs(padding, data.height + 1.2)
|
||||
end
|
||||
formspec.padding = padding
|
||||
formspec.width = width
|
||||
return formspec
|
||||
end
|
||||
|
||||
function technic.chests.update_formspec(pos, data, edit_infotext)
|
||||
local formspec = data.formspec.base
|
||||
local meta = minetest.get_meta(pos)
|
||||
if data.infotext then
|
||||
formspec = formspec..get_infotext_fs(edit_infotext, meta)
|
||||
end
|
||||
if data.sort then
|
||||
formspec = formspec..get_sort_fs(data.formspec.width - 3, meta)
|
||||
if data.autosort then
|
||||
formspec = formspec..get_autosort_fs(data.formspec.width - 5, meta)
|
||||
end
|
||||
end
|
||||
if has_pipeworks then
|
||||
local offset = data.quickmove and (data.formspec.padding * 2 + 3) or data.formspec.padding
|
||||
formspec = formspec..get_pipeworks_fs(offset, data.height + 1, meta)
|
||||
end
|
||||
if data.color or data.digilines then
|
||||
local offset = data.quickmove and (data.formspec.padding * 3 + 11) or (data.formspec.padding * 2 + 8)
|
||||
if data.color then
|
||||
formspec = formspec..get_color_fs(offset, data.height + 1.2, meta)
|
||||
else
|
||||
formspec = formspec..get_digilines_fs(offset, data.height + 1.2, meta)
|
||||
end
|
||||
end
|
||||
meta:set_string("formspec", formspec)
|
||||
end
|
||||
|
||||
function technic.chests.get_receive_fields(data)
|
||||
return function(pos, formname, fields, player)
|
||||
if not fields or not player then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
local chest_inv = meta:get_inventory()
|
||||
local player_inv = player:get_inventory()
|
||||
if fields.quit then
|
||||
if meta:get_int("autosort") == 1 then
|
||||
technic.chests.sort_inv(chest_inv, meta:get_int("sort_mode"))
|
||||
end
|
||||
technic.chests.update_formspec(pos, data)
|
||||
return
|
||||
end
|
||||
if not technic.chests.change_allowed(pos, player, data.locked, data.protected) then
|
||||
return
|
||||
end
|
||||
if data.sort and fields.sort then
|
||||
technic.chests.sort_inv(chest_inv, meta:get_int("sort_mode"))
|
||||
return
|
||||
end
|
||||
if data.quickmove then
|
||||
if fields.all_to_chest then
|
||||
local moved_items = technic.chests.move_inv(player_inv, chest_inv)
|
||||
if data.digilines and meta:get_int("send_put") == 1 then
|
||||
technic.chests.send_digiline_message(pos, "put", player, moved_items)
|
||||
end
|
||||
technic.chests.log_inv_change(pos, player:get_player_name(), "put", "stuff")
|
||||
return
|
||||
elseif fields.all_to_inv then
|
||||
local moved_items = technic.chests.move_inv(chest_inv, player_inv)
|
||||
if data.digilines and meta:get_int("send_take") == 1 then
|
||||
technic.chests.send_digiline_message(pos, "take", player, moved_items)
|
||||
end
|
||||
technic.chests.log_inv_change(pos, player:get_player_name(), "take", "stuff")
|
||||
return
|
||||
elseif fields.existing_to_chest then
|
||||
local items = technic.chests.get_inv_items(chest_inv)
|
||||
local moved_items = technic.chests.move_inv(player_inv, chest_inv, items)
|
||||
if data.digilines and meta:get_int("send_put") == 1 then
|
||||
technic.chests.send_digiline_message(pos, "put", player, moved_items)
|
||||
end
|
||||
technic.chests.log_inv_change(pos, player:get_player_name(), "put", "stuff")
|
||||
return
|
||||
end
|
||||
end
|
||||
if not technic.chests.change_allowed(pos, player, data.locked, true) then
|
||||
return -- Protect settings from being changed, even for open chests
|
||||
end
|
||||
if has_pipeworks then
|
||||
pipeworks.fs_helpers.on_receive_fields(pos, fields)
|
||||
end
|
||||
if data.sort and fields.sort_mode then
|
||||
local value = meta:get_int("sort_mode") + 1
|
||||
if value < 0 or value > 3 then
|
||||
value = 0
|
||||
end
|
||||
meta:set_int("sort_mode", value)
|
||||
end
|
||||
if data.autosort and fields.autosort then
|
||||
local value = meta:get_int("autosort") == 1 and 0 or 1
|
||||
meta:set_int("autosort", value)
|
||||
end
|
||||
if data.color then
|
||||
for i = 1, 16 do
|
||||
if fields["color_button"..i] then
|
||||
local node = minetest.get_node(pos)
|
||||
if technic.chests.colors[i] then
|
||||
node.name = data.node_name.."_"..technic.chests.colors[i][1]
|
||||
else
|
||||
node.name = data.node_name
|
||||
end
|
||||
minetest.swap_node(pos, node)
|
||||
meta:set_int("color", i)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if data.digilines then
|
||||
if fields.save_channel and fields.channel then
|
||||
meta:set_string("channel", fields.channel)
|
||||
end
|
||||
for _,setting in pairs({"send_put", "send_take", "send_inject", "send_pull", "send_overflow"}) do
|
||||
if fields[setting] then
|
||||
local value = fields[setting] == "true" and 1 or 0
|
||||
meta:set_int(setting, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
if data.infotext then
|
||||
if fields.edit_infotext then
|
||||
technic.chests.update_formspec(pos, data, true)
|
||||
return
|
||||
elseif fields.save_infotext and fields.infotext then
|
||||
meta:set_string("infotext", fields.infotext)
|
||||
end
|
||||
end
|
||||
technic.chests.update_formspec(pos, data)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,83 @@
|
||||
|
||||
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
|
||||
--local S = minetest.get_translator("technic_chests")
|
||||
|
||||
local modpath = minetest.get_modpath("technic_chests")
|
||||
|
||||
technic = rawget(_G, "technic") or {}
|
||||
technic.chests = {}
|
||||
|
||||
technic.chests.colors = {
|
||||
{"black", S("Black")},
|
||||
{"blue", S("Blue")},
|
||||
{"brown", S("Brown")},
|
||||
{"cyan", S("Cyan")},
|
||||
{"dark_green", S("Dark Green")},
|
||||
{"dark_grey", S("Dark Grey")},
|
||||
{"green", S("Green")},
|
||||
{"grey", S("Grey")},
|
||||
{"magenta", S("Magenta")},
|
||||
{"orange", S("Orange")},
|
||||
{"pink", S("Pink")},
|
||||
{"red", S("Red")},
|
||||
{"violet", S("Violet")},
|
||||
{"white", S("White")},
|
||||
{"yellow", S("Yellow")},
|
||||
}
|
||||
|
||||
function technic.chests.change_allowed(pos, player, owned, protected)
|
||||
if owned then
|
||||
if minetest.is_player(player) and not default.can_interact_with_node(player, pos) then
|
||||
return false
|
||||
end
|
||||
elseif protected then
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return false
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
if minetest.get_modpath("digilines") then
|
||||
dofile(modpath.."/digilines.lua")
|
||||
end
|
||||
|
||||
dofile(modpath.."/formspec.lua")
|
||||
dofile(modpath.."/inventory.lua")
|
||||
dofile(modpath.."/register.lua")
|
||||
dofile(modpath.."/chests.lua")
|
||||
|
||||
-- Undo all of the locked wooden chest recipes, and just make them use a padlock.
|
||||
minetest.register_on_mods_loaded(function()
|
||||
minetest.clear_craft({output = "default:chest_locked"})
|
||||
minetest.register_craft({
|
||||
output = "default:chest_locked",
|
||||
recipe = {
|
||||
{ "group:wood", "group:wood", "group:wood" },
|
||||
{ "group:wood", "basic_materials:padlock", "group:wood" },
|
||||
{ "group:wood", "group:wood", "group:wood" }
|
||||
}
|
||||
})
|
||||
minetest.register_craft({
|
||||
output = "default:chest_locked",
|
||||
type = "shapeless",
|
||||
recipe = {
|
||||
"default:chest",
|
||||
"basic_materials:padlock"
|
||||
}
|
||||
})
|
||||
end)
|
||||
|
||||
-- Conversion for old chests
|
||||
minetest.register_lbm({
|
||||
name = "technic_chests:old_chest_conversion",
|
||||
nodenames = {"group:technic_chest"},
|
||||
run_at_every_load = false,
|
||||
action = function(pos, node)
|
||||
-- Use `on_construct` function because that has data from register function
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
if def and def.on_construct then
|
||||
def.on_construct(pos)
|
||||
end
|
||||
end,
|
||||
})
|
||||
@@ -0,0 +1,142 @@
|
||||
|
||||
-- Table to define order of type sorting
|
||||
local itemtypes = {
|
||||
node = 1,
|
||||
tool = 2,
|
||||
craft = 3,
|
||||
none = 4
|
||||
}
|
||||
|
||||
function technic.chests.sort_inv(inv, mode)
|
||||
local list = inv:get_list("main")
|
||||
if not list then return end
|
||||
local items = {}
|
||||
for _,stack in pairs(list) do
|
||||
if not stack:is_empty() then
|
||||
local name = stack:get_name()
|
||||
local wear = stack:get_wear()
|
||||
local meta = stack:get_metadata()
|
||||
local count = stack:get_count()
|
||||
local def = minetest.registered_items[name]
|
||||
local itemtype = (def and itemtypes[def.type]) and def.type or "none"
|
||||
local key = string.format("%s %05d %s", name, wear, meta)
|
||||
if not items[key] then
|
||||
items[key] = {
|
||||
stacks = {stack},
|
||||
wear = wear,
|
||||
count = count,
|
||||
itemtype = itemtype,
|
||||
key = key,
|
||||
}
|
||||
else
|
||||
items[key].count = items[key].count + count
|
||||
table.insert(items[key].stacks, stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
local unique_items = {}
|
||||
for k,v in pairs(items) do
|
||||
table.insert(unique_items, v)
|
||||
end
|
||||
if mode == 1 then
|
||||
-- Quantity
|
||||
table.sort(unique_items, function(a, b)
|
||||
if a.count ~= b.count then
|
||||
return a.count > b.count
|
||||
end
|
||||
return a.key < b.key
|
||||
end)
|
||||
elseif mode == 2 then
|
||||
-- Type
|
||||
table.sort(unique_items, function(a, b)
|
||||
if itemtypes[a.itemtype] ~= itemtypes[b.itemtype] then
|
||||
return itemtypes[a.itemtype] < itemtypes[b.itemtype]
|
||||
end
|
||||
return a.key < b.key
|
||||
end)
|
||||
elseif mode == 3 then
|
||||
-- Wear
|
||||
table.sort(unique_items, function(a, b)
|
||||
if a.itemtype == "tool" and b.itemtype == "tool" then
|
||||
if a.wear ~= b.wear then
|
||||
return a.wear < b.wear
|
||||
end
|
||||
return a.key < b.key
|
||||
elseif a.itemtype == "tool" or b.itemtype == "tool" then
|
||||
return a.itemtype == "tool"
|
||||
end
|
||||
return a.key < b.key
|
||||
end)
|
||||
else
|
||||
-- Item
|
||||
table.sort(unique_items, function(a, b)
|
||||
return a.key < b.key
|
||||
end)
|
||||
end
|
||||
inv:set_list("main", {})
|
||||
for _,item in ipairs(unique_items) do
|
||||
for _,stack in ipairs(item.stacks) do
|
||||
inv:add_item("main", stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function technic.chests.get_inv_items(inv)
|
||||
local list = inv:get_list("main")
|
||||
if not list then return {} end
|
||||
local keys = {}
|
||||
for _,stack in pairs(list) do
|
||||
if not stack:is_empty() then
|
||||
keys[stack:get_name()] = true
|
||||
end
|
||||
end
|
||||
local items = {}
|
||||
for k,_ in pairs(keys) do
|
||||
items[#items + 1] = k
|
||||
end
|
||||
return items
|
||||
end
|
||||
|
||||
function technic.chests.move_inv(from_inv, to_inv, filter)
|
||||
local list = from_inv:get_list("main")
|
||||
if not list then return {} end
|
||||
local moved_items = {}
|
||||
for i,stack in ipairs(list) do
|
||||
if not stack:is_empty() then
|
||||
local move_stack = false
|
||||
local name = stack:get_name()
|
||||
if name == filter or not filter then
|
||||
move_stack = true
|
||||
elseif type(filter) == "table" then
|
||||
for _,k in pairs(filter) do
|
||||
if name == k then
|
||||
move_stack = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
if move_stack then
|
||||
local leftover = to_inv:add_item("main", stack)
|
||||
if not leftover:is_empty() then
|
||||
from_inv:set_stack("main", i, leftover)
|
||||
stack:set_count(stack:get_count() - leftover:get_count())
|
||||
else
|
||||
from_inv:set_stack("main", i, "")
|
||||
end
|
||||
table.insert(moved_items, stack:to_table())
|
||||
end
|
||||
end
|
||||
end
|
||||
return moved_items
|
||||
end
|
||||
|
||||
function technic.chests.log_inv_change(pos, name, change, items)
|
||||
local spos = minetest.pos_to_string(pos)
|
||||
if change == "move" then
|
||||
minetest.log("action", name.." moves "..items.." in chest at "..spos)
|
||||
elseif change == "put" then
|
||||
minetest.log("action", name.." puts "..items.." into chest at "..spos)
|
||||
elseif change == "take" then
|
||||
minetest.log("action", name.." takes "..items.." from chest at "..spos)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,41 @@
|
||||
# German Translation for technic_chests
|
||||
# Deutsche Übersetzung von technic_chests
|
||||
# by Xanthin
|
||||
|
||||
%s Chest = %struhe
|
||||
%s Locked Chest = Verschlossene %struhe
|
||||
%s Locked Chest (owned by %s) = Verschlossene %struhe (gehoert %s)
|
||||
Color Filter: %s = Farbfilter: %s
|
||||
Edit chest description: = Bearbeite die Beschreibung
|
||||
|
||||
# Colors
|
||||
Black = Schwarz
|
||||
Blue = Blau
|
||||
Brown = Braun
|
||||
Cyan = Tuerkis
|
||||
Dark Green = Dunkelgruen
|
||||
Dark Grey = Dunkelgrau
|
||||
Green = Gruen
|
||||
Grey = Grau
|
||||
Magenta = Magenta
|
||||
Orange = Orange
|
||||
Pink = Rosa
|
||||
Red = Rot
|
||||
Violet = Violett
|
||||
White = Weiss
|
||||
Yellow = Gelb
|
||||
None = Farblos
|
||||
|
||||
# Materials
|
||||
Copper = Kupfer
|
||||
Gold = Gold
|
||||
Iron = Eisen
|
||||
Mithril = Mithril
|
||||
Silver = Silber
|
||||
Wooden = Holz
|
||||
|
||||
# Sorting
|
||||
Sort =
|
||||
Auto-sort is %s =
|
||||
Off =
|
||||
On =
|
||||
@@ -0,0 +1,39 @@
|
||||
# technic_chests translation template
|
||||
|
||||
%s Chest = Cofre de %s
|
||||
%s Locked Chest = Cofre de %s Bloqueado
|
||||
%s Locked Chest (owned by %s) = Cofre de %s Bloqueado (propiedad de %s)
|
||||
Color Filter: %s = Filtro por Color: %s
|
||||
Edit chest description: = Editar la descripción del cofre
|
||||
|
||||
# Colors
|
||||
Black = Negro
|
||||
Blue = Azul
|
||||
Brown = Café
|
||||
Cyan = Cian
|
||||
Dark Green = Verde Oscuro
|
||||
Dark Grey = Gris Oscuro
|
||||
Green = Verde
|
||||
Grey = Gris
|
||||
Magenta = Magenta
|
||||
Orange = Naranja
|
||||
Pink = Rosado
|
||||
Red = Rojo
|
||||
Violet = Violeta
|
||||
White = Blanco
|
||||
Yellow = Amarillo
|
||||
None = Ninguno
|
||||
|
||||
# Materials
|
||||
Copper = Cobre
|
||||
Gold = Oro
|
||||
Iron = Hierro
|
||||
Mithril = Mitrilo
|
||||
Silver = Plata
|
||||
Wooden = Madera
|
||||
|
||||
# Sorting
|
||||
Sort = Ordenar
|
||||
Auto-sort is %s = El orden Automático esta %s
|
||||
Off = Apagado
|
||||
On = Encendido
|
||||
@@ -0,0 +1,39 @@
|
||||
# technic_chests translation template
|
||||
|
||||
%s Chest = Coffre en %s
|
||||
%s Locked Chest = Coffre verrouillé en %s
|
||||
%s Locked Chest (owned by %s) = Coffre verrouillé en %s (appartient à %s)
|
||||
Color Filter: %s = Filtre couleur : %s
|
||||
Edit chest description: = Editer la description du coffre
|
||||
|
||||
# Colors
|
||||
Black = Noir
|
||||
Blue = Bleu
|
||||
Brown = Marron
|
||||
Cyan = Cyan
|
||||
Dark Green = Vert foncé
|
||||
Dark Grey = Gris foncé
|
||||
Green = Vert
|
||||
Grey = Gris
|
||||
Magenta = Magenta
|
||||
Orange = Orange
|
||||
Pink = Rose
|
||||
Red = Rouge
|
||||
Violet = Violet
|
||||
White = Blanc
|
||||
Yellow = Jaune
|
||||
None = Rien
|
||||
|
||||
# Materials
|
||||
Copper = cuivre
|
||||
Gold = or
|
||||
Iron = fer
|
||||
Mithril = mithril
|
||||
Silver = argent
|
||||
Wooden = bois
|
||||
|
||||
# Sorting
|
||||
Sort = Tri
|
||||
Auto-sort is %s = Tri automatique %s
|
||||
Off = désactivé
|
||||
On = activé
|
||||
@@ -0,0 +1,41 @@
|
||||
# Polish Translation for technic_chests
|
||||
# Polskie tłumaczenie technic_chests
|
||||
# by mat9117
|
||||
|
||||
%s Chest = %s Skrzynia
|
||||
%s Locked Chest = %s Zamknięta skrzynia
|
||||
%s Locked Chest (owned by %s) = %s Zamknięta skrzynia (należy do %s)
|
||||
Color Filter: %s = Filtr kolorów: %s
|
||||
Edit chest description: = Edytuj opis skrzyni
|
||||
|
||||
# Colors
|
||||
Black = Czarny
|
||||
Blue = Niebieski
|
||||
Brown = Brązowy
|
||||
Cyan = Cyan
|
||||
Dark Green = Ciemnozielony
|
||||
Dark Grey = Ciemnoszary
|
||||
Green = Zielony
|
||||
Grey = Szary
|
||||
Magenta = Magenta
|
||||
Orange = Pomarańczowy
|
||||
Pink = Różowy
|
||||
Red = Czerwony
|
||||
Violet = Fioletowy
|
||||
White = Biały
|
||||
Yellow = Żółty
|
||||
None = Żaden
|
||||
|
||||
# Materials
|
||||
Copper = Miedziana
|
||||
Gold = Złota
|
||||
Iron = Żelazna
|
||||
Mithril = Mithrilowa
|
||||
Silver = Srebrna
|
||||
Wooden = Drewniana
|
||||
|
||||
# Sorting
|
||||
Sort = Sortuj
|
||||
Auto-sort is %s = Autosortowanie jest %s
|
||||
Off = Wyłaczone
|
||||
On = Włączone
|
||||
@@ -0,0 +1,41 @@
|
||||
# Braziliam portuguese translation for technic_chests
|
||||
# Tradução portuguesa brasileira para technic_chests
|
||||
# By Sires
|
||||
|
||||
%s Chest = Baú %s
|
||||
%s Locked Chest = Baú Trancado %s
|
||||
%s Locked Chest (owned by %s) = Baú Trancado %s (pertence a/à %s)
|
||||
Color Filter: %s = Filtro de Cor: %s
|
||||
Edit chest description: = Editar descrição do baú:
|
||||
|
||||
# Colors
|
||||
Black = Preto
|
||||
Blue = Azul
|
||||
Brown = Marrom
|
||||
Cyan = Ciano
|
||||
Dark Green = Verde Escuro
|
||||
Dark Grey = Cinza Escuro
|
||||
Green = Verde
|
||||
Grey = Cinza
|
||||
Magenta = Magenta
|
||||
Orange = Laranja
|
||||
Pink = Rosa
|
||||
Red = Vermelho
|
||||
Violet = Violeta
|
||||
White = Branco
|
||||
Yellow = Amarelo
|
||||
None = Nada
|
||||
|
||||
# Materials
|
||||
Copper = Cobre
|
||||
Gold = Ouro
|
||||
Iron = Ferro
|
||||
Mithril = Mithril
|
||||
Silver = Prata
|
||||
Wooden = de Madeira
|
||||
|
||||
# Sorting
|
||||
Sort = Ordenar
|
||||
Auto-sort is %s = Auto-ordenação está %s
|
||||
Off = Desligada
|
||||
On = Ligada
|
||||
@@ -0,0 +1,39 @@
|
||||
# technic_chests translation template
|
||||
|
||||
%s Chest =
|
||||
%s Locked Chest =
|
||||
%s Locked Chest (owned by %s) =
|
||||
Color Filter: %s =
|
||||
Edit chest description: =
|
||||
|
||||
# Colors
|
||||
Black =
|
||||
Blue =
|
||||
Brown =
|
||||
Cyan =
|
||||
Dark Green =
|
||||
Dark Grey =
|
||||
Green =
|
||||
Grey =
|
||||
Magenta =
|
||||
Orange =
|
||||
Pink =
|
||||
Red =
|
||||
Violet =
|
||||
White =
|
||||
Yellow =
|
||||
None =
|
||||
|
||||
# Materials
|
||||
Copper =
|
||||
Gold =
|
||||
Iron =
|
||||
Mithril =
|
||||
Silver =
|
||||
Wooden =
|
||||
|
||||
# Sorting
|
||||
Sort =
|
||||
Auto-sort is %s =
|
||||
Off =
|
||||
On =
|
||||
@@ -0,0 +1,41 @@
|
||||
# Turkish translation
|
||||
# mahmutelmas06@hotmail.com
|
||||
# Türkçe çeviri
|
||||
|
||||
%s Chest = %s Sandık
|
||||
%s Locked Chest = %s Kilitli sandık
|
||||
%s Locked Chest (owned by %s) = %s Kilitli sandık (Sahibi %s)
|
||||
Color Filter: %s = Renk süzgeci: %s
|
||||
Edit chest description: = Sandık bilgilerini düzenle
|
||||
|
||||
# Colors - Renkler
|
||||
Black = Siyah
|
||||
Blue = Mavi
|
||||
Brown = Kahverengi
|
||||
Cyan = Cam göbeği
|
||||
Dark Green = Koyu yeşil
|
||||
Dark Grey = Koyu gri
|
||||
Green = Yeşil
|
||||
Grey = Gri
|
||||
Magenta = Mor
|
||||
Orange = Turuncu
|
||||
Pink = Pembe
|
||||
Red = Kırmızı
|
||||
Violet = Koyu mor
|
||||
White = Beyaz
|
||||
Yellow = Sarı
|
||||
None = Hiç
|
||||
|
||||
# Materials - Metaryeller
|
||||
Copper = Bakır
|
||||
Gold = Altın
|
||||
Iron = Demir
|
||||
Mithril = Mithril
|
||||
Silver = Gümüş
|
||||
Wooden = Ahşap
|
||||
|
||||
# Sorting - Sıralama
|
||||
Sort = Sırala
|
||||
Auto-sort is %s = Otomatik sıralama %s
|
||||
Off = Kapalı
|
||||
On = Açık
|
||||
@@ -0,0 +1,31 @@
|
||||
%s Chest =%s箱子
|
||||
%s Locked Chest =上锁的%s箱子
|
||||
%s Locked Chest (owned by %s) =上锁的%s锁箱子(归%s所有)
|
||||
Color Filter: %s =颜色筛选器:%s
|
||||
Edit chest description: =编辑箱子描述:
|
||||
Black =黑色
|
||||
Blue =蓝色
|
||||
Brown =棕色
|
||||
Cyan =青色
|
||||
Dark Green =深绿色
|
||||
Dark Grey =深灰色
|
||||
Green =绿色
|
||||
Grey =灰色
|
||||
Magenta =洋红
|
||||
Orange =橙色
|
||||
Pink =粉红色
|
||||
Red =红色
|
||||
Violet =紫罗兰色
|
||||
White =白色
|
||||
Yellow =黄色
|
||||
None =没有
|
||||
Copper =铜
|
||||
Gold =黄金
|
||||
Iron =铁
|
||||
Mithril =秘银
|
||||
Silver =银
|
||||
Wooden =木制
|
||||
Sort =排序
|
||||
Auto-sort is %s =自动排序为%s
|
||||
Off =关
|
||||
On =打开
|
||||
@@ -0,0 +1,3 @@
|
||||
name = technic_chests
|
||||
depends = default, basic_materials
|
||||
optional_depends = technic, technic_worldgen, moreores, pipeworks, protector, digilines, intllib
|
||||
@@ -0,0 +1,246 @@
|
||||
|
||||
local S = rawget(_G, "intllib") and intllib.Getter() or function(s) return s end
|
||||
--local S = minetest.get_translator("technic_chests")
|
||||
|
||||
local has_pipeworks = minetest.get_modpath("pipeworks")
|
||||
local has_digilines = minetest.get_modpath("digilines")
|
||||
local has_protector = minetest.get_modpath("protector")
|
||||
|
||||
local tube_entry = has_pipeworks and "^pipeworks_tube_connection_metallic.png" or ""
|
||||
local protector_overlay = has_protector and "^protector_logo.png" or "^technic_protector_overlay.png"
|
||||
|
||||
local node_groups = {
|
||||
snappy = 2,
|
||||
choppy = 2,
|
||||
oddly_breakable_by_hand = 2,
|
||||
tubedevice = 1,
|
||||
tubedevice_receiver = 1,
|
||||
technic_chest = 1,
|
||||
}
|
||||
|
||||
local node_groups_no_inv = {
|
||||
snappy = 2,
|
||||
choppy = 2,
|
||||
oddly_breakable_by_hand = 2,
|
||||
tubedevice = 1,
|
||||
tubedevice_receiver = 1,
|
||||
technic_chest = 1,
|
||||
not_in_creative_inventory = 1,
|
||||
}
|
||||
|
||||
local function get_tiles(name, data, color)
|
||||
local tiles = {
|
||||
"technic_"..name.."_chest_top.png"..tube_entry,
|
||||
"technic_"..name.."_chest_top.png"..tube_entry,
|
||||
"technic_"..name.."_chest_side.png"..tube_entry,
|
||||
"technic_"..name.."_chest_side.png"..tube_entry,
|
||||
"technic_"..name.."_chest_side.png"..tube_entry,
|
||||
"technic_"..name.."_chest_front.png"
|
||||
}
|
||||
if data.color and color then
|
||||
tiles[6] = tiles[6].."^technic_chest_overlay_"..technic.chests.colors[color][1]..".png"
|
||||
end
|
||||
if data.locked then
|
||||
tiles[6] = tiles[6].."^technic_"..name.."_chest_lock_overlay.png"
|
||||
elseif data.protected then
|
||||
tiles[6] = tiles[6]..protector_overlay
|
||||
end
|
||||
return tiles
|
||||
end
|
||||
|
||||
function technic.chests.register_chest(name, data)
|
||||
local lname = name:lower()
|
||||
name = S(name)
|
||||
if data.digilines and not has_digilines then
|
||||
data.digilines = nil
|
||||
end
|
||||
if data.locked then
|
||||
data.node_name = "technic:"..lname.."_locked_chest"
|
||||
data.description = S("%s Locked Chest"):format(name)
|
||||
elseif data.protected then
|
||||
data.node_name = "technic:"..lname.."_protected_chest"
|
||||
data.description = S("%s Protected Chest"):format(name)
|
||||
else
|
||||
data.node_name = "technic:"..lname.."_chest"
|
||||
data.description = S("%s Chest"):format(name)
|
||||
end
|
||||
data.formspec = technic.chests.get_formspec(data)
|
||||
local def = {
|
||||
description = data.description,
|
||||
tiles = get_tiles(lname, data),
|
||||
paramtype2 = "facedir",
|
||||
legacy_facedir_simple = true,
|
||||
groups = node_groups,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = data.node_name,
|
||||
after_place_node = function(pos, placer)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if data.locked then
|
||||
local owner = placer:get_player_name() or ""
|
||||
meta:set_string("owner", owner)
|
||||
meta:set_string("infotext", S("%s Locked Chest (owned by %s)"):format(name, owner))
|
||||
else
|
||||
meta:set_string("infotext", data.description)
|
||||
end
|
||||
if has_pipeworks then
|
||||
pipeworks.after_place(pos)
|
||||
end
|
||||
end,
|
||||
after_dig_node = function(pos)
|
||||
if has_pipeworks then
|
||||
pipeworks.after_dig(pos)
|
||||
end
|
||||
end,
|
||||
tube = {
|
||||
insert_object = function(pos, node, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if data.digilines and meta:get_int("send_inject") == 1 then
|
||||
technic.chests.send_digiline_message(pos, "inject", nil, {stack:to_table()})
|
||||
end
|
||||
technic.chests.log_inv_change(pos, "pipeworks tube", "put", stack:get_name())
|
||||
return meta:get_inventory():add_item("main", stack)
|
||||
end,
|
||||
can_insert = function(pos, node, stack)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("splitstacks") == 1 then
|
||||
stack = stack:peek_item(1)
|
||||
end
|
||||
local can_insert = meta:get_inventory():room_for_item("main", stack)
|
||||
if not can_insert and data.digilines and meta:get_int("send_overflow") == 1 then
|
||||
technic.chests.send_digiline_message(pos, "overflow", nil, {stack:to_table()})
|
||||
end
|
||||
return can_insert
|
||||
end,
|
||||
remove_items = function(pos, node, stack, dir, count, list, index)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local item = stack:take_item(count)
|
||||
meta:get_inventory():set_stack(list, index, stack)
|
||||
if data.digilines and meta:get_int("send_pull") == 1 then
|
||||
technic.chests.send_digiline_message(pos, "pull", nil, {item:to_table()})
|
||||
end
|
||||
technic.chests.log_inv_change(pos, "pipeworks tube", "take", item:get_name())
|
||||
return item
|
||||
end,
|
||||
input_inventory = "main",
|
||||
connect_sides = {left=1, right=1, front=1, back=1, top=1, bottom=1},
|
||||
},
|
||||
on_construct = function(pos)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
inv:set_size("main", data.width * data.height)
|
||||
if data.quickmove then
|
||||
inv:set_size("quickmove", 1)
|
||||
end
|
||||
technic.chests.update_formspec(pos, data)
|
||||
end,
|
||||
can_dig = function(pos, player)
|
||||
if not technic.chests.change_allowed(pos, player, data.locked, data.protected) then
|
||||
return false
|
||||
end
|
||||
return minetest.get_meta(pos):get_inventory():is_empty("main")
|
||||
end,
|
||||
allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
if not technic.chests.change_allowed(pos, player, data.locked, data.protected) then
|
||||
return 0
|
||||
end
|
||||
if data.quickmove and to_list == "quickmove" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local stack = inv:get_stack("main", from_index)
|
||||
local moved_items = technic.chests.move_inv(inv, player:get_inventory(), stack:get_name())
|
||||
if data.digilines and meta:get_int("send_take") == 1 then
|
||||
technic.chests.send_digiline_message(pos, "take", player, moved_items)
|
||||
end
|
||||
technic.chests.log_inv_change(pos, player:get_player_name(), "take", "stuff")
|
||||
return 0
|
||||
end
|
||||
return count
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if not technic.chests.change_allowed(pos, player, data.locked, data.protected) then
|
||||
return 0
|
||||
end
|
||||
if data.quickmove and listname == "quickmove" then
|
||||
local meta = minetest.get_meta(pos)
|
||||
local inv = meta:get_inventory()
|
||||
local moved_items = technic.chests.move_inv(player:get_inventory(), inv, stack:get_name())
|
||||
if data.digilines and meta:get_int("send_put") == 1 then
|
||||
technic.chests.send_digiline_message(pos, "put", player, moved_items)
|
||||
end
|
||||
technic.chests.log_inv_change(pos, player:get_player_name(), "put", "stuff")
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
allow_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if not technic.chests.change_allowed(pos, player, data.locked, data.protected) then
|
||||
return 0
|
||||
end
|
||||
return stack:get_count()
|
||||
end,
|
||||
on_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
technic.chests.log_inv_change(pos, player:get_player_name(), "move", "stuff")
|
||||
end,
|
||||
on_metadata_inventory_put = function(pos, listname, index, stack, player)
|
||||
if data.digilines and minetest.get_meta(pos):get_int("send_put") == 1 then
|
||||
technic.chests.send_digiline_message(pos, "put", player, {stack:to_table()})
|
||||
end
|
||||
technic.chests.log_inv_change(pos, player:get_player_name(), "put", stack:get_name())
|
||||
end,
|
||||
on_metadata_inventory_take = function(pos, listname, index, stack, player)
|
||||
if data.digilines and minetest.get_meta(pos):get_int("send_take") == 1 then
|
||||
technic.chests.send_digiline_message(pos, "take", player, {stack:to_table()})
|
||||
end
|
||||
technic.chests.log_inv_change(pos, player:get_player_name(), "take", stack:get_name())
|
||||
end,
|
||||
on_blast = function(pos)
|
||||
if data.locked or data.protected then
|
||||
return
|
||||
end
|
||||
local drops = {}
|
||||
default.get_inventory_drops(pos, "main", drops)
|
||||
drops[#drops+1] = data.node_name
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end,
|
||||
on_receive_fields = technic.chests.get_receive_fields(data),
|
||||
}
|
||||
if data.locked then
|
||||
def.on_skeleton_key_use = function(pos, player, newsecret)
|
||||
-- Copied from default chests.lua
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = meta:get_string("owner")
|
||||
local player_name = player:get_player_name()
|
||||
if owner ~= player_name then
|
||||
minetest.record_protection_violation(pos, player_name)
|
||||
minetest.chat_send_player(player_name, "You do not own this chest.")
|
||||
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, "a locked chest", owner
|
||||
end
|
||||
end
|
||||
if data.digilines then
|
||||
def.digiline = {
|
||||
receptor = {},
|
||||
effector = {
|
||||
action = technic.chests.digiline_effector
|
||||
},
|
||||
}
|
||||
end
|
||||
minetest.register_node(":"..data.node_name, def)
|
||||
if data.color then
|
||||
for i = 1, 15 do
|
||||
local colordef = {}
|
||||
for k, v in pairs(def) do
|
||||
colordef[k] = v
|
||||
end
|
||||
colordef.groups = node_groups_no_inv
|
||||
colordef.tiles = get_tiles(lname, data, i)
|
||||
minetest.register_node(":"..data.node_name.."_"..technic.chests.colors[i][1], colordef)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 3.3 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 3.8 KiB |
|
After Width: | Height: | Size: 1.7 KiB |
|
After Width: | Height: | Size: 212 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 3.1 KiB |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 120 B |
|
After Width: | Height: | Size: 504 B |
|
After Width: | Height: | Size: 111 B |
|
After Width: | Height: | Size: 471 B |
|
After Width: | Height: | Size: 437 B |
|
After Width: | Height: | Size: 613 B |
|
After Width: | Height: | Size: 200 B |
|
After Width: | Height: | Size: 567 B |
|
After Width: | Height: | Size: 561 B |
|
After Width: | Height: | Size: 559 B |
|
After Width: | Height: | Size: 110 B |
|
After Width: | Height: | Size: 588 B |
|
After Width: | Height: | Size: 735 B |
|
After Width: | Height: | Size: 599 B |
|
After Width: | Height: | Size: 112 B |
|
After Width: | Height: | Size: 583 B |
|
After Width: | Height: | Size: 602 B |
|
After Width: | Height: | Size: 252 B |
|
After Width: | Height: | Size: 138 B |
|
After Width: | Height: | Size: 652 B |
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 613 B |
|
After Width: | Height: | Size: 605 B |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 1.9 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 1.3 KiB |