Improve auto-/supplier- crafting crafting inventory usability by allowing moving and replacement
This commit is contained in:
parent
030571b164
commit
7493f657d9
@ -87,8 +87,12 @@ local function autocrafter_allow_metadata_inv_put(pos, listname, index, stack, p
|
||||
if listname == INV_CRAFT then
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local st = inv:get_stack(listname, index)
|
||||
st:add_item(stack)
|
||||
inv:set_stack(listname, index, st)
|
||||
if st:get_name() == stack:get_name() then
|
||||
st:add_item(stack)
|
||||
inv:set_stack(listname, index, st)
|
||||
else
|
||||
inv:set_stack(listname, index, stack)
|
||||
end
|
||||
update_craft_output(inv)
|
||||
return 0
|
||||
end
|
||||
@ -112,11 +116,13 @@ end
|
||||
local function autocrafter_allow_metadata_inv_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then return 0 end
|
||||
if from_list == INV_DST and to_list == INV_SRC then return count end
|
||||
if from_list == INV_CRAFT and to_list == INV_CRAFT then return count end
|
||||
return 0
|
||||
end
|
||||
|
||||
local function autocrafter_on_inv_change(pos)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
update_craft_output(inv)
|
||||
logistica.start_node_timer(pos, TIMER_SHORT)
|
||||
end
|
||||
|
||||
|
@ -82,8 +82,12 @@ local function allow_craftsup_storage_inv_put(pos, listname, index, stack, playe
|
||||
if listname == INV_CRAFT then
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local st = inv:get_stack(listname, index)
|
||||
st:add_item(stack)
|
||||
inv:set_stack(listname, index, st)
|
||||
if st:get_name() == stack:get_name() then
|
||||
st:add_item(stack)
|
||||
inv:set_stack(listname, index, st)
|
||||
else
|
||||
inv:set_stack(listname, index, stack)
|
||||
end
|
||||
update_craft_output(minetest.get_meta(pos):get_inventory())
|
||||
logistica.update_cache_at_pos(pos, LOG_CACHE_SUPPLIER)
|
||||
end
|
||||
@ -108,6 +112,7 @@ local function allow_craftsup_inv_take(pos, listname, index, stack, player)
|
||||
end
|
||||
|
||||
local function allow_craftsup_inv_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
if from_list == INV_CRAFT and to_list == INV_CRAFT then return count end
|
||||
return 0
|
||||
end
|
||||
|
||||
@ -121,6 +126,11 @@ local function on_craftsup_inventory_take(pos, listname, index, stack, player)
|
||||
logistica.update_cache_at_pos(pos, LOG_CACHE_SUPPLIER)
|
||||
end
|
||||
|
||||
local function on_craftsup_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
|
||||
update_craft_output(minetest.get_meta(pos):get_inventory())
|
||||
logistica.update_cache_at_pos(pos, LOG_CACHE_SUPPLIER)
|
||||
end
|
||||
|
||||
local function can_dig_craftsup(pos, player)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local main = logistica.get_list(inv, INV_MAIN)
|
||||
@ -176,6 +186,7 @@ function logistica.register_crafting_supplier(desc, name, tiles)
|
||||
allow_metadata_inventory_move = allow_craftsup_inv_move,
|
||||
on_metadata_inventory_put = on_craftsup_inventory_put,
|
||||
on_metadata_inventory_take = on_craftsup_inventory_take,
|
||||
on_metadata_inventory_move = on_craftsup_inventory_move,
|
||||
can_dig = can_dig_craftsup,
|
||||
logistica = {
|
||||
on_power = on_craftsup_power,
|
||||
|
Loading…
x
Reference in New Issue
Block a user