Code: Select all
---@param source LuaItemStack
---@param destination LuaItemStack
---@param count uint
function split_stack(source, destination, count)
if count >= source.count then
return destination.transfer_stack(source)
end
source.count = source.count - count
return destination.transfer_stack{name=source.name, count=count}
end
I'm hoping to have this simplified into a LuaItemStack#split_stack function that works like transfer_stack but allows a quantity to be specified. Alternatively, just add a "count" parameter to LuaItemStack#transfer_stack that defaults to "the entire stack" if not passed.