View Single Post
03-28-09, 02:05 AM   #237
jadakren
A Flamescale Wyrmkin
 
jadakren's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2007
Posts: 103
Regarding tagstrings,

I assume that it's not possible to return the contents of a function as a string?

idea i have is to edit tags and the functions that drive them, but in order to do this it seems I would need to provide them as strings and somehow execute them with loadstring.

ideas?

Code:
oUF.Tag["[name]"] = function(u)
 local func = "UnitName(u)"
 return u~=nil and loadstring(func) or func
end
I assume this would allow me to continue using the tagstring normally. But it would also allow me access to the function generating the output value, since i have such an approach for an ingame editor to obtain the internals for this tag :

Code:
function config:GetTagOptions(tag)
 local funcString = oUF.Tag[tag] or nil
 return (funcString~=nil and tostring(funcString())) or 'error'
end
function config:SetTagOptions(tag,funcData)
 oUF.Tags[tag] = function(u) 
  local func = funcData.func
  return loadstring(func)
 end
end
Here we suppose some kind of ingame editor is told to change the way the tagstring '[name]' behaves so that it makes names lowercase :
Code:
oUF.SetTagOptions('[name]',{func = 'UnitName(u):lower()'})
any ideas or thoughts to make this idea better/workable/more efficient or just maybe any kind of thoughts you have?

Last edited by jadakren : 03-28-09 at 08:58 AM.