Problems with TagCompiler-1.0 #1


  • New
  • Defect
Open
Assigned to _ForgeUser122481
  • _ForgeUser98420 created this issue Dec 23, 2008

    i am the current "maintainer" of the version of Aloft over at WoWInterface.

    a user reported a problem with text tags recently, using TagCompiler-1.0 r70. i dug into it, and i will lay it out for you (on the assumption it might need attention, and the library author would have more coherent ideas about what to do with it than i would).

    if an Aloft text field (i.e. "Name Text") contains the following tag text:

    > [IsFriendly:Name:White][~IsFriendly:Name:Red]

    this results in a formatting function loadstring that looks like this (reformatted slightly for readability):

    > local TagCompiler = AceLibrary("TagCompiler-1.0")
    > local tagMethodHexColor = TagCompiler.tagCompilerData["HexColor"].method
    > return function(data)
    >   return
    >     tagMethodHexColor(data, (data.type == "friendlyPlayer" or data.type == "friendlyNPC") and data.name, "ffffff")..
    >     tagMethodHexColor(data, not ((data.type == "friendlyPlayer" or data.type == "friendlyNPC")) and data.name, "ff0000")
    >   end

    in this sort of mutually-exclusive tag construct, one or the other of the boolean conditions involving "(data.type == "friendlyPlayer" or data.type == "friendlyNPC")" is going to evaluate to "false" for any given unit, and "false" will be passed into the "value" parameter of TagCompiler.CommonTagData.HexColor.method:

    > method = function(data, value, colorValue) return value and ("|cff"..colorValue..value.."|r") end,

    this function returns "false", not a string, and this results in a "Attempt to concatenate boolean value" error back up in the formatting function loadstring. what i think i need in tag methods like this one is something like:

    > method = function(data, value, colorValue) return (value and ("|cff"..colorValue..value.."|r")) or "" end,

    so that i get an empty string out of the formatting process if "value" evaluates to "false".

    what do you think? should this instead be done a completely different way at the tag level to begin with (ColorIf, or whatever)? if so, i can pass that along to the user. in the meantime, i have tweaked my local copy of TagCompiler-1.0 to generate empty strings, as a safety, out of formatting that should ultimately return strings. i don't know what side-effects that could have (i will do some testing).

    thanks for any ideas you can contribute.

  • _ForgeUser98420 added the tags New Defect Dec 23, 2008

To post a comment, please login or register a new account.