Thread Tools Display Modes
12-19-10, 04:53 PM   #1
izbatt
A Defias Bandit
Join Date: Dec 2010
Posts: 2
Help for a new addon creator

Hey Guys quick run down.
For my first addon I wanted to write a very simple addon that has a few buttons that do a few simple tasks that I was always typing to do (i.e. /invite, /love, etc...)
After creating my addon I have a nice frame of 4 buttons. invite, guild invite, love, and a button that moves the frame around. Everything works fine.

So then I wanted to add a button that would cast my Hearthstone.
So I put my hearthstone in slot 1 of my back pack and tried running UseContainerItem(0,1);
when the button is pushed. I get a Blizzard UI has blocked this operation error.

Is there a way around this or a better way to do it?
I have researched and researched and can't seem to find anything
I tried casting by spell but got nothing and now i'm stuck.
Any help would be much appreciated.

My code:
XML code for button:
<Button name="$parent_Hearth_Button" parent="SimpleButtons_MainFrame">
<Size>
<AbsDimension x="27" y="25" />
</Size>
<Anchors>
<Anchor point="TOP">
<Offset>
<AbsDimension x="0" y="-5" />
</Offset>
</Anchor>
</Anchors>
<NormalTexture file="Interface\Addons\SimpleButtons\SB_UI\SB_H" />
<HighlightTexture file="Interface\Addons\SimpleButtons\SB_UI\SB_H_HL" />
<Scripts>
<OnClick>
SB_Hearth_OnClick();
</OnClick>
</Scripts>
</Button>

LUA code:
function SB_Hearth_OnClick()
UseContainerItem(0,1);--is blocked by Blizzard UI
end


PS i know I could just use an action bar but I don't want to use up my bars as I seem to use them all for different stuff.
  Reply With Quote
12-19-10, 07:19 PM   #2
Nobgul
A Molten Giant
 
Nobgul's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 693
Its a protected function. You physically need to click the hearthstone. From time to time you will get those blizzard blocked messages, it just means that you cannot do it. As a work around and not sure if it will even work .


You could try moving the hearthstone to a action slot and then try to have the button on the addon click the slot ie. /click MultiActionBar1Button12


Or w/e it could be. I think it will still be protected but worth a try.
__________________
[SIGPIC][/SIGPIC]
  Reply With Quote
12-19-10, 10:25 PM   #3
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,919
I've not used items that way but seeing as the healthstone is technically a cast I would assume the same would apply and you will have to use the special protected action button template and set the various options up.

This link might start you off in the right direction. It's where I started learning about them at any rate.

http://www.wowwiki.com/SecureActionButtonTemplate
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
12-20-10, 04:02 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,322
Originally Posted by nobgul View Post
You could try moving the hearthstone to a action slot and then try to have the button on the addon click the slot ie. /click MultiActionBar1Button12
It still taints the execution path, therefore would still be blocked by Blizzard.

The only way around is to get into SecureActionButtons, which isn't easy for someone to learn. It's a method Blizzard set up for addons to use most of these protected functions the way they want us to.

To do this, you need to create a button object that inherits SecureActionbuttonTemplate. Whatever you do, do not set the OnClick handler on this. It'll overwrite the secure code inherited. Instead, see the comment section below copied from SecureTemplates.lua.
Code:
--
-- SecureActionButton
--
-- SecureActionButtons allow you to map different combinations of modifiers and buttons into
-- actions which are executed when the button is clicked.
--
-- For example, you could set up the button to respond to left clicks by targeting the focus:
-- self:SetAttribute("unit", "focus");
-- self:SetAttribute("type1", "target");
--
-- You could set up all other buttons to bring up a menu like this:
-- self:SetAttribute("type*", "menu");
-- self.showmenu = menufunc;
--
-- SecureActionButtons are also able to perform different actions depending on whether you can
-- attack the unit or assist the unit associated with the action button.  It does so by mapping
-- mouse buttons into "virtual buttons" based on the state of the unit. For example, you can use
-- the following to cast "Mind Blast" on a left click and "Shadow Word: Death" on a right click
-- if the unit can be attacked:
-- self:SetAttribute("harmbutton1", "nuke1");
-- self:SetAttribute("type-nuke1", "spell");
-- self:SetAttribute("spell-nuke1", "Mind Blast");
-- self:SetAttribute("harmbutton2", "nuke2");
-- self:SetAttribute("type-nuke2", "spell");
-- self:SetAttribute("spell-nuke2", "Shadow Word: Death");
--
-- In this example, we use the special attribute "harmbutton" which is used to map a virtual
-- button when the unit is attackable. We also have the attribute "helpbutton" which is used
-- when the unit can be assisted.
--
-- Although it may not be immediately obvious, we are able to use this new virtual button
-- to set up very complex click behaviors on buttons. For example, we can define a new "heal"
-- virtual button for all friendly left clicks, and then set the button to cast "Flash Heal"
-- on an unmodified left click and "Renew" on a ctrl left click:
-- self:SetAttribute("*helpbutton1", "heal");
-- self:SetAttribute("*type-heal", "spell");
-- self:SetAttribute("spell-heal", "Flash Heal");
-- self:SetAttribute("ctrl-spell-heal", "Renew");
--
-- This system is very powerful, and provides a good layer of abstraction for setting up
-- a button's click behaviors.
Note: This inherits a protected frame, as such, it cannot be shown/hidden, moved, or have any attributes changed by addon code while in combat lockdown.



Edit: Didn't see the link posted up above. I even ran a search on "SecureActionButton" on WoWWiki and it returned nothing.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 12-20-10 at 04:06 PM.
  Reply With Quote
12-20-10, 06:51 PM   #5
izbatt
A Defias Bandit
Join Date: Dec 2010
Posts: 2
Thanks guys, this is exactly what I needed to continue work! I knew I was missing something and just needed a push in the right direction.
-Izbatt
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Help for a new addon creator

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