Page 1 of 1
Lua Q: Aircraft availability change
Posted: Fri Apr 26, 2019 6:23 am
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.
RE: Lua Q: Aircraft availability change
Posted: Fri Apr 26, 2019 7:11 am
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
RE: Lua Q: Aircraft availability change
Posted: Fri Apr 26, 2019 1:10 pm
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})
RE: Lua Q: Aircraft availability change
Posted: Wed May 01, 2019 11:15 am
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.
RE: Lua Q: Aircraft availability change
Posted: Wed May 01, 2019 5:59 pm
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})