Page 1 of 1
Trigger Replenish of Ground units via LUA?
Posted: Fri Sep 16, 2022 8:34 pm
by tiag
Hi there,
is there a way to trigger replenish (rearm/refuel) of ground units via LUA?
Regards
Tiago
Re: Trigger Replenish of Ground units via LUA?
Posted: Fri Sep 16, 2022 11:38 pm
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.
Re: Trigger Replenish of Ground units via LUA?
Posted: Sat Sep 17, 2022 6:28 am
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.
Re: Trigger Replenish of Ground units via LUA?
Posted: Sat Sep 17, 2022 7:18 am
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.
Re: Trigger Replenish of Ground units via LUA?
Posted: Sun Sep 18, 2022 10:05 am
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
Re: Trigger Replenish of Ground units via LUA?
Posted: Mon Sep 19, 2022 8:39 am
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.