Set fuel level

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
orca
Posts: 526
Joined: Wed Nov 06, 2013 4:59 pm

Set fuel level

Post by orca »

What is the lua script to set current and max fuel levels for a unit?

I’m attempting to set the max and current fuel level of an aircraft. I hope to be able to make these values to be greater than the regular fuel capacity of the aircraft as stated in the db but can’t get it to work.

Thanks
Whicker
Posts: 664
Joined: Tue Jun 19, 2018 9:54 pm

RE: Set fuel level

Post by Whicker »

heres one way - I don't think you can get it more than max though. You can only set current.
Fuels have a type. Careful with that.

local a = ScenEdit_GetUnit({guid='1298e86b-a6a8-4bb0-bf94-dd77c6559eaa'})
local fuel = a.fuel
print(fuel) --before change

fuel[2001].current = fuel[2001].max*math.random(600, 800)/1000
a.fuel = fuel
print(fuel) --after change
orca
Posts: 526
Joined: Wed Nov 06, 2013 4:59 pm

RE: Set fuel level

Post by orca »

Thanks for the reply. In the command lua documentation it talks about the “max number-How much can be stored for the type” in regard to the fuel. This is why I was thinking it may be possible to edit this to be higher than in the default db max number.

ORIGINAL: Whicker

heres one way - I don't think you can get it more than max though. You can only set current.
Fuels have a type. Careful with that.

local a = ScenEdit_GetUnit({guid='1298e86b-a6a8-4bb0-bf94-dd77c6559eaa'})
local fuel = a.fuel
print(fuel) --before change

fuel[2001].current = fuel[2001].max*math.random(600, 800)/1000
a.fuel = fuel
print(fuel) --after change
User avatar
Primarchx
Posts: 1954
Joined: Sun Jan 20, 2013 9:29 pm

RE: Set fuel level

Post by Primarchx »

Lots of accessible fields are read-only, which I suspect is the case with max fuel for a given fuel type.
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

RE: Set fuel level

Post by KnightHawk75 »

Be aware changes may be on the way so that we can actually fill up all the fuel tanks when there are multiple.

It not so much a read only issue, it's a can't force it to fill up the correct tank of same type usually when more than 1 exists.

tm.asp?m=4577588&mpage=1&key=�
Post Reply

Return to “Lua Legion”