end
local function get_receive_fields(name, data)
- if not data.sort and not data.autosort and not data.infotext and not data.color then
- return nil
- end
local lname = name:lower()
return function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
end
-function technic.chests:register(name, data)
+function technic.chests:definition(name, data)
local lname = name:lower()
name = S(name)
def.allow_metadata_inventory_put = self.inv_put
def.allow_metadata_inventory_take = self.inv_take
end
+ return def
+end
- local nn = "technic:"..lname..(data.locked and "_locked" or "").."_chest"
+function technic.chests:register(name, data)
+ local def = technic.chests:definition(name, data)
+ local nn = "technic:"..name:lower()..(data.locked and "_locked" or "").."_chest"
minetest.register_node(":"..nn, def)
if data.color then
- front[3] = front[2]
+ local mk_front
+ if string.find(def.tiles[6], "%^") then
+ mk_front = function (overlay) return def.tiles[6]:gsub("%^", "^"..overlay.."^") end
+ else
+ mk_front = function (overlay) return def.tiles[6].."^"..overlay end
+ end
for i = 1, 15 do
local postfix = colorid_to_postfix(i)
local colordef = {}
end
colordef.drop = nn
colordef.groups = self.groups_noinv
- front[2] = "technic_chest_overlay"..postfix..".png"
- colordef.tiles[6] = table.concat(front, "^")
+ colordef.tiles = { def.tiles[1], def.tiles[2], def.tiles[3], def.tiles[4], def.tiles[5], mk_front("technic_chest_overlay"..postfix..".png") }
minetest.register_node(":"..nn..postfix, colordef)
end
end
-local S
-if intllib then
- S = intllib.Getter()
-else
- S = function(s) return s end
-end
-
+local udef = technic.chests:definition("Wooden", {
+ width = 8,
+ height = 4,
+ sort = false,
+ autosort = false,
+ infotext = false,
+ color = false,
+ locked = false,
+})
+local uudef = {
+ groups = udef.groups,
+ tube = udef.tube,
+ on_construct = udef.on_construct,
+ can_dig = udef.can_dig,
+ on_receive_fields = udef.on_receive_fields,
+ on_metadata_inventory_move = udef.on_metadata_inventory_move,
+ on_metadata_inventory_put = udef.on_metadata_inventory_put,
+ on_metadata_inventory_take = udef.on_metadata_inventory_take,
+}
if minetest.registered_nodes["default:chest"].description == "Chest" then
- minetest.override_item("default:chest", { description = S("%s Chest"):format(S("Wooden")) })
+ uudef.description = udef.description
end
+minetest.override_item("default:chest", uudef)
+local ldef = technic.chests:definition("Wooden", {
+ width = 8,
+ height = 4,
+ sort = false,
+ autosort = false,
+ infotext = false,
+ color = false,
+ locked = true,
+})
+local lldef = {
+ groups = ldef.groups,
+ tube = ldef.tube,
+ after_place_node = ldef.after_place_node,
+ on_construct = ldef.on_construct,
+ can_dig = ldef.can_dig,
+ on_receive_fields = ldef.on_receive_fields,
+ allow_metadata_inventory_move = ldef.allow_metadata_inventory_move,
+ allow_metadata_inventory_put = ldef.allow_metadata_inventory_put,
+ allow_metadata_inventory_take = ldef.allow_metadata_inventory_take,
+ on_metadata_inventory_move = ldef.on_metadata_inventory_move,
+ on_metadata_inventory_put = ldef.on_metadata_inventory_put,
+ on_metadata_inventory_take = ldef.on_metadata_inventory_take,
+}
if minetest.registered_nodes["default:chest_locked"].description == "Locked Chest" then
- minetest.override_item("default:chest_locked", { description = S("%s Locked Chest"):format(S("Wooden")) })
+ lldef.description = ldef.description
end
+minetest.override_item("default:chest_locked", lldef)