Prospecting Lua Script Help
Trying to learn Lua, and starting really simple.
I have made a button that appears in the middle of my screen. I can make the button do many things, such as leave groups, dance, random rolls, summon creatures, etc etc.
When i try to cast a spell via this same button, i get the protected blah blah message. What i am trying to do is prospect some ore, when i push the button.
A simple macro of /cast Prospecting, /cast Obsidium Ore works just fine, but since i am trying to do this via an addon, i cant figure it out.
I know things like: CastSpellByName("Prospecting") no longer work (protected), but other addons are able to prospect ore, by clicking a button. Even reading through the code of those addons, i cant seem to piece it together :(
Beginner Code i am working with
local Button = CreateFrame("Button", "MyButton", UIParent, "UIPanelButtonTemplate")
Any simple solutions?
When it comes to buttons casting spells there is not exactly an easy solution ;)
Your button should inherit a secure template. A good start to learn what you need is
local macroBtn = CreateFrame("Button", "Prospect", UIParent, "SecureActionButtonTemplate");
With the above code using the SecureActionButtonTemplate, i am able to cast Prospecting like i wanted. The problem now is, i can not get the button to show.
I can use /click Prospect and it fires just fine, but obviously im missing something to show the button, just not sure where i went wrong :(
The secure template only takes care of the protected stuff :)
For visuals you need 'ActionButtonTemplate' :)
You can inherit more than one template "ActionButtonTemplate SecureActionButtonTemplate"
In addition to inheriting from ActionButtonTemplate (which will give you the hover/pushed textures) you also need to set the icon texture for the button.
Get the correct texture file using the GetSpellInfo API:
|All times are GMT -6. The time now is 01:32 AM.|
vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI