FualState in Lua : how do you use it ? (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series



Message


iborg -> FualState in Lua : how do you use it ? (3/21/2016 5:28:10 PM)

As the title says. I want to set the fuel state of units in scenarios, using Lua, but I can't seem to make it work. I tried to follow the syntax on Baloogan's Lua function documentation, but it's not clear as to how to integrate it in API calls. Anyone could post a working example (in a ScenEdit_AddUnit script), I'd be grateful !




ckfinite -> RE: FualState in Lua : how do you use it ? (3/21/2016 10:24:25 PM)

See the example here. You'd use it like

local u = ScenEdit_AddUnit(...)
local fuel = u.fuel
fuel[3001].current = 400
u.fuel = fuel

(you'll need to get the fuel code from the list on that page)




iborg -> RE: FualState in Lua : how do you use it ? (3/22/2016 3:09:14 PM)

Ah, thanks ! I understand better now. I think you should put this example instead of (or in addition to) the one in the link, which is less complete (and which I couldn't understand [;)] ). And thanks for the rest of the Lua documentation by the way, it's immensely helpful [&o]




tjhkkr -> RE: FualState in Lua : how do you use it ? (3/22/2016 9:11:30 PM)

quote:

ORIGINAL: ckfinite

See the example here. You'd use it like

local u = ScenEdit_AddUnit(...)
local fuel = u.fuel
fuel[3001].current = 400
u.fuel = fuel

(you'll need to get the fuel code from the list on that page)


Did you mean ADDUnit or GetUnit?




tjhkkr -> RE: FualState in Lua : how do you use it ? (3/22/2016 9:13:26 PM)

Do when you do this, the local variable u has all the parameters of that unit, and that unit's parameters/properties could then be modified?
Do I understand this accurately?




iborg -> RE: FualState in Lua : how do you use it ? (3/23/2016 8:41:50 PM)


quote:

ORIGINAL: tjhkkr

Do when you do this, the local variable u has all the parameters of that unit, and that unit's parameters/properties could then be modified?
Do I understand this accurately?

quote:

local u = ScenEdit_AddUnit(...)
local fuel = u.fuel
fuel[3001].current = 400
u.fuel = fuel


I just tried it in the Lua console, using it like this :
local u =  ScenEdit_SetUnit({side="India", guid="0747cd9c-eca2-4a65-b04e-c0d226b0a91d"})
local fuel = u.fuel 
fuel[2001].current = 1500 
u.fuel = fuel 


Of course, you have to change side and guid accordingly, but in this example I changed the fuel state of an airborne plane (therefore the 2001 code for avgas). [:)]




ckfinite -> RE: FualState in Lua : how do you use it ? (3/23/2016 10:47:40 PM)

quote:

Do when you do this, the local variable u has all the parameters of that unit, and that unit's parameters/properties could then be modified?
Do I understand this accurately?


Yes, exactly. See my documentation for what you can do with it.

quote:

Did you mean ADDUnit or GetUnit?


AddUnit, since that's what iborg asked about. If you look at the documentation, you can see it returns the unit that was added.




tjhkkr -> RE: FualState in Lua : how do you use it ? (3/24/2016 4:36:45 AM)

quote:

ORIGINAL: ckfinite

quote:

Do when you do this, the local variable u has all the parameters of that unit, and that unit's parameters/properties could then be modified?
Do I understand this accurately?


Yes, exactly. See my documentation for what you can do with it.

quote:

Did you mean ADDUnit or GetUnit?


AddUnit, since that's what iborg asked about. If you look at the documentation, you can see it returns the unit that was added.

Thank you for taking the time to answer. :)




Dysta -> RE: FualState in Lua : how do you use it ? (3/26/2016 3:52:18 PM)

I tried to modify the unit's maximum fuel for a new scenario, but the Max field doesn't seems working. Something wrong in this script? (Tested Current adjustment is working)

quote:



local u = ScenEdit_SetUnit({side="***", guid="***"})
local fuel = u.fuel
fuel[3001].max = 50000
u.fuel = fuel




ckfinite -> RE: FualState in Lua : how do you use it ? (3/26/2016 4:18:36 PM)

quote:

I tried to modify the unit's maximum fuel for a new scenario, but the Max field doesn't seems working. Something wrong in this script? (Tested Current adjustment is working)


I suspect (but don't know for sure) that the max fuel state is read only.




Dysta -> RE: FualState in Lua : how do you use it ? (3/26/2016 4:32:54 PM)

quote:

ORIGINAL: ckfinite

I suspect (but don't know for sure) that the max fuel state is read only.

Ouch. Is there's a workaround like using triggers? If not, seems like the only way is to make a replenishment ship for refueling.




ckfinite -> RE: FualState in Lua : how do you use it ? (3/26/2016 4:50:46 PM)

quote:

Ouch. Is there's a workaround like using triggers? If not, seems like the only way is to make a replenishment ship for refueling.


You can refuel the units like the following:

local u = ScenEdit_SetUnit({side=..., guid=...})
local fuel = u.fuel
fuel[2001].current = fuel[2001].max
u.fuel = fuel

But you can't change the maximum amount of fuel that the unit has, as far as I know.




Dysta -> RE: FualState in Lua : how do you use it ? (3/26/2016 5:17:58 PM)


quote:

ORIGINAL: ckfinite

quote:

Ouch. Is there's a workaround like using triggers? If not, seems like the only way is to make a replenishment ship for refueling.


You can refuel the units like the following:

local u = ScenEdit_SetUnit({side=..., guid=...})
local fuel = u.fuel
fuel[2001].current = fuel[2001].max
u.fuel = fuel

But you can't change the maximum amount of fuel that the unit has, as far as I know.

quote:

local u = ScenEdit_SetUnit({side=..., guid=...}) local fuel = u.fuel fuel[2001].current = fuel[2001].max u.fuel = fuel


Got it! With Event, Trigger and Action, the ship can now roaming much further as long as it reached the set area.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
5.421875