diff --git a/stack.lua b/stack.lua index c9fa639..4862cb8 100644 --- a/stack.lua +++ b/stack.lua @@ -108,7 +108,14 @@ function Aux.stack.onupdate() local next_slot = state.other_slots() local empty_slot = find_empty_slot() - if next_slot then + if empty_slot and stack_size(state.target_slot) > state.target_size then + move_item( + state.target_slot, + empty_slot, + stack_size(state.target_slot) - state.target_size + ) + return + elseif next_slot then if stack_size(state.target_slot) < state.target_size then move_item( next_slot, @@ -124,13 +131,6 @@ function Aux.stack.onupdate() ) return end - elseif empty_slot and stack_size(state.target_slot) > state.target_size then - move_item( - state.target_slot, - empty_slot, - stack_size(state.target_slot) - state.target_size - ) - return end Aux.stack.stop() @@ -184,4 +184,4 @@ function Aux.stack.start(name, size, callback) state.target_slot = find_charges_item_slot(name, size) Aux.stack.stop() end -end \ No newline at end of file +end