New 15.1 Lua (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


michaelm75au -> New 15.1 Lua (3/21/2019 8:46:18 AM)

I thought I might just show examples of some of the commands introduced with 15.1...and check CommandLua at same time [:D]. This might take a few days.
--
Sample scenario run commands on




michaelm75au -> RE: New 15.1 Lua (3/21/2019 8:51:30 AM)

Play a sound effect from the sound\effects folder
ScenEdit_PlaySound('airplane_takeoff.mp3')

==============
Create a scenario attachment as a sound file and use it from AttachmentRepo
ScenEdit_UseAttachment('d86f4e24-7af0-48e8-ae1b-a02f574ce90e')

==============




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)




michaelm75au -> RE: New 15.1 Lua (3/22/2019 8:31:11 AM)

Using export to create an INST file in the normal folder (ImportExport)
ScenEdit_ExportInst('sidea', {'9506a165-6e44-40dd-b721-f9c07e056bdb'}, {filename='myCVBG.inst',name='CVBG'})

And using import to retrieve it
ScenEdit_DeleteUnit({name='CVN BG', guid='9506a165-6e44-40dd-b721-f9c07e056bdb'},true)
ScenEdit_ImportInst('sidea', 'myCVBG.inst')




michaelm75au -> RE: New 15.1 Lua (3/22/2019 8:52:21 AM)

Updating unit in game from a INI
ScenEdit_UpdateUnit({guid='c866539a-664c-48b2-88e3-be8e32514320',mode='delta', file='local delta.ini'})

Sample INI




michaelm75au -> RE: New 15.1 Lua (3/24/2019 2:13:36 AM)

Display a message, and set the 'jump' location.
ScenEdit_SpecialMessage('sidea','Life raft' ,{latitude='33.8495760280169', longitude='136.796207690362'})




michaelm75au -> RE: New 15.1 Lua (3/24/2019 2:16:45 AM)

Shows a list of selected/highlighted units

local units = ScenEdit_SelectedUnits()
print(units)
{ units = { [1] = { name = 'fight #1', guid = '30184f60-768b-4e2e-847d-19c97289357e' }, [2] = { name = 'Tanker #1', guid = '1530d502-69b2-4fa6-9145-c1f55dd39701' }, [3] = { name = 'Tanker #2', guid = 'd5eedc59-2541-4b7a-b540-607e84e579f8' }, [4] = { name = 'Looking #2', guid = '2cd64757-1b66-4609-ad56-df41bee652e5' } } }




michaelm75au -> RE: New 15.1 Lua (3/31/2019 5:54:07 AM)

Pass some data from scenario to scenario in a campaign.

The attached file has a campaign and 2 scenarios.
Load the campaign.
The first scenario has an action that sets a key to 150.
The second scenario has an action that will read the the passed key and show it.
Just cancel the campaign after the second scenario.

Note that playing in standalone mode might cause an error if you trying to use/save a 'campaign' key. Designers should cater for this.

--
I can't see a Lua method that shows if the scenario is in Campaign mode or not. One way to test could be to try saving a key value in campaign mode; you should get back an error if it is not in that mode.
Also note that this should not be abused. Putting too much into the campaign key store might cause performance/memory issues.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.84375