martijnaikema
Warlord
- Joined
- Oct 30, 2010
- Messages
- 111
In the EnemyUnitPanel.xml the unit-bonusses that are displayed in the panel (like Rough Terrain Bonus) are created as instances. In the xml it is displayed as:
<Instance Name="UsCombatInfo" >
<Label Anchor="R,C" Offset="52.0" String=" " Font="TwCenMT14" ID="Text" WrapWidth="230" LeadingOffset="-6" >
<Label Anchor="R,C" AnchorSide="O.I" Offset="4.0" Font="TwCenMT14" ID="Value" />
</Label>
</Instance>
If I edit the core file (EnemyUnitPanel.lua) and add my bonus to it, it is displayed in the screen:
local iType = pMyUnit:GetNameKey();
if (pToPlot:IsRiver() and iType == "TXT_KEY_UNIT_WATERGEUS") then
-- RiverModifier
iModifier = 50;
if (iModifier ~= 0) then
controlTable = g_MyCombatDataIM:GetInstance();
local RiverBonus = "River";
controlTable.Text:LocalizeAndSetText( "TXT_KEY_EUPANEL_ATTACK_INTO_BONUS", RiverBonus );
controlTable.Value:SetText( GetFormattedText(strText, iModifier, true, true) );
end
end
-- pMyUnit = UI.GetHeadSelectedUnit();
-- pToPlot = the mouseover of a certain plot
When I add this to the core lua-file the text and bonus is displayed in the panel:
But I do not want to edit the core file but create the new instance with my own lua. But I can not get it to work. Here is some more info from the instance.
* The instance in the core-lua is created through the command: g_MyCombatDataIM:GetInstance = InstanceManager:new( "UsCombatInfo", "Text", Controls.MyCombatResultsStack );
* The instance is created by including the InstanceManager.lua
* To add a new instance I guess I have to read the instances allready created by EnemyUnitPanel.lua and add my instance to it
* I found this thread really interesting cause it shows the power of ContextPtr-commands. I tried different options, but I can't get it to work.
I hope someone knows how I should add a new Instance to the panel.
Edit:When I try to create a new instance I get an error "Instance Manager built with a bad Root Control [USCombatInfo] [Text]"
Spoiler :
<Instance Name="UsCombatInfo" >
<Label Anchor="R,C" Offset="52.0" String=" " Font="TwCenMT14" ID="Text" WrapWidth="230" LeadingOffset="-6" >
<Label Anchor="R,C" AnchorSide="O.I" Offset="4.0" Font="TwCenMT14" ID="Value" />
</Label>
</Instance>
If I edit the core file (EnemyUnitPanel.lua) and add my bonus to it, it is displayed in the screen:
Spoiler :
local iType = pMyUnit:GetNameKey();
if (pToPlot:IsRiver() and iType == "TXT_KEY_UNIT_WATERGEUS") then
-- RiverModifier
iModifier = 50;
if (iModifier ~= 0) then
controlTable = g_MyCombatDataIM:GetInstance();
local RiverBonus = "River";
controlTable.Text:LocalizeAndSetText( "TXT_KEY_EUPANEL_ATTACK_INTO_BONUS", RiverBonus );
controlTable.Value:SetText( GetFormattedText(strText, iModifier, true, true) );
end
end
-- pMyUnit = UI.GetHeadSelectedUnit();
-- pToPlot = the mouseover of a certain plot
When I add this to the core lua-file the text and bonus is displayed in the panel:

But I do not want to edit the core file but create the new instance with my own lua. But I can not get it to work. Here is some more info from the instance.
* The instance in the core-lua is created through the command: g_MyCombatDataIM:GetInstance = InstanceManager:new( "UsCombatInfo", "Text", Controls.MyCombatResultsStack );
* The instance is created by including the InstanceManager.lua
* To add a new instance I guess I have to read the instances allready created by EnemyUnitPanel.lua and add my instance to it
* I found this thread really interesting cause it shows the power of ContextPtr-commands. I tried different options, but I can't get it to work.
I hope someone knows how I should add a new Instance to the panel.
Edit:When I try to create a new instance I get an error "Instance Manager built with a bad Root Control [USCombatInfo] [Text]"