This site makes extensive use of JavaScript.
Please enable JavaScript in your browser.
Classic Theme
Thottbot Theme
Help w/ debugging addon
Post Reply
Return to board index
Post by
JASP01
So, using Addon Studio, I managed to create an addon that basically has 4 buttons:
Button 1: Cast Army of the Dead
Button 2: Raise Dead
Button 3: Dark Transformation
Button 4: Death Pact
Eventually I want to do a similar one with Warlock abilities.
Anyhow
, the buttons show, so the code is correct... but nothing happens when I click... am I coding something wrong? Here's an example in the .lua file:
function Button1_OnClick()
........CastSpellByName(Army of the Dead)
end
(The periods are placeholders for actual spaces... for wowhead formatting)
So... what did I do wrong?
Post by
HighFive
CastSpellByName is a protected function, which means it can only be called from secure (Blizzard) code.
Look into secure templates.
Post by
JASP01
so for thorns, wowwikki says
<Attributes>
<Attribute name="type" type="string" value="spell"/>
<Attribute name="spell" type="string" value="Thorns"/>
<Attribute name="unit" type="string" value="player"/>
</Attributes>
... but if the ability is a cast, not a buff, would you still use value="player", or something else?
Edit:
http://www.wowwiki.com/SecureTemplates
also says "xml only"... so is a .lua file even needed for this type of addon?
Thanks!
Post by
JASP01
Hate bumping, but I still need my last question answered. It's ethical, isn't it?
Bump.
Post by
Wanderingfox
http://www.wowwiki.com/SecureActionButtonTemplate
Is what you're going to need.
Something like this: (
dry code, purely an example
)
local btn = CreateFrame("Button", "myButton", UIParent, "SecureActionButtonTemplate")
btn:SetAttribute("type", "spell")
btn:SetAttribute("spell", "Army of the Dead")
If you needed to target something, you'd add something like:
btn:SetAttribute("target","<someUnitID>")
Where <someUnitID> is a valid unit identifier, ie. "player" "target" "focus" etc.
Try not to bump posts that haven't fallen off the first page. I don't think 17 minutes really warranted a bump.
Post by
JASP01
Thanks!
Post by
JASP01
Um... using
local btn = CreateFrame("Button", "myButton", UIParent, "SecureActionButtonTemplate")
btn:SetAttribute("type", "spell")
btn:SetAttribute("spell", "Army of the Dead")
gave me critical errors every time I tried to log onto one of my chars... what's up with that?
Post by
Wanderingfox
What error and where? Can't really help if you don't provide more information
:P
Post by
JASP01
This application has encountered a critical error:
ERROR #132 (0x85100084) Fatal Exception
Program: C:\Program Files\World of Warcraft\WoW.exe
Exception: 0xC0000005 (ACCESS_VIOLATION) at 001B:004FE9A1
The instruction at "0x004FE9A1" referenced memory at "0x00030003".
The memory could not be "read".
...Every time I would try to login to one of my chars. Didn't happen before I put the code in, and stopped happening once I took the folder with that addon out.
Really appreciate the help!
Post by
Wanderingfox
Thats not an addon error. That's something wrong with your game client itself. It shouldn't be possible for you to crash the client with an addon since all of the Lua code is run in a sandbox.
Post by
JASP01
It only happened when the addon was running, and only when I put the code in there. Any ideas how to fix it? I already ran the WoW repair tool. Thanks!
Post by
Vlad
Certain LUA code can make the game crash, I had several encounters with specific code making #132 errors occur and memory issues, and the game crashed. I didn't think it would pass over to the retail release, well I haven't tried to run your addon, but if I ran it and also crashed then it's sure that the problem is on Blizzards side and not the client.
Post by
JASP01
So... if it's the code... do I wait for the problem to be fixed, or use different code, or... what?
Thanks!
Post by
Vlad
Well it would be nice if you post the whole code you use, so one of us can try to run it and see if it crashes our client. If it does, then it's a Blizzard issue, if not then it's something with your client or some other code on your side that does something...
For now I as well suspect your client to be at fault, until we can see if the code crashes on other clients or not. :)
Post by
JASP01
Frame.xml:
<Ui xmlns="
http://www.blizzard.com/wow/ui/"
xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.blizzard.com/wow/ui/
..\..\FrameXML\UI.xsd">
<Script file="Frame.lua" />
<Frame name="Frame1" parent="UIParent" toplevel="true" movable="true" enableMouse="true">
<Size>
<AbsDimension x="165" y="38" />
</Size>
<Anchors>
<Anchor point="CENTER">
<Offset x="-50" y="-129" />
</Anchor>
</Anchors>
<Backdrop bgFile="Interface\DialogFrame\UI-DialogBox-Background" edgeFile="Interface\DialogFrame\UI-DialogBox-Border" tile="true">
<BackgroundInsets>
<AbsInset left="11" right="12" top="12" bottom="11" />
</BackgroundInsets>
<TileSize>
<AbsValue val="32" />
</TileSize>
<EdgeSize>
<AbsValue val="32" />
</EdgeSize>
</Backdrop>
<Frames>
<Button name="Button1" inherits="SecureActionButtonTemplate" parent="UIParent" text="AotD">
<Size>
<AbsDimension x="35" y="32" />
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="3" y="-3" />
</Anchor>
</Anchors>
<Scripts>
<OnClick>Button1_OnClick();</OnClick>
</Scripts>
<ButtonText font="Fonts\FRIZQT__.TTF">
<FontHeight>
<AbsValue val="12" />
</FontHeight>
<Color r="1" g="1" b="0" />
</ButtonText>
</Button>
<Button name="Button2" inherits="SecureActionButtonTemplate" parent="UIParent" text="RD">
<Size>
<AbsDimension x="35" y="32" />
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="45" y="-3" />
</Anchor>
</Anchors>
<Scripts>
<OnClick>Button2_OnClick();</OnClick>
</Scripts>
<NormalColor r="0.83" g="0.82" b="0.78" />
</Button>
<Button name="Button3" inherits="SecureActionButtonTemplate" parent="UIParent" text="DT">
<Size>
<AbsDimension x="35" y="32" />
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="86" y="-3" />
</Anchor>
</Anchors>
<Scripts>
<OnClick>Button3_OnClick();</OnClick>
</Scripts>
</Button>
<Button name="Button4" inherits="SecureActionButtonTemplate" parent="UIParent" text="DP">
<Size>
<AbsDimension x="35" y="32" />
</Size>
<Anchors>
<Anchor point="TOPLEFT">
<Offset x="127" y="-3" />
</Anchor>
</Anchors>
<Scripts>
<OnClick>Button4_OnClick();</OnClick>
</Scripts>
<ButtonText font="Fonts\FRIZQT__.TTF">
<FontHeight>
<AbsValue val="12" />
</FontHeight>
<Color r="1" g="1" b="0" />
</ButtonText>
</Button>
</Frames>
<Scripts>
<OnDragStop>self:StopMovingOrSizing();</OnDragStop>
<OnDragStart>self:StartMoving();</OnDragStart>
<OnLoad>self:RegisterForDrag("LeftButton");</OnLoad>
</Scripts>
</Frame>
</Ui>
Frame.lua:
local btn = CreateFrame("Button1_OnClick()", "myButton", UIParent,
"SecureActionButtonTemplate")
btn:SetAttribute("type", "spell")
btn:SetAttribute("spell", "Army of the Dead")
local btn = CreateFrame("Button2_OnClick()", "myButton", UIParent,
"SecureActionButtonTemplate")
btn:SetAttribute("type", "spell")
btn:SetAttribute("spell", "Raise Dead")
local btn = CreateFrame("Button3_OnClick()", "myButton", UIParent,
"SecureActionButtonTemplate")
btn:SetAttribute("type", "spell")
btn:SetAttribute("spell", "Dark Transformation")
local btn = CreateFrame("Button4_OnClick()", "myButton", UIParent,
"SecureActionButtonTemplate")
btn:SetAttribute("type", "spell")
btn:SetAttribute("spell", "Death Pact")
Thanks!
Post by
JASP01
Bump
Post by
Vlad
It's not your client but the code itself that crashes the game. I haven't specifically found why but several things, like: "local btn = ..." is declared several times, each time it overwrites the old "btn" in the memory and each frame is named the same name. One way to fix this would be to use this LUA code:
local btn = CreateFrame("Frame", "Button1", UIParent, "SecureActionButtonTemplate")
btn:SetAttribute("type", "spell")
btn:SetAttribute("spell", "Army of the Dead")
btn = CreateFrame("Frame", "Button2", UIParent, "SecureActionButtonTemplate")
btn:SetAttribute("type", "spell")
btn:SetAttribute("spell", "Raise Dead")
btn = CreateFrame("Frame", "Button3", UIParent, "SecureActionButtonTemplate")
btn:SetAttribute("type", "spell")
btn:SetAttribute("spell", "Dark Transformation")
btn = CreateFrame("Frame", "Button4", UIParent, "SecureActionButtonTemplate")
btn:SetAttribute("type", "spell")
btn:SetAttribute("spell", "Death Pact")
You see that "btn" is defined once as a local variable and re-declared for the other buttons. We still got the ability to go back as "Button1" and so on are the global names for these buttons. For example having "/click Button1" in a macro would make you cast Army of the Dead.
About the XML, it's never been my favorite and prefer to make GUI via pure LUA but I don't think that crashes the game.
Post by
JASP01
Ah, thanks! Just what I was looking for.
Post by
JASP01
Well, tried it, the frame was created (and the right size)... but the buttons were missing...
Post Reply
You are not logged in. Please
log in
to post a reply or
register
if you don't already have an account.