Thread: Lua for Stuf
View Single Post
01-27-10, 04:41 PM   #2
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
Originally Posted by Safturento View Post
I've been using Stuf, and find the pattern tags to be somewhat limited. I've tried using the custom lua text on it, but my knowledge of lua is very limited and it has an odd format that I don't quite understand. Is there any place or anyone that could explain to me how it works? Another way would be to convert
Code:
local s = Status(unit)
if s then
  return s
end
local cur, max = HP(unit), MaxHP(unit)
return "%s/%s || %s%%",Short(cur,true),Short(max,true),Percent(cur,max)
into what it would be in Stuf, and maybe I could use that as a model to work with.

Thanks in advance,
-Saft
with this are you running into "nil" issues. I was having similar issues with an addon of mine. The easiest for me has been to convert. EG.
-- the sample string is 95511|TInterface\\MoneyFrame\\UI-GoldIcon:0:0:2:0|t 5|TInterface\\MoneyFrame\\UI-SilverIcon:0:0:2:0|t 12|TInterface\\MoneyFrame\\UI-CopperIcon:0:0:2:0|t
  1. i had to isolate the individual demominations with match
  2. next i had to remove the data i didnt want EG. |TInterface\\MoneyFrame\\UI-CopperIcon:0:0:2:0|t
    1. = = txt:match("%d+|TInterface\\MoneyFrame\\UI%-CopperIcon:0:0:2:0|t");
      1. %d+ = all occurences of all digits with matching string text.
  3. i put a couple links below that helped me to understand match and sub.

Code:
-- match
  local iscopper = txt:match("%d+|TInterface\\MoneyFrame\\UI%-CopperIcon:0:0:2:0|t");
  if (iscopper == nil or iscopper == "") then
  iscopper = "0";
  end
  local issilver = txt:match("%d+|TInterface\\MoneyFrame\\UI%-SilverIcon:0:0:2:0|t");
  if (issilver == nil or issilver == "") then
  issilver = "0";
  end
  local isgold = txt:match("%d+|TInterface\\MoneyFrame\\UI%-GoldIcon:0:0:2:0|t");
  if (isgold == nil or isgold == "") then
  isgold = "0";
  end
-- replace
  local iscopper1 = iscopper:match("%d+");
  if (iscopper1 == nil or iscopper1 == "") then
  iscopper1 = "0";
  end
  local issilver1 = issilver:match("%d+");
  if (issilver1 == nil or issilver1 == "") then
  issilver1 = "0";
  end
  local isgold1 = isgold:match("%d+");
  if (isgold1 == nil or isgold1 == "") then
  isgold1 = "0";
  end
http://www.wowwiki.com/API_strmatch for matching .
http://www.wowwiki.com/Pattern_matching for all patterns
__________________
  Reply With Quote