Trigger Replenish of Ground units via LUA?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
tiag
Posts: 130
Joined: Thu Jun 21, 2018 8:33 am

Trigger Replenish of Ground units via LUA?

Post by tiag »

Hi there,

is there a way to trigger replenish (rearm/refuel) of ground units via LUA?

Regards

Tiago
User avatar
TitaniumTrout
Posts: 469
Joined: Mon Oct 20, 2014 9:06 am
Location: Michigan

Re: Trigger Replenish of Ground units via LUA?

Post by TitaniumTrout »

tiag wrote: Fri Sep 16, 2022 8:34 pm Hi there,

is there a way to trigger replenish (rearm/refuel) of ground units via LUA?

Regards

Tiago
To add reloads use :

ScenEdit_AddReloadsToUnit({unitname="Test Tank", wpn_dbid=688, number=1})

The above script adds a single 120mm APFSDS-T to an M1A1.

For fuel we have to use the Fuel table from the unit wrapper.

local a = ScenEdit_GetUnit({ side = 'OPFOR' , name = 'Test Tank' })

local fuel=a.fuel
fuel[3003].current=100
a.fuel=fuel
print(a.fuel)

This queries a unit, assigns it to the variable a, then grabs the fuel info from it. You can print the a.fuel variable and see what is inside the table, in this case the M1A1 uses a fuel type 3003. Then we set the current to 100, then reassign.
tiag
Posts: 130
Joined: Thu Jun 21, 2018 8:33 am

Re: Trigger Replenish of Ground units via LUA?

Post by tiag »

Thank you, I am aware of AddReloadsToUnit, but that is not what I asked exactly.
Is there any command to trigger an unit to seek a source for rearm/refuel, which is perhaps not docummented?!
To be clear, to replicate the GUI command "replenish" from the user menu.
User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

Re: Trigger Replenish of Ground units via LUA?

Post by michaelm75au »

No there is not an Event as such for it.
You can set the ROE/Doctrine to force a unit to withdraw to replenish.
Michael
tiag
Posts: 130
Joined: Thu Jun 21, 2018 8:33 am

Re: Trigger Replenish of Ground units via LUA?

Post by tiag »

Hi there,

The withdraw to replenish option seems buggy for ground units. Before I report it, just want to make sure you also get what I am getting.

I made a small test scenario with a HIMARS platoon (in the blue side)
After firing all its missiles, it does not look for a replenish, although it should withdraw after primary attack weapon is exausted. In my tests, it will only move if I set to look for refuel.
Scenario is attached. Simply fire all missiles at the target marker (red side) and check if the platoon will move. Nothing happens for me.
-> Strange is that if I manually click on replenish automatically via menu, the platoon will go to the nearest magazine and replenish its own magazines.
Am I doing something wrong or should I report as a bug?

https://drive.google.com/file/d/1DxW8p1 ... sp=sharing
User avatar
michaelm75au
Posts: 12457
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

Re: Trigger Replenish of Ground units via LUA?

Post by michaelm75au »

The 'withdraw' function only works with 'bases' so that might not be want you based on the last post.

If the unit is part of a group that includes an 'ammo truck', then the unit should withdraw to re-arm automatically from memory.
Michael
Post Reply

Return to “Lua Legion”