ScenEdit_UpdateUnitCargo ( table )

This function Updates the cargo space on a unit.
By default, this treats the cargo type as 'mount' as per the original cargo V1 specifications.
As this function also calls ScenEdit_SetUnit(), additional parameters for that function may also be passed to this function.

Parameters

  • table { }
    • guid = string The GUID of the unit
    • mode = value 'add_cargo', 'remove_cargo' The action mode to perform
    • cargo = { } of multiple cargo to affect
      • string Cargo GUID - treated as one unit to act on
      • or
      • { } of number Cargo database id (DBID) and is treated as one unit to act on
      • or
      • { } of
        • number Number to act on
        • number Cargo DBID to affect
        Note the order of 'number to affect' and 'DBID'
      • or
      • { } of
        • number Number to act on
        • number Cargo DBID to affect
        • value '1 = Mount', '2 = Ground', '3 = Facility', '4 = Container' Type of cargo

Returns

Unit The updated unit object

Example
ScenEdit_UpdateUnitCargo( { guid='2cd64757-1b66-4609-ad56-df41bee652e5', mode='add_cargo', cargo={ {5,752}, {700 } } } )
ScenEdit_UpdateUnitCargo( { guid='2cd64757-1b66-4609-ad56-df41bee652e5', mode='remove_cargo', cargo={'871aea14-d963-4052-a7fc-ed36e97bb732',{5,752} } } )
local u = ScenEdit_GetUnit({name='Yokosuka Building 14 (Large)', guid='29541903-93d0-436b-9f08-a4696f12a4fc'})
local a = ScenEdit_UpdateUnitCargo({guid='29541903-93d0-436b-9f08-a4696f12a4fc',mode='add_cargo',cargo={ {1,2541}, {3,361,3}, {4,7,4}, {2,246,2} } })
print(a.cargo)