LUA Cargo 2.0 Ground and Mobile Units Programming
Posted: Tue Feb 28, 2023 10:18 pm
I have a question about LUA coding for new Ground and Mobile Units. I have previous scenarios that I created that load cargo at a base or on a ship or plane. The function that I wrote looks like this:
function createCargoAtBase(base,num,db)
-- creates cargo onto a base or on an aircraft at the base, ex passing 6,357 creates six 7.62 MG Rfiles at the base passed
-- pass the base or object that the cargo is to be created at, number of cargo to create and cargo dbid
local u = ScenEdit_GetUnit({name=base})
ScenEdit_UpdateUnitCargo({guid=u.guid, mode='add_cargo', cargo={{num,db}}})
return
end
If I use this it creates a cargo type of "mount", which after some investigation I found that "type" = 1 and after creating ground units and mobile units manually I have found that
Type 1 = Mount
Type 2 = Ground Unit
Type 3 = Mobile Facility
So far after numerous tries, trial and error, guessing on syntax, etc, I cannot get the command to work to add a type = 2 or type = 3, For instance, if I wanted to load Ground Unit ID 32 Light Utility Vehicle onto a ship with LUA, how to I specify it is type 2? It always comes out type 1. I can find no examples or new documentation for this.
Thanks in advance,
Steve
function createCargoAtBase(base,num,db)
-- creates cargo onto a base or on an aircraft at the base, ex passing 6,357 creates six 7.62 MG Rfiles at the base passed
-- pass the base or object that the cargo is to be created at, number of cargo to create and cargo dbid
local u = ScenEdit_GetUnit({name=base})
ScenEdit_UpdateUnitCargo({guid=u.guid, mode='add_cargo', cargo={{num,db}}})
return
end
If I use this it creates a cargo type of "mount", which after some investigation I found that "type" = 1 and after creating ground units and mobile units manually I have found that
Type 1 = Mount
Type 2 = Ground Unit
Type 3 = Mobile Facility
So far after numerous tries, trial and error, guessing on syntax, etc, I cannot get the command to work to add a type = 2 or type = 3, For instance, if I wanted to load Ground Unit ID 32 Light Utility Vehicle onto a ship with LUA, how to I specify it is type 2? It always comes out type 1. I can find no examples or new documentation for this.
Thanks in advance,
Steve