WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Lua for Stuf (https://www.wowinterface.com/forums/showthread.php?t=30191)

Safturento 01-22-10 06:58 PM

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

Drshow 01-27-10 04:41 PM

Quote:

Originally Posted by Safturento (Post 175700)
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

Drshow 01-27-10 04:43 PM

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".

Zyonin 01-28-10 08:22 AM

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

alimjocox 01-28-10 10:24 PM

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.


All times are GMT -6. The time now is 06:11 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI