Thread Tools Display Modes
01-17-14, 06:26 PM   #1
jinppa
A Murloc Raider
AddOn Compiler - Click to view compilations
Join Date: May 2009
Posts: 5
Hide name whilst casting.

Hi there,

Just looking for some help with Stuf and LUA. I'm wanting to hide the player name whilst they cast and show the spell name instead.

I'm a totally clueless when it comes to LUA but after searching I managed to find
Code:
if UnitCastingInfo(unit) or UnitChannelInfo(unit) then
    return ""
else
    return UnitName(unit)
end
But I don't know how to start that off.

Really appreciate any help.
  Reply With Quote
01-17-14, 09:08 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Code:
local name, _, text = UnitCastingInfo(unit)
if not name then
	name, _, text = UnitChannelInfo(unit)
end
if not name then
	name = UnitName(unit)
end
return text or name
If there's a field for entering a list of events that should trigger an update (I don't use Stuf) it needs to include:
  • UNIT_NAME
  • UNIT_SPELLCAST_START
  • UNIT_SPELLCAST_STOP
  • UNIT_SPELLCAST_CHANNEL_START
  • UNIT_SPELLCAST_CHANNEL_STOP
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-18-14, 03:15 AM   #3
jinppa
A Murloc Raider
AddOn Compiler - Click to view compilations
Join Date: May 2009
Posts: 5
Originally Posted by Phanx View Post

If there's a field for entering a list of events that should trigger an update (I don't use Stuf) it needs to include:
  • UNIT_NAME
  • UNIT_SPELLCAST_START
  • UNIT_SPELLCAST_STOP
  • UNIT_SPELLCAST_CHANNEL_START
  • UNIT_SPELLCAST_CHANNEL_STOP
That looks much better, thanks! But there isn't a field to call a trigger, is that something we could also put in LUA?
  Reply With Quote
01-18-14, 08:07 AM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
No; LuaStrings tags don't have access to the internals of LuaTexts, so they can't register events for themselves. I haven't actually looked at the LuaTexts code in depth, but I'd guess it just parses your tag text to figure it out, if it doesn't ask you for the events. Does the tag I posted not update when the unit starts/stops casting?
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-18-14, 10:04 AM   #5
jinppa
A Murloc Raider
AddOn Compiler - Click to view compilations
Join Date: May 2009
Posts: 5
Oh okay, no nothing displays. However when hovering over the input area for custom LUA is gives a format that they must follow.

Looks like this:
Code:
function(unit, cache, textframe) return 'text' end
Does that help at all?
  Reply With Quote
01-18-14, 10:50 AM   #6
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, that's a pretty useless error message... I can't tell whether it's complaining that you need to actually write "function(unit, cache, textframe)" and "end" around the text, or whether it's complaining that it's not getting a string (which could only happen if it's being stupid and calling the function for a nonexistent unit, such as the target unit when you aren't targeting anything). Try adding either the blue parts or the green parts, or maybe both:

Code:
function(unit, cache, textframe)
	local name, _, text = UnitCastingInfo(unit)
	if not name then
		name, _, text = UnitChannelInfo(unit)
	end
	if not name then
		name = UnitName(unit)
	end
	return text or name or ""
end
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-18-14, 11:10 AM   #7
jinppa
A Murloc Raider
AddOn Compiler - Click to view compilations
Join Date: May 2009
Posts: 5
It doesn't appear as an error message, just as like a tip when you start writing in the box.

I added what you said, the green text displays the targets name, but doesn't change to the spell they are casting. With the blue or just the blue exclusively it displays nothing.

If this is going to take up too much of your time I'm not really too fussed. Naive me thought it would have been simple ha!

Thanks for all your help!

Last edited by jinppa : 01-18-14 at 11:12 AM. Reason: Words
  Reply With Quote
01-18-14, 12:03 PM   #8
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Well, you'll have to figure out how to tell LuaTexts when to update the text, or hope someone who actually uses it can tell you... I have no idea, and no time (or desire) to poke around in its code to figure it out, sorry.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
01-18-14, 12:08 PM   #9
jinppa
A Murloc Raider
AddOn Compiler - Click to view compilations
Join Date: May 2009
Posts: 5
Me being as blind and as dumb as I am, there was a check box below for 'Frequent Updates' which makes it work.

Thanks again for all the help!

Last edited by jinppa : 01-18-14 at 12:25 PM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Hide name whilst casting.


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