Add mods: technic, moreores, paintings, Nyancat (Pbj_pup). Small fix: sandwiches
28
mods/technic_plus_beta/technic_chests/README.md
Normal file
|
@ -0,0 +1,28 @@
|
|||
Technic chests
|
||||
==============
|
||||
|
||||
[](https://github.com/mt-mods/technic/actions/workflows/luacheck.yml?query=branch%3Amaster)
|
||||
[](https://github.com/mt-mods/technic/actions/workflows/mineunit.yml?query=branch%3Amaster)
|
||||
[](https://github.com/mt-mods/technic/actions/workflows/mineunit.yml?query=branch%3Amaster+is%3Asuccess)
|
||||
|
||||
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.
|
||||
|
164
mods/technic_plus_beta/technic_chests/chests.lua
Normal file
|
@ -0,0 +1,164 @@
|
|||
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
local function register_chests(data)
|
||||
local name = data.description:lower()
|
||||
local type_description = {
|
||||
S("@1 Chest", S(data.description)),
|
||||
S("@1 Locked Chest", S(data.description)),
|
||||
S("@1 Protected Chest", S(data.description)),
|
||||
}
|
||||
for i,t in ipairs({"", "_locked", "_protected"}) do
|
||||
local data_copy = table.copy(data)
|
||||
data_copy.locked = t == "_locked"
|
||||
data_copy.protected = t == "_protected"
|
||||
data_copy.texture_prefix = "technic_"..name.."_chest"
|
||||
data_copy.description = type_description[i]
|
||||
technic.chests.register_chest(":technic:"..name..t.."_chest", 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({
|
||||
description = "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({
|
||||
description = "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({
|
||||
description = "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({
|
||||
description = "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({
|
||||
description = "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"
|
||||
)
|
102
mods/technic_plus_beta/technic_chests/digilines.lua
Normal file
|
@ -0,0 +1,102 @@
|
|||
|
||||
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_meta():get_string("") == 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)
|
||||
local item = stack:to_table()
|
||||
if item then
|
||||
-- item available at that slot
|
||||
local def = minetest.registered_items[stack:get_name()]
|
||||
item.groups = def and table.copy(def.groups) or {}
|
||||
digilines.receptor_send(pos, digilines.rules.default, set_channel, item)
|
||||
else
|
||||
-- nothing there, return nil
|
||||
digilines.receptor_send(pos, digilines.rules.default, set_channel, nil)
|
||||
end
|
||||
|
||||
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
|
254
mods/technic_plus_beta/technic_chests/formspec.lua
Normal file
|
@ -0,0 +1,254 @@
|
|||
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
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: @1", 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").."]"
|
||||
elseif mode == 4 then
|
||||
return fs.."button["..x..",0;2,1;sort_mode;"..S("Natural sort").."]"
|
||||
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(nodename, 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")
|
||||
meta:set_int("sort_mode", (value + 1) % 5)
|
||||
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 = nodename.."_"..technic.chests.colors[i][1]
|
||||
else
|
||||
node.name = nodename
|
||||
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
|
82
mods/technic_plus_beta/technic_chests/init.lua
Normal file
|
@ -0,0 +1,82 @@
|
|||
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
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,
|
||||
})
|
193
mods/technic_plus_beta/technic_chests/inventory.lua
Normal file
|
@ -0,0 +1,193 @@
|
|||
|
||||
-- Table to define order of type sorting
|
||||
local itemtypes = {
|
||||
node = 1,
|
||||
tool = 2,
|
||||
craft = 3,
|
||||
none = 4
|
||||
}
|
||||
|
||||
-- Not so good compatibility workaround for older than 5.3 servers
|
||||
local get_translated_string = minetest.get_translated_string or function(_, name) return name end
|
||||
|
||||
function technic.chests.sort_inv(inv, mode)
|
||||
local list = inv:get_list("main")
|
||||
if not list then return end
|
||||
local unique_items = {}
|
||||
if mode ~= 4 then
|
||||
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_meta():get_string("")
|
||||
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
|
||||
for k,v in pairs(items) do
|
||||
table.insert(unique_items, v)
|
||||
end
|
||||
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)
|
||||
elseif mode == 4 then
|
||||
-- Natural
|
||||
do -- Collect item stacks for sorting
|
||||
local function name(stack)
|
||||
return stack:get_meta():get("infotext")
|
||||
or stack:get_description()
|
||||
or stack:get_name()
|
||||
end
|
||||
local lookup = {}
|
||||
for _,stack in pairs(list) do
|
||||
local key = get_translated_string('', name(stack))
|
||||
if not lookup[key] then
|
||||
table.insert(unique_items, {
|
||||
stacks = {stack},
|
||||
key = key,
|
||||
})
|
||||
lookup[key] = #unique_items
|
||||
else
|
||||
table.insert(unique_items[lookup[key]].stacks, stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
local function padnum(value)
|
||||
local dec, n = string.match(value, "(%.?)0*(.+)")
|
||||
return #dec > 0 and ("%.12f"):format(value) or ("%s%03d%s"):format(dec, #n, n)
|
||||
end
|
||||
table.sort(unique_items, function(a, b)
|
||||
local sort_a = ("%s%3d"):format(tostring(a.key):gsub("%.?%d+", padnum), #b.key)
|
||||
local sort_b = ("%s%3d"):format(tostring(b.key):gsub("%.?%d+", padnum), #a.key)
|
||||
return sort_a < sort_b
|
||||
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
|
||||
|
||||
function technic.chests.log_fast_move(pos, name, change, items)
|
||||
local spos = minetest.pos_to_string(pos)
|
||||
local itemlist = {}
|
||||
for _, stack in ipairs(items) do
|
||||
table.insert(itemlist, stack.name.." "..stack.count)
|
||||
end
|
||||
if change == "put" then
|
||||
minetest.log("action", string.format("%s puts items into chest at %s: %s",
|
||||
name, spos, table.concat(itemlist, ", ")))
|
||||
elseif change == "take" then
|
||||
minetest.log("action", string.format("%s takes items from chest at %s: %s",
|
||||
name, spos, table.concat(itemlist, ", ")))
|
||||
end
|
||||
end
|
|
@ -0,0 +1,63 @@
|
|||
# textdomain: technic_chests
|
||||
|
||||
# German Translation for technic_chests
|
||||
# Deutsche Übersetzung von technic_chests
|
||||
# by Xanthin
|
||||
|
||||
@1 Chest=@1truhe
|
||||
@1 Locked Chest=Verschlossene @1truhe
|
||||
@1 Locked Chest (owned by @2)=Verschlossene @1truhe (gehoert @2)
|
||||
Color Filter: @1=Farbfilter: @1
|
||||
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 @1=
|
||||
Off=
|
||||
On=
|
||||
@1 (owned by @2)=
|
||||
@1 Protected Chest=
|
||||
Selected Color: @1=
|
||||
Move existing to Chest=
|
||||
Move specific=
|
||||
Drop to move=
|
||||
Move all to Chest=
|
||||
Move all to Inventory=
|
||||
Send player put messages=
|
||||
Send player take messages=
|
||||
Send tube inject messages=
|
||||
Send tube pull messages=
|
||||
Send overflow messages=
|
||||
Auto-sort is On=
|
||||
Auto-sort is Off=
|
||||
Sort by Quantity=
|
||||
Sort by Type=
|
||||
Sort by Wear=
|
||||
Natural sort=
|
||||
Sort by Item=
|
|
@ -0,0 +1,61 @@
|
|||
# textdomain: technic_chests
|
||||
|
||||
# technic_chests translation template
|
||||
|
||||
@1 Chest=Cofre de @1
|
||||
@1 Locked Chest=Cofre de @1 Bloqueado
|
||||
@1 Locked Chest (owned by @2)=Cofre de @1 Bloqueado (propiedad de @2)
|
||||
Color Filter: @1=Filtro por Color: @1
|
||||
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 @1=El orden Automático esta @1
|
||||
Off=Apagado
|
||||
On=Encendido
|
||||
@1 (owned by @2)=
|
||||
@1 Protected Chest=
|
||||
Selected Color: @1=
|
||||
Move existing to Chest=
|
||||
Move specific=
|
||||
Drop to move=
|
||||
Move all to Chest=
|
||||
Move all to Inventory=
|
||||
Send player put messages=
|
||||
Send player take messages=
|
||||
Send tube inject messages=
|
||||
Send tube pull messages=
|
||||
Send overflow messages=
|
||||
Auto-sort is On=
|
||||
Auto-sort is Off=
|
||||
Sort by Quantity=
|
||||
Sort by Type=
|
||||
Sort by Wear=
|
||||
Natural sort=
|
||||
Sort by Item=
|
|
@ -0,0 +1,61 @@
|
|||
# textdomain: technic_chests
|
||||
|
||||
# technic_chests translation template
|
||||
|
||||
@1 Chest=Coffre en @1
|
||||
@1 Locked Chest=Coffre verrouillé en @1
|
||||
@1 Locked Chest (owned by @2)=Coffre verrouillé en @1 (appartient à @2)
|
||||
Color Filter: @1=Filtre couleur : @1
|
||||
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 @1=Tri automatique @1
|
||||
Off=désactivé
|
||||
On=activé
|
||||
@1 (owned by @2)=
|
||||
@1 Protected Chest=
|
||||
Selected Color: @1=
|
||||
Move existing to Chest=
|
||||
Move specific=
|
||||
Drop to move=
|
||||
Move all to Chest=
|
||||
Move all to Inventory=
|
||||
Send player put messages=
|
||||
Send player take messages=
|
||||
Send tube inject messages=
|
||||
Send tube pull messages=
|
||||
Send overflow messages=
|
||||
Auto-sort is On=
|
||||
Auto-sort is Off=
|
||||
Sort by Quantity=
|
||||
Sort by Type=
|
||||
Sort by Wear=
|
||||
Natural sort=
|
||||
Sort by Item=
|
|
@ -0,0 +1,43 @@
|
|||
# textdomain: technic_chests
|
||||
|
||||
# technic_chests japanese translation
|
||||
# technic_chestsの日本語への翻訳
|
||||
# by damiemk
|
||||
|
||||
@1 Chest=@1 のチェスト
|
||||
@1 Locked Chest=@1 ロックされたチェスト
|
||||
@1 Locked Chest (owned by @2)=@1 のロックされたチェスト (@2 が所有)
|
||||
Color Filter: @1=カラーフィルター: @1
|
||||
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 @1=自動組織が @1 になっている
|
||||
Off=オフ
|
||||
On=オン
|
|
@ -0,0 +1,63 @@
|
|||
# textdomain: technic_chests
|
||||
|
||||
# Polish Translation for technic_chests
|
||||
# Polskie tłumaczenie technic_chests
|
||||
# by mat9117
|
||||
|
||||
@1 Chest=@1 Skrzynia
|
||||
@1 Locked Chest=@1 Zamknięta skrzynia
|
||||
@1 Locked Chest (owned by @2)=@1 Zamknięta skrzynia (należy do @2)
|
||||
Color Filter: @1=Filtr kolorów: @1
|
||||
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 @1=Autosortowanie jest @1
|
||||
Off=Wyłaczone
|
||||
On=Włączone
|
||||
@1 (owned by @2)=
|
||||
@1 Protected Chest=
|
||||
Selected Color: @1=
|
||||
Move existing to Chest=
|
||||
Move specific=
|
||||
Drop to move=
|
||||
Move all to Chest=
|
||||
Move all to Inventory=
|
||||
Send player put messages=
|
||||
Send player take messages=
|
||||
Send tube inject messages=
|
||||
Send tube pull messages=
|
||||
Send overflow messages=
|
||||
Auto-sort is On=
|
||||
Auto-sort is Off=
|
||||
Sort by Quantity=
|
||||
Sort by Type=
|
||||
Sort by Wear=
|
||||
Natural sort=
|
||||
Sort by Item=
|
|
@ -0,0 +1,63 @@
|
|||
# textdomain: technic_chests
|
||||
|
||||
# Braziliam portuguese translation for technic_chests
|
||||
# Tradução portuguesa brasileira para technic_chests
|
||||
# By Sires
|
||||
|
||||
@1 Chest=Baú @1
|
||||
@1 Locked Chest=Baú Trancado @1
|
||||
@1 Locked Chest (owned by @2)=Baú Trancado @1 (pertence a/à @2)
|
||||
Color Filter: @1=Filtro de Cor: @1
|
||||
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 @1=Auto-ordenação está @1
|
||||
Off=Desligada
|
||||
On=Ligada
|
||||
@1 (owned by @2)=
|
||||
@1 Protected Chest=
|
||||
Selected Color: @1=
|
||||
Move existing to Chest=
|
||||
Move specific=
|
||||
Drop to move=
|
||||
Move all to Chest=
|
||||
Move all to Inventory=
|
||||
Send player put messages=
|
||||
Send player take messages=
|
||||
Send tube inject messages=
|
||||
Send tube pull messages=
|
||||
Send overflow messages=
|
||||
Auto-sort is On=
|
||||
Auto-sort is Off=
|
||||
Sort by Quantity=
|
||||
Sort by Type=
|
||||
Sort by Wear=
|
||||
Natural sort=
|
||||
Sort by Item=
|
|
@ -0,0 +1,63 @@
|
|||
# textdomain: technic_chests
|
||||
|
||||
# Turkish translation
|
||||
# mahmutelmas06@hotmail.com
|
||||
# Türkçe çeviri
|
||||
|
||||
@1 Chest=@1 Sandık
|
||||
@1 Locked Chest=@1 Kilitli sandık
|
||||
@1 Locked Chest (owned by @2)=@1 Kilitli sandık (Sahibi @2)
|
||||
Color Filter: @1=Renk süzgeci: @1
|
||||
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 @1=Otomatik sıralama @1
|
||||
Off=Kapalı
|
||||
On=Açık
|
||||
@1 (owned by @2)=
|
||||
@1 Protected Chest=
|
||||
Selected Color: @1=
|
||||
Move existing to Chest=
|
||||
Move specific=
|
||||
Drop to move=
|
||||
Move all to Chest=
|
||||
Move all to Inventory=
|
||||
Send player put messages=
|
||||
Send player take messages=
|
||||
Send tube inject messages=
|
||||
Send tube pull messages=
|
||||
Send overflow messages=
|
||||
Auto-sort is On=
|
||||
Auto-sort is Off=
|
||||
Sort by Quantity=
|
||||
Sort by Type=
|
||||
Sort by Wear=
|
||||
Natural sort=
|
||||
Sort by Item=
|
|
@ -0,0 +1,53 @@
|
|||
# textdomain: technic_chests
|
||||
|
||||
@1 Chest=@1箱子
|
||||
@1 Locked Chest=上锁的@1箱子
|
||||
@1 Locked Chest (owned by @2)=上锁的@1锁箱子(归@2所有)
|
||||
Color Filter: @1=颜色筛选器:@1
|
||||
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 @1=自动排序为@1
|
||||
Off=关
|
||||
On=打开
|
||||
@1 (owned by @2)=
|
||||
@1 Protected Chest=
|
||||
Selected Color: @1=
|
||||
Move existing to Chest=
|
||||
Move specific=
|
||||
Drop to move=
|
||||
Move all to Chest=
|
||||
Move all to Inventory=
|
||||
Send player put messages=
|
||||
Send player take messages=
|
||||
Send tube inject messages=
|
||||
Send tube pull messages=
|
||||
Send overflow messages=
|
||||
Auto-sort is On=
|
||||
Auto-sort is Off=
|
||||
Sort by Quantity=
|
||||
Sort by Type=
|
||||
Sort by Wear=
|
||||
Natural sort=
|
||||
Sort by Item=
|
61
mods/technic_plus_beta/technic_chests/locale/template.txt
Normal file
|
@ -0,0 +1,61 @@
|
|||
# textdomain: technic_chests
|
||||
|
||||
# technic_chests translation template
|
||||
|
||||
@1 Chest=
|
||||
@1 Locked Chest=
|
||||
@1 Locked Chest (owned by @2)=
|
||||
Color Filter: @1=
|
||||
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 @1=
|
||||
Off=
|
||||
On=
|
||||
@1 (owned by @2)=
|
||||
@1 Protected Chest=
|
||||
Selected Color: @1=
|
||||
Move existing to Chest=
|
||||
Move specific=
|
||||
Drop to move=
|
||||
Move all to Chest=
|
||||
Move all to Inventory=
|
||||
Send player put messages=
|
||||
Send player take messages=
|
||||
Send tube inject messages=
|
||||
Send tube pull messages=
|
||||
Send overflow messages=
|
||||
Auto-sort is On=
|
||||
Auto-sort is Off=
|
||||
Sort by Quantity=
|
||||
Sort by Type=
|
||||
Sort by Wear=
|
||||
Natural sort=
|
||||
Sort by Item=
|
3
mods/technic_plus_beta/technic_chests/mod.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
name = technic_chests
|
||||
depends = default, basic_materials
|
||||
optional_depends = technic, technic_worldgen, moreores, pipeworks, protector, digilines
|
240
mods/technic_plus_beta/technic_chests/register.lua
Normal file
|
@ -0,0 +1,240 @@
|
|||
|
||||
local S = minetest.get_translator(minetest.get_current_modname())
|
||||
|
||||
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(data, color)
|
||||
local tiles = data.tiles and table.copy(data.tiles) or {
|
||||
data.texture_prefix.."_top.png"..tube_entry,
|
||||
data.texture_prefix.."_top.png"..tube_entry,
|
||||
data.texture_prefix.."_side.png"..tube_entry,
|
||||
data.texture_prefix.."_side.png"..tube_entry,
|
||||
data.texture_prefix.."_side.png"..tube_entry,
|
||||
data.texture_prefix.."_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].."^"..data.texture_prefix.."_lock_overlay.png"
|
||||
elseif data.protected then
|
||||
tiles[6] = tiles[6]..protector_overlay
|
||||
end
|
||||
return tiles
|
||||
end
|
||||
|
||||
function technic.chests.register_chest(nodename, data)
|
||||
assert(data.tiles or data.texture_prefix, "technic.chests.register_chest: tiles or texture_prefix required")
|
||||
assert(data.description, "technic.chests.register_chest: description required")
|
||||
local colon
|
||||
colon, nodename = nodename:match("^(:?)(.+)")
|
||||
|
||||
if data.digilines and not has_digilines then
|
||||
data.digilines = nil
|
||||
end
|
||||
|
||||
data.formspec = technic.chests.get_formspec(data)
|
||||
local def = {
|
||||
description = data.description,
|
||||
tiles = data.tiles or get_tiles(data),
|
||||
paramtype2 = "facedir",
|
||||
is_ground_content = false,
|
||||
legacy_facedir_simple = true,
|
||||
groups = node_groups,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
drop = nodename,
|
||||
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("@1 (owned by @2)", data.description, 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_fast_move(pos, player:get_player_name(), "take", moved_items)
|
||||
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_fast_move(pos, player:get_player_name(), "put", moved_items)
|
||||
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] = nodename
|
||||
minetest.remove_node(pos)
|
||||
return drops
|
||||
end,
|
||||
on_receive_fields = technic.chests.get_receive_fields(nodename, 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(colon..nodename, 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(data, i)
|
||||
minetest.register_node(colon..nodename.."_"..technic.chests.colors[i][1], colordef)
|
||||
end
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 212 B |
After Width: | Height: | Size: 100 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 101 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 101 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 97 B |
After Width: | Height: | Size: 114 B |
After Width: | Height: | Size: 91 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 88 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 3.1 KiB |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 89 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 89 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 105 B |
After Width: | Height: | Size: 480 B |
After Width: | Height: | Size: 111 B |
After Width: | Height: | Size: 446 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: 705 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 |