Spawn Loaded Transports

I'm trying to use this function to attach units to transports, but I seem to be doing something wrong.

ScenarioFramework.AttachUnitsToTransports(units, transports)

After running a script that spawns a transport, I've tried:

transport = spawnedunit ScenarioFramework.AttachUnitsToTransports({"xel0305", "uel0303"}, {transport})

Also Tried:
transports = aiBrain:GetListOfUnits(categories.xea0306, false)
units = {"xel0305", "uel0303"}
ScenarioFramework.AttachUnitsToTransports(units, transports)

And other combinations. The transport still spawns with no units attached.

The Trident mission spawns transports with units.

You must pass unit object instead of string.

“Be a yardstick of quality. Some people aren’t used to an environment where excellence is expected.”
— Steve Jobs.
My UI Mods
Support me

This is how it is done with Oxygen in my coop mission: https://github.com/4z0t/MapsCoopDev/blob/GW/maps/Test/Test1_script.lua#L70-L78

“Be a yardstick of quality. Some people aren’t used to an environment where excellence is expected.”
— Steve Jobs.
My UI Mods
Support me

@azath0th

Thanks for the information. I've read through your example, and also scoured github (and the scripts used in Survival Verses) and other LUA documentation, but I still haven't been able to make sense of what you mean of unit object. Is there an example of creating a unit object? I was under the impression that a table was an object, but that didn't work when I tried.

In your example you are using the unit id's in that function, its like saying you want to put someones name into a car instead of a person and wondering why they are not in the car.

What you would want to do is create the units first, for example. Actually I'm not sure how the units are being created but you get the idea.

local unit1 = armybrain:CreateUnitNearSpot('UEB0101', posX, posY)
local unit2 = armybrain:CreateUnitNearSpot('UEB0101', posX, posY)

ScenarioFramework.AttachUnitsToTransports({unit1, unit2}, {transport})

p.s just to clarify your confusion. The function takes a table of objects rather than the table being an object itself.

I got the transports loaded, and also got them to drop their units and fly off. Each transport has its own platoon of troops. I am trying to get the platoons to target specific units after being dropped. I've tried the following commands, but without luck:

CPlatoon:AttackTarget(Target, platoon) <-- Got the error "access to nonexistent global variable CPlatoon"
IssueAttack(platoon:GetPlatoonUnits(), Target) <-- No errors, script completed, but platoon did not attack the targeted unit.
PlatoonAttackClosestUnit(platoon) <-- Function from ScenarioPlatoonAI.lua, introduced an error "access to nonexistent global variable PlatoonAttackClosestUnit"

@rama

CPlatoon:AttackTarget(Target, platoon)

Needs to be the platoon object in question.

e.g platoon:AttackTarget(Target)

This is assuming that 'platoon' is the object for the platoon that came off the transport. and that 'Target' is the unit object for a target that you have already got via some other means.

@relentless

That worked perfect! Thanks!