Loading...
  OR  Zero-K Name:    Password:   

Trying to add CMD_FORMATION_RANK

10 posts, 474 views
Post comment
Filter:    Player:  
sort
2 years ago
I am trying to add a new state to the custom formations widget.

local formationRankCmdDesc = {
id = CMD_FORMATION_RANK,
type = CMDTYPE.ICON_MODE,
name = 'formation Rank',
action = 'formation_rank',
tooltip = 'Formation rank: units of lower rank line up in front of units of higher rank.',
params = {0, 'Lowest', 'Low', 'Medium', 'High'}
}

The new state is not showing up in the Chili Integral menu. How do I get it to show up?

I have also added it to the custom commands:

function widget:CommandsChanged()
local selectedUnits = Spring.GetSelectedUnits()
local unitID = selectedUnits and selectedUnits[1]
local unitDefID = unitID and Spring.GetUnitDefID(unitID)
if not unitDefID then
return
end
local rank = formationRank[unitID] or defaultRank[unitDefID] or 2
local customCommands = widgetHandler.customCommands
formationRankCmdDesc.params[1] = rank
table.insert(customCommands, selectionRankCmdDesc)
end

function widget:CommandNotify(id, params, options)
if id ~= CMD_FORMATION_RANK then
return false
end
local newRank = params[1]
if options.right then
newRank = (newRank + 2)%4
end
local selectedUnits = Spring.GetSelectedUnits()
for i = 1, #selectedUnits do
formationRank[selectedUnits[i]] = newRank
end
if WG.noises and selectedUnits[1] then
WG.noises.PlayResponse(selectedUnits[1], CMD_SELECTION_RANK)
end
return true
end

What are the requirements to add a state command?

(form formatting should have a code option.)
+2 / -0


2 years ago
Search all of luaUI to see how selection rank is added. It looks like you haven't set how it should be drawn by the command menu.
+0 / -0
2 years ago
quote:
(forum formatting should have a code option.)
(FIFY)

Yes, that's on my wishlist, too.
+0 / -0
2 years ago
Changes in LuaRules\Configs are not being used. Probably due to it being a config for gadgets.

quote:

LuaRules\Configs
config files read by Lua gadgets

Looks like I need to make a dev.sdd directory

https://springrts.com/wiki/Gamedev:Structure Is not very clear on where to put it and how to use it. I will need to experiment with it later.
+0 / -0
2 years ago
https://zero-k.info/mediawiki/index.php?title=Mod_Creation#Mutators

Try putting it in your zk folder's first "games" folder.
+0 / -0
2 years ago
quote:

https://zero-k.info/mediawiki/index.php?title=Mod_Creation#Mutators

So much better documentation than the general springRTS one. Thank you. Zero-k’s Readme should use this link instead, though the other link has more information about file structure.
+0 / -0
2 years ago
quote:

formationRankCmdDesc.params[1] = rank
table.insert(customCommands, selectionRankCmdDesc)

Looks like the main issue was a copy and paste error; however, I needed to figure out how to create a mod to test changes that are not widgets anyway, which I also got working.

I also need images for the states. Right now I am using the images from selection, which allows me to develop without them. Can anyone create images for formation rank states modeled after the four selection rank images (Zero-K/LuaUI/Images/commands/states/selection_rank_0.png)
+0 / -0
2 years ago
For the request images, maybe 4 horizontal lines, 3 grey, 1 a brighter color, since the formation will spread units out in 4 lines depending on their rank.
+0 / -0


2 years ago
It sounds like you want https://zero-k.info/mediawiki/index.php?title=Zero-K:Developing#Modifying_the_game rather than a mutator.
+0 / -0
2 years ago
Yes, https://zero-k.info/mediawiki/index.php?title=Zero-K:Developing#Modifying_the_game is better; however, I got it to work with the mod path.

quote:
New developers should read this before touching the source.

Opps.
+0 / -0