Thread Tools Display Modes
01-22-10, 06:58 PM   #1
Safturento
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 13
Lua for Stuf

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
  Reply With Quote
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
01-27-10, 04:43 PM   #3
Drshow
A Cyclonian
 
Drshow's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 49
also you maybe just wanna save the string you are filtering to savedvar first. I found this will avoid amost all nil issues "aside from server side latency where the data doent get downloaded before the function is ran".
__________________
  Reply With Quote
01-28-10, 08:22 AM   #4
Zyonin
Coffee powered Kaldorei
 
Zyonin's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 1,443
If my memory is correct (it's been a few month since I last played), Stuf uses the LuaTexts module for custom Lua tags (same one as used for Pitbull4). You may want browse through the official LuaTexts thread over on the WoWAce forums:

http://forums.wowace.com/showthread.php?t=16955
__________________
Twitter
  Reply With Quote
01-28-10, 10:24 PM   #5
alimjocox
A Warpwood Thunder Caller
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 96
no STUF uses a significantly different (not completely) style of Lua text. Im pretty sure the LuaText you posted is for PB4 mate, (ive spent quite some time learnning basic Lua using PB4 and STUF, i managed to pretty much master it but then i moved to oUF) . You should look through the stuf lua code to notice the patterns and functions STUF uses.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Lua for Stuf


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off