Replacing a Leader Icon with LUA

OzzyMandice

Chieftain
Joined
Apr 4, 2021
Messages
2
Is this possible?
I've been trying at this for a bit but my dummy brain that's new to LUA hasn't been exactly able to do this— basically, what I'm trying to do is to change the leader icon (and leader scene too, if possible) under certain circumstances.

I've tried using IconHookup with something like this:
Code:
IconHookup( 2, 128, "CIV_COLOR_ATLAS_WARFANG_LEGENDS", Controls.Portrait);
but I think I'm using that wrong, or doing something wrong, as FireTurner spits back that image control: nil (although I did make sure to include IconSupport.lua).

I've also tried importing it to VFS, but that didn't seem to work either— I'm supposed to be loading it with InGameUIAddin, right?

Thanks for your help in advance, and sorry if this is in the wrong section or something, I've never used a forum before.
 
Is this possible?
I've been trying at this for a bit but my dummy brain that's new to LUA hasn't been exactly able to do this— basically, what I'm trying to do is to change the leader icon (and leader scene too, if possible) under certain circumstances.
Vice made a utility to change leaderscenes mid-game, so that should certainly be possible!

As for the leader icon, you're attempting to change Controls.PortraitIndex. UI files consist of a pair of a Lua file (defining all the interactions and doing the processing) and an xml file (defining the base layout/structure). When using Controls.PortraitIndex in a UI Lua file, you're essentially referring to the PortraitIndex element in the related UI xml file. It does not refer to the PortraitIndex element in other UI files, which is why the icon is not changing.
Note: Since you're not wanting to add a new UI ("just" modifying existing ones), there's no need for an xml file (I did the write-up to explain why your current approach is not working)

The leader icon is located across many different UI contexts (e.g. the civilopedia, the diplo popup, etc.). While I think it might be possible to do by using :LookUpControl(..) and its shenanigans to change the icon in all these different contexts individually, I don't have the knowledge/experience with that method.

P.s. this is the correct (sub)forum ;)
 
As for the leader icon, you're attempting to change Controls.PortraitIndex. UI files consist of a pair of a Lua file (defining all the interactions and doing the processing) and an xml file (defining the base layout/structure). When using Controls.PortraitIndex in a UI Lua file, you're essentially referring to the PortraitIndex element in the related UI xml file. It does not refer to the PortraitIndex element in other UI files, which is why the icon is not changing.
Note: Since you're not wanting to add a new UI ("just" modifying existing ones), there's no need for an xml file (I did the write-up to explain why your current approach is not working)

Ah, that's a shame. I've fiddled around with it myself but that looks extremely painful for someone who has 0 experience with Civ UI so far, maybe when I know more I can come back to it

That leaderscene utility though is very useful though, thank you for pointing that my way! (and thanks to vice for making it as well). For now I can definitely use that along with the dialogue util for a similar effect to what I'm looking for.
 
Back
Top Bottom