Thread Tools Display Modes
06-10-11, 05:25 AM   #21
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Originally Posted by Nibelheim View Post
Debug time! Hmm, I wonder if print works in Lua Text Is fast update ticked?
Still nothing, and yes it is... Idk whats' going on. I never attempted to do this before, so I have no idea what needs to be done for it to work... BEH!
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote
06-10-11, 05:30 AM   #22
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Lily.Petal View Post
Still nothing, and yes it is... Idk whats' going on. I never attempted to do this before, so I have no idea what needs to be done for it to work... BEH!
May be something wrong with the setup of that particular Lua Text. Missing events, settings... something. Hopefully the answer comes along soon Wish I knew more about Stuf to help more.

What if you try just:
Code:
return "Hello World"
Get any text appear?


As for me, I'm late for an appointment with my bed
  Reply With Quote
06-10-11, 05:36 AM   #23
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Originally Posted by Nibelheim View Post
May be something wrong with the setup of that particular Lua Text. Missing events, settings... something. Hopefully the answer comes along soon Wish I knew more about Stuf to help more.

What if you try just:
Code:
return "Hello World"
Get any text appear?


As for me, I'm late for an appointment with my bed
Nope, not at all. Sorry for keeping you up Nib :<
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote
06-10-11, 06:59 AM   #24
Canities
A Wyrmkin Dreamwalker
Join Date: Oct 2007
Posts: 54
Cant remember where i got this from but it might help with the showing of power/mana issue for stuf...

Code:
local pType, pTypeStr = UnitPowerType(unit)
local pPower = UnitPower(unit, pType)
if pType == 1 || pType == 3 || pType == 6 then
  -- Rage, Energy, RP
   if pPower > 0 then
     -- do whatever here for displaying
   end
else
   -- energy is mana etc
   if pPower < UnitMaxPower(unit, pType) then
     -- show mana etc stuff here
   end
end
Actually i found where i got that peice of cade, its on another thread on the forum: Stuf Unit LUA help which has a load more custom LUA for stUF for anyone thats intrested.

Last edited by Canities : 06-10-11 at 10:13 AM.
  Reply With Quote
06-10-11, 08:20 PM   #25
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
It's because you're not using a function. Just an if statement.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-10-11, 08:28 PM   #26
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Originally Posted by Seerah View Post
It's because you're not using a function. Just an if statement.
Hmm, shouldn't need to wrap the code in a function. Would be very odd if that's the case. Then again, I've only used Pitbull's Lua Text, which may be entirely different to Stuf's implementation.
  Reply With Quote
06-10-11, 08:29 PM   #27
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Lily.Petal View Post
Hm, using stuf it says when I switch to LUA:
Lua Code must have this format:
function(unit, cache, textframe) <some text> return 'text', ... end where 'cache' may be used as cache.infotag (see pattern help or core.lua) and "..." are optional arguments to SetFormattedText.
function(unit, cache, textframe) return 'text' end
Yep. These are the instructions/example. ^^
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-10-11, 08:40 PM   #28
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Omoshiroi. In that case:

Code:
function(unit)
	local _, pToken = UnitPowerType(unit)
	local pCur, pMax = Power(unit), MaxPower(unit)
	if pMax > 0 then
		if pToken == "RAGE" or pToken == "RUNIC_POWER" then
			-- Warrior / Teddy Bear Druid / DK
			if pCur > 0 then 
				return "%d", pCur
			end
		elseif pToken == "ENERGY" then
			-- Rogue / Kitty Druid
			if pCur < pMax then
				return "%d", pCur
			end
		else
			-- Everything else
			local pPer = ceil(pCur / pMax)
			if pPer < 100 then
				return "%d", pPer
			end
		end
	end
end

Last edited by Nibelheim : 06-10-11 at 08:44 PM.
  Reply With Quote
06-10-11, 08:48 PM   #29
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Originally Posted by Nibelheim View Post
Omoshiroi. In that case:

*SNIP*
Ill go test this right meow~

EDIT: Still didn't work or show up :<

Going to try the one Canites posted real fast

EDIT2: Tried the link (s)he gave:

Code:
function(unit)
  local name, level = UnitName(unit), UnitLevel(unit)
  local clcolor = RAID_CLASS_COLORS[select(2, UnitClass(unit))]
  if (name and string.len(name) > 10) then 
    name = string.gsub(name, "([^%s]+) ", function(s) return string.sub(s,1,1) .. "." end)
  end
  return "%s |cff%02x%02x%02x%s|r", level, clcolor.r*255, clcolor.g*255, clcolor.b*255, name
end
This worked as intended. So I know it's not from my side.
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah

Last edited by Lily.Petal : 06-10-11 at 08:58 PM.
  Reply With Quote
06-10-11, 09:01 PM   #30
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Originally Posted by Taryble View Post
Well, it's mostly for doing things that StUF's (fairly limited) tag system won't handle.

...

Here's a more interesting text that I use (my "Power" text).
Code:
function(unit, cache, textframe)
  local powtype, maxmp, curmp = UnitPowerType(unit), UnitPowerMax(unit), UnitPower(unit)
  local cc = PowerBarColor[powtype]
  local permp = 100*curmp/maxmp 
  if (powtype == 1 or powtype == 3) then
    local _, class = UnitClass(unit)
    if (class == "DRUID" and unit == "player") then
      local maxdmp, curdmp, ccd = UnitPowerMax(unit,0), UnitPower(unit,0), PowerBarColor[0]
      if curdmp ~= maxdmp then
        return "|cff%02x%02x%02x%.0f|r%% | |cff%02x%02x%02x%s|r",ccd.r*255,ccd.g*255,ccd.b*255,100*curdmp/maxdmp,cc.r*255,cc.g*255,cc.b*255,curmp
      else
        return "|cff%02x%02x%02x%s|r",cc.r*255,cc.g*255,cc.b*255,curmp 
      end
    else        
      return "|cff%02x%02x%02x%s|r",cc.r*255,cc.g*255,cc.b*255,curmp
    end 
  elseif curmp ~= maxmp then 
    return "|cff%02x%02x%02x%.0f|r%%",cc.r*255,cc.g*255,cc.b*255,permp 
  elseif powtype == 0 then 
    return "|cff%02x%02x%02x%s|r",cc.r*255,cc.g*255,cc.b*255,maxmp 
  end
end
This one is rather fun. Basically, if you're a druid in shapeshift form, it shows your rage/energy - and if you're below full mana, it shows your mana as a percentage (separated by a pipe character). If you're a Warrior or Rogue, it just shows your rage/energy.

If you're anything else, it shows your percentage of power - but if you're at full power, it just shows your maximum power. (ie, 99% OR 78532, for example).

And, yes, all you Lua coders out there, please feel free to take a look at it and give me advice on how to make it better.

I haven't really done any programming since 1997, and Lua wasn't very common back then, so this is all sorta tossed together with half-remembered scraps of programming theory and style.
Maybe this may be of some help?
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah

Last edited by Lily.Petal : 06-10-11 at 09:03 PM.
  Reply With Quote
06-10-11, 09:01 PM   #31
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Woops, my bad, I left some Pitbull code in my examples

Code:
function(unit)
	local pCur, pMax = UnitPower(unit), UnitPowerMax(unit)
	if pMax > 0 then
		local _, pToken = UnitPowerType(unit)
		if pToken == "RAGE" or pToken == "RUNIC_POWER" then
			-- Warrior / Teddy Bear Druid / DK
			if pCur > 0 then 
				return "%d", pCur
			end
		elseif pToken == "ENERGY" then
			-- Rogue / Kitty Druid
			if pCur < pMax then
				return "%d", pCur
			end
		else
			-- Everything else
			local pPer = ceil(pCur / pMax)
			if pPer < 100 then
				return "%d", pPer
			end
		end
	end
end
  Reply With Quote
06-10-11, 09:06 PM   #32
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
You. Are. Simply. Amazing.

Thank you for all your hard work everyone; Nib, Seerah, Canities.

I will make sure to edit my 1st post to show the correct examples as well as a link that Canities posted for anyone who searches for this

EDIT: I forgot about my Threat bar! ROFL :>
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote
06-10-11, 09:29 PM   #33
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Or for some extra features:

Code:
function(unit)
	local pCur, pMax, mCur, mMax = UnitPower(unit), UnitPowerMax(unit), UnitPower(unit, 0), UnitPowerMax(unit, 0)
	if pMax > 0 then
		local pType, pToken = UnitPowerType(unit)
		local pColor = PowerBarColor[pType]
		if ( (pToken ~= "MANA") and (mMax > 0) ) then	-- Druid in Bear/Cat form
			local mColor = PowerBarColor[0]
			local mPer = ceil(mCur / mMax)
			local ShowPower, ShowMana
			if ((pToken == "RAGE") and (pCur > 0)) or ((pToken == "ENERGY") and (pCur < pMax)) then 
				ShowPower = true
			end
			if mPer < 100 then
				ShowMana = true
			end
			if ShowPower and ShowMana then
				return "|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r", pColor.r * 255, pColor.g * 255, pColor.b * 255, pCur, mColor.r * 255, mColor.g * 255, mColor.b * 255, mPer
			elseif ShowPower then
				return "|cff%02x%02x%02x%s|r", pColor.r * 255, pColor.g * 255, pColor.b * 255, pCur
			elseif ShowMana then
				return "|cff%02x%02x%02x%s|r", mColor.r * 255, mColor.g * 255, mColor.b * 255, mPer
			end
		elseif pToken == "RAGE" or pToken == "RUNIC_POWER" then		-- Warrior / DK
			if pCur > 0 then 
				return "|cff%02x%02x%02x%s|r", pColor.r * 255, pColor.g * 255, pColor.b * 255, pCur
			end
		elseif pToken == "ENERGY" then	-- Rogue
			if pCur < pMax then
				return "|cff%02x%02x%02x%s|r", pColor.r * 255, pColor.g * 255, pColor.b * 255, pCur
			end
		else	-- Everything else
			local pPer = ceil(pCur / pMax)
			if pPer < 100 then
				return "|cff%02x%02x%02x%s|r", pColor.r * 255, pColor.g * 255, pColor.b * 255, pPer
			end
		end
	end
end
Dry coded, so may not work

Edit: I wonder if Stuf supports MouseOver. In Pitbull you can just say If IsMouseOver() then and do cool things, like showing different values on mouseover.

Last edited by Nibelheim : 06-10-11 at 09:42 PM.
  Reply With Quote
06-10-11, 09:50 PM   #34
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Originally Posted by Nibelheim View Post
Or for some extra features:

*SNIPE*

Dry coded, so may not work

Edit: I wonder if Stuf supports MouseOver. In Pitbull you can just say If IsMouseOver() then and do cool things, like showing different values on mouseover.
OOH looks lovely, and Stuf has a toggle option if MouseOvers, it's pretty cool!

Gonna see if I can get your threat bar to work now :>
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote
06-12-11, 08:27 PM   #35
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Something seemed odd earlier today when I was in a group...

My party members definitely did not have 1% mana lol :P
Even after mana went down (2nd image) the text didn't change.

Same thing with Hunter Focus :<
Attached Thumbnails
Click image for larger version

Name:	WoWScrnShot_061211_222530.jpeg
Views:	858
Size:	642.5 KB
ID:	6258  Click image for larger version

Name:	WoWScrnShot_061211_223750.jpeg
Views:	854
Size:	582.0 KB
ID:	6259  
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah

Last edited by Lily.Petal : 06-12-11 at 09:00 PM.
  Reply With Quote
06-12-11, 09:58 PM   #36
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Sounds like I forgot a *100. xPer lines need to read: xPer = ceil((xCur / xMax) * 100)

Code:
function(unit)
	local pCur, pMax, mCur, mMax = UnitPower(unit), UnitPowerMax(unit), UnitPower(unit, 0), UnitPowerMax(unit, 0)
	if pMax > 0 then
		local pType, pToken = UnitPowerType(unit)
		local pColor = PowerBarColor[pType]
		if ( (pToken ~= "MANA") and (mMax > 0) ) then	-- Druid in Bear/Cat form
			local mColor = PowerBarColor[0]
			local mPer = ceil((mCur / mMax)*100)
			local ShowPower, ShowMana
			if ((pToken == "RAGE") and (pCur > 0)) or ((pToken == "ENERGY") and (pCur < pMax)) then 
				ShowPower = true
			end
			if mPer < 100 then
				ShowMana = true
			end
			if ShowPower and ShowMana then
				return "|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r", pColor.r * 255, pColor.g * 255, pColor.b * 255, pCur, mColor.r * 255, mColor.g * 255, mColor.b * 255, mPer
			elseif ShowPower then
				return "|cff%02x%02x%02x%s|r", pColor.r * 255, pColor.g * 255, pColor.b * 255, pCur
			elseif ShowMana then
				return "|cff%02x%02x%02x%s|r", mColor.r * 255, mColor.g * 255, mColor.b * 255, mPer
			end
		elseif pToken == "RAGE" or pToken == "RUNIC_POWER" then		-- Warrior / DK
			if pCur > 0 then 
				return "|cff%02x%02x%02x%s|r", pColor.r * 255, pColor.g * 255, pColor.b * 255, pCur
			end
		elseif pToken == "ENERGY" then	-- Rogue
			if pCur < pMax then
				return "|cff%02x%02x%02x%s|r", pColor.r * 255, pColor.g * 255, pColor.b * 255, pCur
			end
		else	-- Everything else
			local pPer = ceil((pCur / pMax)*100)
			if pPer < 100 then
				return "|cff%02x%02x%02x%s|r", pColor.r * 255, pColor.g * 255, pColor.b * 255, pPer
			end
		end
	end
end
  Reply With Quote
06-12-11, 10:32 PM   #37
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Thank you nib~
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote
08-13-11, 05:18 PM   #38
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
Sorry about the necro threading, but the actual reason of this thread wasn't done :P While it's awesome to get my Power Text like this, my threat question wasn't finished ;D Any ideas?

Originally Posted by Lily.Petal
I am currently wanting to make a small threat meter using Stuf's custom LUA text option.

All I want it to do is just show My current Threat% (without the % sign please) on my target, the color being Stuf's HP Red Color.

If someone could offer assistance, I would appreciate it greatly!

*~Lily.Petal~*
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote
08-13-11, 05:27 PM   #39
Nibelheim
local roygbi-
 
Nibelheim's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 1,600
Code:
function(unit)
    local _, _, threatpct, _, threatvalue = UnitDetailedThreatSituation(unit, "target")
    if threatvalue then
        return "|cffff0000%d|r", floor(threatpct)
    else
        return ""
    end
end
If you make this a LuaText on the Player frame, and use Seerah's OnUpdate instructions, it should work.

LuaTexts can be set to run (a slightly throttled, iirc) OnUpdate if you check the "frequent updates" box.
May have to adjust the |cffff0000 (format is |caarrggbb) if the red color is off. Or someone may know Stuf's Health Color variable.
  Reply With Quote
08-13-11, 05:33 PM   #40
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
And you're still a God! Thank you Nib, I'll test this asap~

Originally Posted by Nibelheim View Post
SNIP
If you make this a LuaText on the Player frame, and use Seerah's OnUpdate instructions, it should work.

May have to adjust the |cffff0000 (format is |caarrggbb) if the red color is off. Or someone may know Stuf's Health Color variable.
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Stuf + Threat

Thread Tools
Display Modes

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