mirror of
https://github.com/joe7575/techpack.git
synced 2024-12-25 07:02:31 +01:00
keep items w/ wear or items w/ max stacksize=1 from going into warehouses
This commit is contained in:
parent
49352529e4
commit
10409987f0
@ -7,7 +7,7 @@
|
||||
|
||||
LGPLv2.1+
|
||||
See LICENSE.txt for more information
|
||||
|
||||
|
||||
common.lua
|
||||
|
||||
]]--
|
||||
@ -36,24 +36,24 @@ local function formspec(self, pos, meta)
|
||||
"list[context;shift;1,0;7,1;]"..
|
||||
"image_button[9,0;1,1;techpack_warehouse_arrow_inv.png;shift;;true;false;]"..
|
||||
"image_button[8,0;1,1;".. self:get_state_button_image(meta) ..";state_button;]"..
|
||||
|
||||
|
||||
"image_button[0,1.4;1,1;techpack_warehouse_filter_inv.png;filter;;true;false;]"..
|
||||
"list[context;filter;1,1.4;8,1;]"..
|
||||
"image_button[9,1.4;1,1;techpack_warehouse_filter_inv.png;filter;;true;false;]"..
|
||||
|
||||
|
||||
"image_button[0,2.5;1,1;techpack_warehouse_inventory_inv.png;storage;;true;false;]"..
|
||||
"list[context;main;1,2.5;8,1;]"..
|
||||
"image_button[9,2.5;1,1;techpack_warehouse_inventory_inv.png;storage;;true;false;]"..
|
||||
|
||||
|
||||
"image_button[0,3.6;1,1;techpack_warehouse_input_inv.png;input;;true;false;]"..
|
||||
"list[context;input;1,3.6;8,1;]"..
|
||||
"image_button[9,3.6;1,1;techpack_warehouse_input_inv.png;input;;true;false;]"..
|
||||
|
||||
|
||||
"tooltip[shift;Pass-through storage for unconfigured items (turn on/off)]"..
|
||||
"tooltip[filter;Filter: To configure the 8 storages]"..
|
||||
"tooltip[storage;Storage: All items will be stored here]"..
|
||||
"tooltip[input;Input: Put items will be moved to the storage, if configured]"..
|
||||
|
||||
|
||||
"list[current_player;main;1,5.3;8,4;]"..
|
||||
"listring[context;shift]"..
|
||||
"listring[current_player;main]"..
|
||||
@ -64,12 +64,12 @@ local function move_to_main(pos, index)
|
||||
local inv = M(pos):get_inventory()
|
||||
local main_stack = inv:get_stack("main", index)
|
||||
local inp_stack = inv:get_stack("input", index)
|
||||
|
||||
|
||||
if inp_stack:get_name() ~= "" then
|
||||
local stack = ItemStack(inp_stack:get_name())
|
||||
stack:set_count(inp_stack:get_count() + main_stack:get_count())
|
||||
inp_stack:clear()
|
||||
|
||||
|
||||
inv:set_stack("main", index, stack)
|
||||
inv:set_stack("input", index, inp_stack)
|
||||
end
|
||||
@ -178,12 +178,12 @@ function techpack_warehouse.numbers_to_shift(self, meta, item)
|
||||
Cache[number][idx] = items:get_name()
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- determine number to shift
|
||||
local num_items = item:get_count()
|
||||
local inv_size = meta:get_int("inv_size")
|
||||
local inv = meta:get_inventory()
|
||||
|
||||
|
||||
for idx, name in ipairs(Cache[number]) do
|
||||
if item_name == name then
|
||||
local stack_size = inv:get_stack("main", idx):get_count()
|
||||
@ -206,6 +206,10 @@ end
|
||||
function techpack_warehouse.allow_metadata_inventory_put(self, pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
elseif stack:get_wear() ~= 0 then
|
||||
return 0
|
||||
elseif stack:get_stack_max() == 1 then
|
||||
return 0
|
||||
end
|
||||
local inv = M(pos):get_inventory()
|
||||
local main_stack = inv:get_stack("main", index)
|
||||
@ -275,7 +279,7 @@ function techpack_warehouse.after_place_node(self, pos, placer, itemstack)
|
||||
inv:set_size('main', 8)
|
||||
inv:set_size('input', 8)
|
||||
end
|
||||
|
||||
|
||||
function techpack_warehouse.on_timer(self, pos, elapsed)
|
||||
if tubelib.data_not_corrupted(pos) then
|
||||
local meta = M(pos)
|
||||
@ -292,7 +296,7 @@ function techpack_warehouse.on_timer(self, pos, elapsed)
|
||||
local stack = inv:get_stack("shift", idx)
|
||||
if stack:get_count() > 0 then
|
||||
if tubelib.push_items(pos, push_dir, stack, player_name) then
|
||||
-- The effort is needed here for the case the
|
||||
-- The effort is needed here for the case the
|
||||
-- pusher pushes into its own chest.
|
||||
local num = stack:get_count()
|
||||
stack = inv:get_stack("shift", idx)
|
||||
@ -308,12 +312,12 @@ function techpack_warehouse.on_timer(self, pos, elapsed)
|
||||
else
|
||||
self.State:idle(pos, meta)
|
||||
end
|
||||
|
||||
|
||||
return self.State:is_active(meta)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
|
||||
function techpack_warehouse.can_dig(self, pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
return inv:is_empty("main") and inv:is_empty("shift")
|
||||
|
Loading…
Reference in New Issue
Block a user