LookUpControl Fail

JFD

Kathigitarkh
Joined
Oct 19, 2010
Messages
9,132
Location
The Kingdom of New Zealand
I'm trying to edit a few things on the TopPanel, but as they are fairly minor it's generally not worth overwriting the file. I'm using the 'lookupcontrol' method to - try - to achieve this, but it always returns as nil. However, it does work when used in Firetuner, so I'm not sure why I'm having no luck. Any help would be appreciated. Thanks.

Code:
ContextPtr:LookUpControl("/InGame/TopPanel/CultureString"):SetText("testing")
 
Lua context are loaded in a specific order. If you try to lookup LookUpControl into a context which is not yet loaded, it will return nil.
So you need to wait until things are loaded to call LookUpControl. Usually having the file loaded by "UIaddin" or something like that should be enough, otherwise try on player turn start.
 
That makes sense. Thanks for the advice.

EDIT: Well, it resolved the issue of it coming up nil, but hasn't gotten it to work as intended; however I call the command, the TopPanel doesn't change. It does work when I use the OnAdoptPolicy event, but that is for a split-second, after which it reverts to the default. So why is it, I wonder, that the command works in Firetuner perfectly.
 
If you want to write to the top panel, you need to subscribe to the same event triggers as TopPanel.lua (base game: Events.SerialEventGameDataDirty, Events.SerialEventTurnTimerDirty, Events.SerialEventCityInfoDirty) in order to overwrite what TopPanel itself writes each time its subscribed event runs (event suscribers are run by order of suscription, so make sure you subscribe *after* TopPanel.lua has initialized - in the same way as for LookUpControl ). If you want to change the tooltips, left click or right click actions, it's even easier: just grab the corresponding callback for yourself.
 
Back
Top Bottom