Change the item add function
This commit is contained in:
parent
e1a570d245
commit
cce617255a
@ -105,12 +105,10 @@ holostorage.server_inventory = {
|
|||||||
function system:add_item(abs, stack)
|
function system:add_item(abs, stack)
|
||||||
if not stack then stack = abs end
|
if not stack then stack = abs end
|
||||||
local leftover = nil
|
local leftover = nil
|
||||||
for i,stc in pairs(system.stacks) do
|
local first_empty_index = system:first_empty_index()
|
||||||
if not stc or stc:is_empty() then
|
local added = false
|
||||||
system[i] = stack
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
|
for i, stc in pairs(system.stacks) do
|
||||||
if stc:get_name() == stack:get_name() and stc:get_meta() == stack:get_meta() then
|
if stc:get_name() == stack:get_name() and stc:get_meta() == stack:get_meta() then
|
||||||
if stc:get_count() == stack:get_stack_max() then
|
if stc:get_count() == stack:get_stack_max() then
|
||||||
break
|
break
|
||||||
@ -120,11 +118,14 @@ holostorage.server_inventory = {
|
|||||||
if leftover and not leftover:is_empty() and system:room_for_item(leftover) then
|
if leftover and not leftover:is_empty() and system:room_for_item(leftover) then
|
||||||
leftover = system:add_item(leftover)
|
leftover = system:add_item(leftover)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
|
added = true
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if added then return leftover end
|
||||||
|
|
||||||
if not leftover then
|
if not leftover then
|
||||||
system.stacks[system:first_empty_index()] = stack
|
system.stacks[system:first_empty_index()] = stack
|
||||||
leftover = ItemStack(nil)
|
leftover = ItemStack(nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user