PDA

View Full Version : Secure Functions for casting?


ChaosInc
02-07-2007, 05:16 AM
Trying to add buttons to cast portals in Mage Taxi, but I havn't coded since pre-2.0 when "CastSpell" wasn't protected. I've looked over the information over at wowwiki, and I understand the concept of the new Secure Functions. However, it doesn't explain where to set the commands in order for it to work. Here's what I have:

------------
<Button name="$parent_Port1" inherits="SecureActionButtonTemplate" text="Cast!">
<Anchors>
<Anchor point="RIGHT" relativeTo="$parent_City1">
<Offset><AbsDimension x="0" y="0"/></Offset>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
this:SetAttribute("unit",nil);
this:SetAttribute("type1", "spell");
this:SetAttribute("spell1","Heroic Strike");
</OnLoad>
<OnClick></OnClick>
</Scripts>
</Button>
------------

When I load it up, the button doesn't appear, so obviously I'm doing something wrong.

Daviesh
02-07-2007, 02:14 PM
As far as I am aware, you need to also set this.SpellID, which is the ID of where the spell is in your spellbook.

Feel free to dig through my code here and see how I got it to work:

http://www.daviesh.net/atlasloot_enhanced/Other_Mods/DavAspectFrame.zip

ChaosInc
27-07-2007, 04:59 PM
Still can't get a custom button to work. According to wowwiki, it doesn't state anything about needed a spell id:

spell

Casts a spell.
Attributes:
spell (string) The name of the spell to cast. For example, "Flash Heal".
unit (unitid) The unit to cast the spell on. Defaults to player's target.

Example:
frame:SetAttribute("type1", "spell")
frame:SetAttribute("spell1", "Flash Heal")
frame:SetAttribute("shift-spell1", "Greater Heal")

-----------------

My code:

<Scripts>
<OnLoad>
this:SetAttribute("unit","none");
this:SetAttribute("type1", "spell");
this:SetAttribute("spell1", "Portal: Stormwind");
this:Show();
</OnLoad>
<OnClick>
</OnClick>
</Scripts>


Everything else about the button works fine; I can get it to appear and such, just can't click it to do anything.

Jumpy
27-07-2007, 06:17 PM
My button works and here is what I have. I think you need to register for clicks.
<OnLoad>
this:RegisterForClicks("LeftButtonUp");
this:SetAttribute("type1", "spell");
this:SetAttribute("spell1", "Conjure Water(rank 1)")
</OnLoad>

ChaosInc
27-07-2007, 06:23 PM
<------- NOOBSAUCE!

Oh jeez, I forgot to register the click. :shocked:

Thanks for the help, works now. :cool: