PDA

View Full Version : Adjusting Objects Defined by Templates



Kurst
12-20-2006, 01:34 PM
Is it possible to change aspects of an item (such as a text string) after it has been defined by a template? Consider this snippet:

http://img111.imageshack.us/img111/6948/codekt7.png

First, the template Nurfed_Unit_hp has a font size of 15. I want this particular health bar to have a smaller font size than is defined in the template, without creating a new template altogether. The line which has been struck out (Font = ...) does not work. Other ideas I had (such as text = { ... } confused Nurfed itself:

http://img187.imageshack.us/img187/6112/code2qq7.png

Is it necessary to create a second template to change the font of a single string of text?

Shield
12-20-2006, 01:46 PM
Nurfed_Unit_hp = {
type = "StatusBar",
FrameStrata = "LOW",
FrameLevel = 1,
StatusBarTexture = NRF_IMG.."statusbar10",
children = {
bg = {
type = "Texture",
layer = "BACKGROUND",
Texture = NRF_IMG.."statusbar10",
VertexColor = { 1, 0, 0, 0.25 },
Anchor = "all",
},
text = {
type = "FontString",
layer = "OVERLAY",
FontObject = "Nurfed_UnitFont",
JustifyH = "RIGHT",
ShadowColor = { 0, 0, 0, 0.75 },
ShadowOffset = { 1, -1 },
Anchor = { "RIGHT", "$parent", "RIGHT", -1, 1 },
vars = { format = "$cur/$max" },
},
},
-- vars = { ani = "glide" },
},

That is the template for Nurfed_Unit_hp, to change the text that appears on it, you'll change the bolded section.

It uses:

Nurfed_UnitFont = {
type = "Font",
Font = { NRF_FONT.."ClearFont.ttf", 10, "NONE" },
TextColor = { 1, 1, 1 },
},
To determine the font, change the bolded number to the fontsize you want. (Mine's customized so some things may be different, like the font type).

Kurst
12-20-2006, 03:41 PM
Thanks for trying to help, Shield. But if you're suggesting I modify the template to get the font size I wanted, you may have misinterpreted my question. I was asking whether there was a way to "tweak" a frame defined by a template, without modifying the template itself.

edit: While playing around with the layout, I figured it out:



player = {
children = {
hp = {
template = { "Nurfed_Unit_hp" },
children = {
text = { ... },
},
},
},
},


All I was missing was the "children" part. !@#$

fridgid
12-21-2006, 03:36 AM
It goes against convention though, to create a template, and then tell it to change one thing after using the template. Its bad policy and I wouldn't recommend it. Just make either a second template with different setttings, or don't use a template and type in it by hand.

a67rhf7823jn8747==