-
-
Save octacian/3db609143ada1160e761775b6ec376d9 to your computer and use it in GitHub Desktop.
ME function to move the contents of one inventory into another
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- [function] Move items from inv to inv | |
function microexpansion.move_inv(inv1, inv2) | |
local finv, tinv = inv1.inv, inv2.inv | |
local fname, tname = inv1.name, inv2.name | |
for i,v in ipairs(finv:get_list(fname) or {}) do | |
if tinv and tinv:room_for_item(tname, v) then | |
local leftover = tinv:add_item( tname, v ); | |
finv:remove_item( fname, v ); | |
if leftover and not( leftover:is_empty() ) then | |
finv:add_item( fname, v ); | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment