Hi everyone, I've only recently started attempting modding so I hope this issue isn't already addressed.
I'm making a mod and adding units which will have various special abilities, ie light a fire, terraform a plot, whatever. Though I think I've made a good start, I'm wondering a few things.
At the moment I am accomplishing my goal by editing UnitPanel.lua. Essentially I just added this chunk of code to UpdateUnitActions:
Obviously I also added a method OnWarriorActionClicked, which does some irrelevant things like print to FireTuner and use up a movement point.
This works but doesn't feel good to me as a programmer; is there a way to modify GameInfoActions to accomplish what I want? Where is GameInfoActions defined anyway?
My second question is to do with assigning an icon to the action button. I see this line:
being used elsewhere in the file but I'm not 100% sure how to use it. Is buildInfo.IconAtlas an object or a string? Whats the last parameter exactly?
And if anyone knows whats going on behind the scenes when g_BuildIM:GetInstance() is called, it would be nice to know, I hate just relying on "its magic and it works!"
Thanks heaps; lets break stuff!
I'm making a mod and adding units which will have various special abilities, ie light a fire, terraform a plot, whatever. Though I think I've made a good start, I'm wondering a few things.
At the moment I am accomplishing my goal by editing UnitPanel.lua. Essentially I just added this chunk of code to UpdateUnitActions:
Code:
if(bUnitHasMovesLeft)
then
local thisUnitInfo = GameInfo.Units[unit:GetUnitType()];
if (thisUnitInfo.Class == "UNITCLASS_WARRIOR") --This works, displaying the panel only when a warrior is selected
then
instance = g_BuildIM:GetInstance();
instance.UnitActionButton:SetAnchor( "L,B" );
instance.UnitActionButton:SetOffsetVal( (numBuildActions % numberOfButtonsPerRow) * buttonSize + buttonPadding + buttonOffsetX, math.floor(numBuildActions / numberOfButtonsPerRow) * buttonSize + buttonPadding + buttonOffsetY );
instance.UnitActionButton:RegisterCallback( Mouse.eLClick, OnWarriorActionClicked );
activeUnit = unit;
numBuildActions = numBuildActions + 1;
end
end
Obviously I also added a method OnWarriorActionClicked, which does some irrelevant things like print to FireTuner and use up a movement point.
This works but doesn't feel good to me as a programmer; is there a way to modify GameInfoActions to accomplish what I want? Where is GameInfoActions defined anyway?
My second question is to do with assigning an icon to the action button. I see this line:
Code:
IconHookup( buildInfo.IconIndex, actionIconSize, buildInfo.IconAtlas, Controls.RecommendedActionImage );
And if anyone knows whats going on behind the scenes when g_BuildIM:GetInstance() is called, it would be nice to know, I hate just relying on "its magic and it works!"

Thanks heaps; lets break stuff!