Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

FualState in Lua : how do you use it ?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> FualState in Lua : how do you use it ? Page: [1]
Login
Message << Older Topic   Newer Topic >>
FualState in Lua : how do you use it ? - 3/21/2016 5:28:10 PM   
iborg

 

Posts: 23
Joined: 2/22/2016
Status: offline
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 !
Post #: 1
RE: FualState in Lua : how do you use it ? - 3/21/2016 10:24:25 PM   
ckfinite

 

Posts: 377
Joined: 7/20/2013
Status: offline
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)

(in reply to iborg)
Post #: 2
RE: FualState in Lua : how do you use it ? - 3/22/2016 3:09:14 PM   
iborg

 

Posts: 23
Joined: 2/22/2016
Status: offline
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

(in reply to ckfinite)
Post #: 3
RE: FualState in Lua : how do you use it ? - 3/22/2016 9:11:30 PM   
tjhkkr


Posts: 2428
Joined: 6/3/2010
Status: offline
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?

_____________________________

Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.

(in reply to ckfinite)
Post #: 4
RE: FualState in Lua : how do you use it ? - 3/22/2016 9:13:26 PM   
tjhkkr


Posts: 2428
Joined: 6/3/2010
Status: offline
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?

_____________________________

Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.

(in reply to tjhkkr)
Post #: 5
RE: FualState in Lua : how do you use it ? - 3/23/2016 8:41:50 PM   
iborg

 

Posts: 23
Joined: 2/22/2016
Status: offline

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).

(in reply to tjhkkr)
Post #: 6
RE: FualState in Lua : how do you use it ? - 3/23/2016 10:47:40 PM   
ckfinite

 

Posts: 377
Joined: 7/20/2013
Status: offline
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.

(in reply to iborg)
Post #: 7
RE: FualState in Lua : how do you use it ? - 3/24/2016 4:36:45 AM   
tjhkkr


Posts: 2428
Joined: 6/3/2010
Status: offline
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. :)


_____________________________

Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.

(in reply to ckfinite)
Post #: 8
RE: FualState in Lua : how do you use it ? - 3/26/2016 3:52:18 PM   
Dysta


Posts: 1908
Joined: 8/8/2015
Status: offline
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


_____________________________


(in reply to tjhkkr)
Post #: 9
RE: FualState in Lua : how do you use it ? - 3/26/2016 4:18:36 PM   
ckfinite

 

Posts: 377
Joined: 7/20/2013
Status: offline
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.

(in reply to Dysta)
Post #: 10
RE: FualState in Lua : how do you use it ? - 3/26/2016 4:32:54 PM   
Dysta


Posts: 1908
Joined: 8/8/2015
Status: offline
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.

_____________________________


(in reply to ckfinite)
Post #: 11
RE: FualState in Lua : how do you use it ? - 3/26/2016 4:50:46 PM   
ckfinite

 

Posts: 377
Joined: 7/20/2013
Status: offline
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.

(in reply to Dysta)
Post #: 12
RE: FualState in Lua : how do you use it ? - 3/26/2016 5:17:58 PM   
Dysta


Posts: 1908
Joined: 8/8/2015
Status: offline

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.

_____________________________


(in reply to ckfinite)
Post #: 13
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> FualState in Lua : how do you use it ? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.420