Thread: Lua XML Basics
View Single Post
07/24/14, 01:36 PM   #4
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by zgrssd View Post
Atributes:
There are also conventinal XML atributes. They are always of type string.
In XML it always looks like a string, but interpretation may vary depending on the attribute. Some examples:

offsetX="-5" ... used in <Anchor>, this attribute probably undergoes ivalue = tonumber(value) before being passed to control:SetAnchor(...)

point="LEFT" ... named constant, not sure whether point="2" (since LEFT == 2) would work; but I still think it's converted to integer at some point, ivalue = _G[value]

color="3a6b9c" ... hex color code, may be parsed by a, r, g, b = ConvertHTMLColorToFloatValues(value)

color="INTERFACE_COLOR_TYPE_ALLIANCE:ALLIANCE_DAGGERFALL_COVENANT" ... another way of specifying color; the conversion would look something like:
Lua Code:
  1. local colorType, colorIndex = value:match("(%w+):(%w+)")
  2. local r, g, b, a = GetInterfaceColor(colorType, colorIndex)
I'm not saying these conversions are done in Lua code, I only tried to illustrate how they'd be done in Lua.

Last edited by merlight : 07/24/14 at 06:03 PM.
  Reply With Quote