Thread Tools Display Modes
08-24-16, 11:09 AM   #1
MuffinManKen
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 106
Icon for Macrotext, SecureCmdOptionParse oddity

Given a chunk of macrotext, I'm trying to find the appropriate icon to show. Most of the time SecureCmdOptionParse gives me the spell/item so I can query further, but not always.

1) It ignores #show/#showtooltip
2) It gives odd results when there are no conditionals:
/dump SecureCmdOptionParse("/cast []Mend Pet")
gives "Mend Pet"
/dump SecureCmdOptionParse("/cast Mend Pet")
gives "/cast Mend Pet"

So I'm trying to first manually look for #show/#showtooltip, then run SecureCmdOptionParse, but then I have to check manually for "/cast" or "/use" (and maybe others?) and manually strip them.

Is there an easier/better way? It feels fragile.
  Reply With Quote
08-24-16, 11:50 AM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
You aren't actually supposed to include "/cast" in the string you're feeding to SecureCmdOptionParse, just the condition and command.
  Reply With Quote
08-24-16, 11:53 AM   #3
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
You're not meant to include anything other than the actual conditionals and their results. It doesn't recognise slash commands. I don't know how SecureCmdOptionParse("/cast []Mend Pet") works, but the result is probably intended, as that's not a valid syntax. SecureCmdOptionParse("/cast Mend Pet") works as intended. Again, it has no notion of slash commands and doesn't interpret anything other than macro conditionals. You're only meant to include the part that comes after the slash command.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
08-24-16, 12:26 PM   #4
MuffinManKen
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 106
Given a chunk of macrotext, I'm trying to find the appropriate icon to show.

Is there an easier/better way?
  Reply With Quote
08-24-16, 12:30 PM   #5
Lombra
A Molten Giant
 
Lombra's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 554
Without placing the macro on an action bar; probably not.
__________________
Grab your sword and fight the Horde!
  Reply With Quote
08-24-16, 01:19 PM   #6
MuffinManKen
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2009
Posts: 106
In case anyone else needs something like this, this is what I'm using now. It seems really hacky, but it works in all of my test cases. My original version has a bunch of debug stuff strewn throughout, which I just deleted. Without all of that it can be cleaned up further, but this might help someone as is.
Code:
	local show_action = string.match(p_macro_body, "#show%s*([^\n]+)")
	if(show_action) then return show_action end;

	local show_tt_action = string.match(p_macro_body, "#showtooltip%s*([^\n]+)")
	if(show_tt_action) then return show_tt_action end;

	local cast_action = string.match(p_macro_body, "/cast%s*([^\n]+)")

	local use_action = string.match(p_macro_body, "/use%s*([^\n]+)")

	local secure_parse = SecureCmdOptionParse(cast_action or use_action)
	if(secure_parse) then return secure_parse end;
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Icon for Macrotext, SecureCmdOptionParse oddity


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