summaryrefslogtreecommitdiff
path: root/technic_chests
diff options
context:
space:
mode:
Diffstat (limited to 'technic_chests')
-rw-r--r--technic_chests/register.lua32
-rw-r--r--technic_chests/wooden_chest.lua55
2 files changed, 7 insertions, 80 deletions
diff --git a/technic_chests/register.lua b/technic_chests/register.lua
index 0d5c767..61d49d3 100644
--- a/technic_chests/register.lua
+++ b/technic_chests/register.lua
@@ -137,38 +137,20 @@ local function sort_inventory(inv)
local m = st:get_metadata()
local k = string.format("%s %05d %s", n, w, m)
if not typecnt[k] then
- typecnt[k] = {
- name = n,
- wear = w,
- metadata = m,
- stack_max = st:get_stack_max(),
- count = 0,
- }
+ typecnt[k] = {st}
table.insert(typekeys, k)
+ else
+ table.insert(typecnt[k], st)
end
- typecnt[k].count = typecnt[k].count + st:get_count()
end
end
table.sort(typekeys)
- local outlist = {}
+ inv:set_list("main", {})
for _, k in ipairs(typekeys) do
- local tc = typecnt[k]
- while tc.count > 0 do
- local c = math.min(tc.count, tc.stack_max)
- table.insert(outlist, ItemStack({
- name = tc.name,
- wear = tc.wear,
- metadata = tc.metadata,
- count = c,
- }))
- tc.count = tc.count - c
+ for _, item in ipairs(typecnt[k]) do
+ inv:add_item("main", item)
end
end
- if #outlist > #inlist then return end
- while #outlist < #inlist do
- table.insert(outlist, ItemStack(nil))
- end
- inv:set_list("main", outlist)
end
local function get_receive_fields(name, data)
@@ -305,7 +287,7 @@ function technic.chests:definition(name, data)
on_receive_fields = get_receive_fields(name, data),
on_metadata_inventory_move = self.on_inv_move,
on_metadata_inventory_put = self.on_inv_put,
- on_metadata_inventory_take = self.on_inv_take,
+ on_metadata_inventory_take = self.on_inv_take,
on_blast = function(pos)
local drops = {}
default.get_inventory_drops(pos, "main", drops)
diff --git a/technic_chests/wooden_chest.lua b/technic_chests/wooden_chest.lua
deleted file mode 100644
index 120a318..0000000
--- a/technic_chests/wooden_chest.lua
+++ /dev/null
@@ -1,55 +0,0 @@
---[[
-
-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
- 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
- lldef.description = ldef.description
-end
-minetest.override_item("default:chest_locked", lldef)
-
---]]