therefromhere
Chieftain
- Joined
- Aug 11, 2013
- Messages
- 3
I'm trying to add an item to MiniMapPanel using ContextPtr:LookUpControl() rather than replacing the whole file. I'm trying to follow the approach of section 8 from http://forums.civfanatics.com/showthread.php?t=399743
My code creates a checkbox, but it's not relocating it as I'd expect, I get the following error:
The error message is on the ReprocessAnchoring() line, which suggests that the ContextPtr:LookUpControl() call is failing.
However, if I run the lua in the ShowAntiquityMenu state in FireTuner, it works as expected. What's going on?
Is my code running before MiniMapPanel exists, maybe?
ShowAntiquityMenu.lua:
ShowAntiquityMenu.xml:
MyMenuItem.xml is marked as an InGameUiAddin
My code creates a checkbox, but it's not relocating it as I'd expect, I get the following error:
Incorrect type for pointer argument. Using NULL instead.
Runtime Error: M:\Users\John\Documents\My Games\Sid Meier's Civilization 5\MODS\Antiquity Site Icons Filter (v 2)\Lua/ShowAntiquityMenu.lua:6: attempt to index a nil value
Runtime Error: Error loading M:\Users\John\Documents\My Games\Sid Meier's Civilization 5\MODS\Antiquity Site Icons Filter (v 2)\Lua/ShowAntiquityMenu.lua.
The error message is on the ReprocessAnchoring() line, which suggests that the ContextPtr:LookUpControl() call is failing.
However, if I run the lua in the ShowAntiquityMenu state in FireTuner, it works as expected. What's going on?
Is my code running before MiniMapPanel exists, maybe?
ShowAntiquityMenu.lua:
PHP:
Controls.ShowOnlyAntiquityResources:ChangeParent( ContextPtr:LookUpControl("/InGame/WorldView/MiniMapPanel/MainStack"));
ContextPtr:LookUpControl("/InGame/WorldView/MiniMapPanel/MainStack"):ReprocessAnchoring();
ShowAntiquityMenu.xml:
HTML:
<?xml version="1.0" encoding="utf-8"?>
<Context>
<CheckBox Anchor="L,T" TextAnchorSide="Right" Offset="0,0" TextOffset="40,0" IsChecked="0" ID="ShowOnlyAntiquityResources" String="TXT_KEY_MAP_OPTIONS_ANTIQUITY_RESOURCE_ICONS" />
</Context>
MyMenuItem.xml is marked as an InGameUiAddin