Page 1 of 1

LUA to refuel aircraft after remains in area trigger

Posted: Sat Feb 15, 2025 9:55 pm
by orca
I have a unit remains in area trigger for any Red side aircraft that remains in a "refueling zone" for 30 minutes. I want to create an event in which this trigger results in an action to refuel the aircraft that resulted in the trigger.

I'm using this script to refuel aircraft:

u = ScenEdit_GetUnit({side='Red',"AIRCRAFT_NAME'})
if u ~= nil then
local newfuel = u.fuel
newfuel[2001].current = newfuel[2001].max
u.fuel = newfuel
end

But how can I always make the local unit u to be the aircraft that caused the trigger to fire?

Re: LUA to refuel aircraft after remains in area trigger

Posted: Sun Feb 16, 2025 6:31 am
by blu3s
orca wrote: Sat Feb 15, 2025 9:55 pm u = ScenEdit_GetUnit({side='Red',"AIRCRAFT_NAME'})
This one is wrong you need to indicate that the 2nd parameter is the name.

To get the unit that triggers the event you need to use UnitX()

So you will have:

Code: Select all

local unit = UnitX()

if unit then
...
end