Lua Q: Aircraft availability change

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
User avatar
Sardaukar
Posts: 12747
Joined: Wed Nov 28, 2001 10:00 am
Location: Finland/Israel

Lua Q: Aircraft availability change

Post by Sardaukar »

I am total newbie with Lu...so have a questin:

Is it possible via Lua to change a/c randomly from Maintenance to Reserve/Ready?

It'd make those a/c potentially usable instead of pure targets. It'd resemble maintenance efforts or ground crews. Randomized with min. delay would be great.
"To meaningless French Idealism, Liberty, Fraternity and Equality...we answer with German Realism, Infantry, Cavalry and Artillery" -Prince von Bülov, 1870-

Image
User avatar
Gunner98
Posts: 5978
Joined: Fri Apr 29, 2005 12:49 am
Location: The Great White North!
Contact:

RE: Lua Q: Aircraft availability change

Post by Gunner98 »

I'm certainly not one of the wizards with Lua but short answer is - yes you can. The best guide for Lua is here: http://commandlua.github.io/index.html

You can randomize a repeatable event. Triggered on 'regular time' and the action would be:

ScenEdit_SetLoadout (loadoutinfo)

If you go to the site and then go to 'Loadoutinfo' you will find the 5 things you need to consider in the command:

1. UnitName: this will be the tricky bit
2. LoadoutID: you find this in the DB entry far right hand column for loadouts (Reserve is universally '3' and Maint is '4' I think)
3. TimeToReady_Minutes: this might be '0' or whatever you want
4. IgnoreMagazines: this is probably one you would just omit
5. ExcludeOptionalWeapons: omit

So if it was only one unit in question:

ScenEdit_SetLoadout (UnitName= Arco #1, LoadoutID= 3, TimeToReady_Minutes=0)

You may be able to shortcut this as:

ScenEdit_SetLoadout (Arco #1, 3, 0) (or even omit the time variable)

But I find each command might be slightly different so you need to experiment.

Making this adaptable to fit multiple units is the trick and I'm not the best to talk about that. This is not a difficult one though.

B
Check out our novel, Northern Fury: H-Hour!: http://northernfury.us/
And our blog: http://northernfury.us/blog/post2/
Twitter: @NorthernFury94 or Facebook https://www.facebook.com/northernfury/
Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

RE: Lua Q: Aircraft availability change

Post by Whicker »

ScenEdit_SetLoadout (UnitName= Arco #1, LoadoutID= 3, TimeToReady_Minutes=0)

- needs to be in curlies inside the parens as it is a table
- strings are always in quotes - double or single doesn't matter. Numbers and variables are not in quotes

ScenEdit_SetLoadout ({UnitName= 'Arco #1', LoadoutID= 3, TimeToReady_Minutes=0})

User avatar
Sharana
Posts: 347
Joined: Wed Feb 03, 2016 9:58 pm

RE: Lua Q: Aircraft availability change

Post by Sharana »

As for the random time needed I usually use it like this:

ScenEdit_SetLoadout({unitname='253sq #466', LoadoutID = 3, TimeToReady_Minutes = math.random(60,180), IgnoreMagazines='false'})

The time is in minutes, so in this example the unit will get "reserve" status at some point between 1 and 3 hours after the script gets activated.
Image
User avatar
SeaQueen
Posts: 1436
Joined: Sat Apr 14, 2007 4:20 am
Location: Washington D.C.

RE: Lua Q: Aircraft availability change

Post by SeaQueen »

Is it possible via Lua to change a/c randomly from Maintenance to Reserve/Ready?

Yes. Use the script described here:

tm.asp?m=4499127

but change the line

Code: Select all

 ScenEdit_SetLoadout({UnitName=v, LoadoutID=tonumber(defaultLoadouts[w.dbid]), IgnoreMagazines=true, TimeToReady_Minutes=0}) 
 

to read

Code: Select all

 ScenEdit_SetLoadout({UnitName=v, LoadoutID=3, IgnoreMagazines=true, TimeToReady_Minutes=0}) 
 
Post Reply

Return to “Lua Legion”