michaelm75au -> RE: New 15.1 Lua (3/21/2019 9:23:11 AM)
|
Handle multiple fuel sources on a unit local plane = ScenEdit_GetUnit({name='fight #1', guid='30184f60-768b-4e2e-847d-19c97289357e'}) print(plane.fuels) -- all sources of fuel (main tank and a drop tank) local fuel = plane.fuel print 'Start' print(fuel) for i, tank in ipairs(plane.fuels) do print("Tank #" .. i) print(tank) end print 'Set ' -- overall fuel level across all sources with the requested fuel type plane = ScenEdit_SetUnit({name='fight #1', guid='30184f60-768b-4e2e-847d-19c97289357e', fuel={{2001,800}} }) print(plane.fuel) for i, tank in ipairs(plane.fuels) do print("Tank #" .. i) print(tank) end print(plane.fuels) -- whats left -------------- And using the wrapper to spread the new fuel level local plane = ScenEdit_GetUnit({name='fight #1', guid='30184f60-768b-4e2e-847d-19c97289357e'}) print( plane.fuels) local f = plane.fuel f[2001].current = 800 plane.fuel = f print( plane.fuels)
|
|
|
|