Fire and move state both are in GetUnitStates but I see no way to add my own custom mode toggles with a add unit state etc..
Is there a table for the unit states? or are they hard coded to the engine? because right now the latter seems to be true(of course my engine source is a bit old).
If it is hard coded to the engine, is there another way of reading the current fire and move states? Because I am working on code to better handle custom commands and this is a point I am stuck at.
fire state, move state and other toggle commands
Moderator: Moderators
Re: fire state, move state and other toggle commands
local cmdDesc = {
...
type = CMDTYPE.ICON_MODE,
params = {'0', 'Cloaker Off', 'Cloaker On' } -- first '0' indicates the default state (here 'Cloaker Off')
}
Spring.InsertUnitCmdDesc(unitID, 0, cmdDesc)
...
type = CMDTYPE.ICON_MODE,
params = {'0', 'Cloaker Off', 'Cloaker On' } -- first '0' indicates the default state (here 'Cloaker Off')
}
Spring.InsertUnitCmdDesc(unitID, 0, cmdDesc)
Re: fire state, move state and other toggle commands
Yet my command is missing from the unit states returned by the get callin
I'll double check my command code when I get home
I'll double check my command code when I get home
Re: fire state, move state and other toggle commands
I think the OP is correct, Smoth iirc-off-the-top-of-my-head.
Re: fire state, move state and other toggle commands
flozi, is there a different way to handle fire/move state? If so, it would be good to know because I am trying to clean up the feature placer code and one of the big issues I found is handling CMDTYPE.ICON_MODE
Re: fire state, move state and other toggle commands
doesnt seem like it can read custom toggle buttons.Spring.GetUnitStates
( number unitID ) -> nil | {
"firestate" = number,
"movestate" = number,
"repeat" = boolean,
"cloak" = boolean,
"active" = boolean,
"trajectory" = boolean,
["autoland" = boolean,]
["autorepairlevel" = number,]
["loopbackattack" = boolean]
}
seems if you make your own toggle button, you have to save that state yourself? maybe in a table or better in UnitRules.
Re: fire state, move state and other toggle commands
so there is no way to add to unit state? was this by design or forgotten? because it seems like it wasn't intended
Re: fire state, move state and other toggle commands
There are no unit states! There is no code in the engine that `manages` CMDTYPE.ICON_MODE. All code catches such commands in `AllowCommand` and even has to update the CmdDesc itself (switching the state of the button).
Re: fire state, move state and other toggle commands
What i am talking about are the values returned by GetUnitStates(). Are you talking something lower level than this?jK wrote:There are no unit states!
when I want to find out the fire mode of a unit I use:jK wrote:There is no code in the engine that `manages` CMDTYPE.ICON_MODE. All code catches such commands in `AllowCommand` and even has to update the CmdDesc itself (switching the state of the button).
GetUnitStates(unitID)["firestate"]
which returns 1 or 2 or 3.
This I use to get the mode of the FIRE_STATE command.
in my own ICON_MODE commands I use
local spreadCMD = CMD["FSPREAD"]
GetUnitCmdDescs(unitID, spreadCMDID)[1].params[1])
Why is my spread command not returned as a result in GetUnitStates? Should I be using GetUnitCmdDescs instead of GetUnitStates for FIRE_STATE instead?
-----------------------------------------------------------------
Why are there two functions:
Spring.GetUnitCmdDescs()
Spring.GetUnitStates()
there must be a reason.
Re: fire state, move state and other toggle commands
As said there are no unitstates!
Spring.GetUnitStates() gathers them from several places across the engine!
Spring.GetUnitStates() gathers them from several places across the engine!
Re: fire state, move state and other toggle commands
so why have it?
- Pressure Line
- Posts: 2283
- Joined: 21 May 2007, 02:09
Re: fire state, move state and other toggle commands
when I want to find out the fire mode of a unit I use:
GetUnitStates(unitID)["firestate"]
which returns 1 or 2 or 3.
This I use to get the mode of the FIRE_STATE command.
in my own ICON_MODE commands I use
local spreadCMD = CMD["FSPREAD"]
GetUnitCmdDescs(unitID, spreadCMDID)[1].params[1])
Short answer: Because it's not.Why is my spread command not returned as a result in GetUnitStates?
Long answer: because GetUnitStates grabs "from several places across the engine" some of the 'states' of the hardcoded command buttons, which would otherwise be a pain in the rear to get. But for custom commands you have to get them yourself