Re: Transferring Inventory
You can try this function to get inventory and clear it in source actor, and transfering items to another actor is trivial I guess
Code:
-----------------------------------------------------------------------------------------
-- Get table with inventory of actor, inventory cleared as a result
-----------------------------------------------------------------------------------------
function CF_GetInventory(actor)
--print("GetInventory")
local inventory = {}
local classes = {}
if MovableMan:IsActor(actor) then
if actor.ClassName == "AHuman" then
local human = ToAHuman(actor);
if human ~= nil then
if human.EquippedItem ~= nil then
inventory[#inventory + 1] = human.EquippedItem.PresetName;
classes[#classes + 1] = human.EquippedItem.ClassName;
end
human:UnequipBGArm()
end
end
if not actor:IsInventoryEmpty() then
local enough = false;
while not enough do
local weap = nil;
weap = actor:SwapNextInventory(weap, true);
if weap == nil then
enough = true;
else
inventory[#inventory + 1] = weap.PresetName;
classes[#classes + 1] = weap.ClassName;
end
end
end
else
--print("Actor: ")
--print(actor);
end
return inventory, classes;
end