Semi Unlimited - automated magazine and loadouts topping up

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Semi Unlimited - automated magazine and loadouts topping up

Post by KnightHawk75 »

So I recently saw another request for ability to have each side have separate unlimited mags.

Thing is with-in reason though you can mostly already accomplish this via LUA. Thing is it used to be a real pita due to quirks and other limitations. However most of those have been resolved over the last year in 1147.4x+ and ~1280.x and 1300.

So seeing this again prompted me to quickly built what I hope is useful for some of you who want to do that, at least in a form where you just have to tell the script(s), what you want and it'll handled the doing it part. This could be for selective unlimited on either side or just unit specific,etc. I could have built this where it just does every unit and mag on a side, but lets be real, that's almost always going to be overkill, even for 30day impossible ai scenes, and you homies doing those things already will know how to just adapt this to run through a side and call these functions according to your own need.

What I wanted was something that lua beginners could just kinda use... so long as they know how to copy and paste all code and just change lines in a table list at the top basically, where this list instructs what they want acted on, either generically or quite specifically down to a specific wpn_record. There is no fancy code here, in fact probably 60% of the lines are error handling, basic input validation, logging, and accounting. Two basic scripts, one for loadoutid package adding to unit mags, and one more flexible for unit mag topping up.

Most of how to use it is in the side briefing along with carry on sentences and probably some typos cause that's how I roll.. :D
But here is the sort of basic lists it'll process.

For specific loadouts you want added to units you tweak\add to the following sort of list:

Code: Select all

--name,guid,loadoutid,quanity required.
--don't forget to add the comma after new entries unless it's the very last in the list(even then leaving the comma it's fine).
local airbasesToFill = {
{name='SUA_1', guid='4FH7PU-0HMNDPRJL928I',loadoutid=26461, quantity=50,mydesc="f22 aim 260 loadout"}, 
{name='SUA_1', guid='4FH7PU-0HMNDPRJL928I',loadoutid=29716, quantity=50,mydesc="f18 aim 120D loadout"}, 
{name='SUA_2', guid='4FH7PU-0HMNDPRJL9A20',loadoutid=26461, quantity=50,mydesc="f22 aim 260 loadout"}, 
{name='SUA_2', guid='4FH7PU-0HMNDPRJL9A20',loadoutid=29716, quantity=50,mydesc="f18 aim 120D loadout"}
}

Yes, I can't help you come up with what loadoutid's you want, you're gonna have to do that process yourself for what you want\need, above is just a sample from the include demo scenes, yours could be hundreds long or 1 line.

Now for topping up existing mags on any unit you want, either trying to top everything up (up to max cap on the mag reached), or as specific as you want to get, and there are reasons to be very specific (due to mag capacity issues), be it only do 'this' specific mag on the unit, or hey not only do just that specific mag, but only do this specific weapon record entry, and set it specifically to this number. Here is a sample showing most of the combinations of options possible:

Code: Select all

--requires 1147.44+/~1300
--name,guid are required, the guid must be actual guid, the name can be anything it techinicaly doesn't have to mach the unit.
--optional specific_magguid="guid string" and or specific_wpnrecguid="guid string", and or quantity=integerNumber.
local TopUpAllExistingMagsUnitList = {
{name='SAM Bn S-400 #1', guid='4FH7PU-0HMNDPRJL9OQ0',comment="attempts maxcap fill on all mags on unit"}, 
{name='SAM Bn S-400 #2', guid='4FH7PU-0HMNDPRJL99BD',comment="attempts maxcap fill on all mags on unit"}, 
{name='DDG 125 #1 rim174 on munitions only', guid='4FH7PU-0HMNDPRJL9Q17',specific_magguid ="4FH7PU-0HMNDPRJL9QJH",specific_wpnrecguid="4FH7PU-0HMNDPRJL9QJI",comment="fastest perf it will only do this specific mag and only this specfic wpn record 174A blk1a"},
{name='DDG 125 #1 helocopter magonly', guid='4FH7PU-0HMNDPRJL9Q17',specific_magguid ="4FH7PU-0HMNDPRJL9Q6P",comment="will only process the helicopter mag."},
{name='DDG 125 #1 mk54LHT to 24 only', guid='4FH7PU-0HMNDPRJL9Q17',specific_wpnrecguid ="4FH7PU-0HMNDPRJL9Q75",quantity=24,comment="will search all mags but only till it finds this specific mk54 LHT record and change it to 24"}
--note the last entry would run faster searching wise if you also provided the magguid involved...but you don't have too.
}
Attached are 3 copies of what are effectively the same scene running effective all the same core script, the difference is just in how each chooses to implement the usage.

_LOCAL.scen - for beginners, and copy+paste into your own events, just change the tables and Go. Duplicate it in every event where you need it, all function and vars are local to the event script and start and die during the event.

_Hybrid.scen - Here we move the core scripts into global functions, but leave the tables in the events, and just submit them to the global instances of the functions, this way one can make table changes and see results without having to re-load a scene like GLOBALS requires (in the sample anyway). It's also far less bloat and the core functions don't have to be recompiled on the fly during every event.

_GLOBALS.scene - Here we moved everything into global functions and vars, and the events just call those functions with global vars already setup onSceneload. One will have to 'save and reload' after you change the tables.... unless of course you just copy the whole thing to you lua console and re-execute it, or at least the table var parts.

Again there is nothing special or fancy about this, it's more just functional code with logs of logging, that I think might be handy for some and packaged with functional demo scene samples of the most basic way to use it. By default the sample scene scripts run at every in-game minute marker via a 1-minute trigger. Obviously no need to do that in a real scene, it's just a sample so you can eyeball all the mags first, press play wait ~35seconds pause and go look at the mags again, and your logs\LuaHistory_todaysdata.txt log. I indicate what to expect in terms of changes\what the entries should accomplish in the briefing, and discuss side effects of hitting mag_caps. I also provide a basic unit.mags console dumping script in each sample in a special action that you can copy\paste into the lua console to help lookup the mag_guids and wpn_guids if you need to for a unit guid, it's nothing special either it's code I've already posted here before helping peeps with similar.

So you're saying I have to explicitly tell it all the units I want refilled?
Yup, again if you know some lua you'll probably know how to automatically generate your own list of units and params and submit those to the functions if you really want or need to automate it more. This is more in mind for peeps who kinda sorta don't want to touch any more lua then they have too, and idk, editing a list of units is about as easy as I can make it and still keep it kinda flexible, and kind of simple. None lua folks will sill need to do the pita jobs of collecting the data to throw into these instruction tables.

More Q and A in the sample briefings.

Zip contents. (requires build 1300.1 or I think 1147.52 will work; database 497a; I built it with 1300.1)
RefillingLoadoutsAndMags\Scenes\Sample_ScriptRefillingLoadoutsAndUnitMags_1300xdb497a_GLOBALS.scen
RefillingLoadoutsAndMags\Scenes\Sample_ScriptRefillingLoadoutsAndUnitMags_1300xdb497a_Hybrid.scen
RefillingLoadoutsAndMags\Scenes\Sample_ScriptRefillingLoadoutsAndUnitMags_1300xdb497a_LOCALS.scen
RefillingLoadoutsAndMags\LuaInText\Globals\ .txt files of same code in scene and events extracted.
RefillingLoadoutsAndMags\LuaInText\Hybrid\ .txt files of same code in scene and events extracted.
RefillingLoadoutsAndMags\LuaInText\Locals\ .txt files of same code in scene and events extracted.
RefillingLoadoutsAndMags\LuaInText\DumpUnitMagsInConsoleAndLog.txt file - help script for dumping unit's mags.
LuaInText\*.* are provided cause people sometimes people can't open a scene, though in this cause you really do need pretty current copy cause there is a function that is used and recently fixed that is required.
RefillingLoadoutsAndMags.zip
(307.38 KiB) Downloaded 10 times

I can probably add doing top up of mounts and maybe active loadouts on active aircraft to this as well if there is real interest.
Parel803
Posts: 937
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

Re: Semi Unlimited - automated magazine and loadouts topping up

Post by Parel803 »

thanks for all the work and sharing it.
best regards GJ
Post Reply

Return to “Lua Legion”