Lua IconHookup/Lookup question

Sneaks

Brooklyn Bum
Joined
Oct 15, 2010
Messages
1,877
Location
NYC
For IconLookup and Hookup,

first question: What is the difference?

second question: Is the fourth value the name of the variable the icon is being stored locally?

For example would the line
Code:
local IconLookup( 0, 32, "SNCIT_ATLAS", bureaucratTexture);
store the first icon of the 32pix SNCIT_ATLAS to the variable bureaucratTexture?

Would this line do anything differently?
Code:
local bureaucratTexture = IconLookup( 0, 32, "SNCIT_ATLAS", bureaucratTexture);

For reference, I am trying to assign a variable name to the icon so that I can display a new specialist icon in cityview. The game has a separate .dds for each specialist on top of the atlas, which seems awfully redundant.

If anyone can give me feedback, it would be most welcome!
 
IconLookup tells you which entries in the icon file correspond to the building/action/whatever you're trying to place an icon for. It's not an assignment function, it's a lookup.
IconHookup sets the icon variables for a given UI button to the values obtained from IconLookup (or to values acquired some other way). For obvious reasons it tends to come right after an IconLookup call.

You can't just use an arbitrary format for IconLookup; the first example you gave would only work if it's a Void, the second only if it's an Int. While I don't have the files in front of me, I think it returns a 2-element array, so neither of those would work right IIRC. And again, it's not an assignment function, so it's probably not what you want anyway.

The easiest thing to do when trying to figure out the way to call a function is to just look at an example of something that already uses it. For instance, TechButtonInclude.lua (in the UI/InGame/TechTree/ directory) has some good examples of how to use both of these functions; it's the Lua that tells the game how to plot all the little 45-pixel icons in the tech tree boxes, so I've edited it pretty heavily for my own mod.
 
Alas. I would just make individual .dds files but for some reason, all of the individual specialist ones, such as citizenartist.dds look either corrupt or just packed in a way where I cannot read them in photoshop.
 
A related question: how would it work if done with ContextPtr?

For example, there is this line in the citybanner.lua:
Code:
IconHookup( civInfo.PortraitIndex, 32, civInfo.AlphaIconAtlas, controls.MinorIndicator )
If I'd want to change it, would that be done with something like:
Code:
IconHookup( myIndex, 32, myAtlas, ContextPtr:LookupControl("/InGame/CityBannerManager/MinorIndicator") )

To me that seems like how it's supposed to work, but I thought I'd ask to see if someone knows.
 
Back
Top Bottom