WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Creating a secure macro (>255) frame (https://www.wowinterface.com/forums/showthread.php?t=17369)

laeg 07-26-08 07:52 AM

Creating a secure macro (>255) frame
 
I've learned that I can bypass the 255 character limit by using a secure macro frame but at the moment I'm still trying to learn how to do this. The following is the text from a file myfirstframe.xml which I create with a text editor and until I get my head around the method I'll just be using the macro as it stands (<255) in this file:
Code:

        <Button name="SecureActionButtonTemplate" inherits="SecureFrameTemplate" virtual="true">

                <Scripts>

                        <OnClick>

                                SecureActionButton_OnClick(self, button);

                                frame:SetAttribute("type", "macro"), ("macrotext", "#showtooltip\n/startattack\n/console Sound_EnableSFX 0\n/use [combat]
                                14\n/use [combat] item:25633\n/use [combat[ item:25937\n/console Sound_EnableSFX 1\n/castrandom [nomod]ghostly                                        strike,hemorrhage,ghostly strike; [target=mouseover,harm,nodead,mod][harm,nodead] Blind"
                        </OnClick>/

                        </OnClick>

                </Scripts>

        </Button>

Is this correct and how do I go about have this as a button on my action bar?

Shirik 07-26-08 09:16 AM

You have several problems:

Code:

frame:SetAttribute("type", "macro"), ("macrotext", "#showtooltip\n/startattack\n/console Sound_EnableSFX 0\n/use [combat]
                                14\n/use [combat] item:25633\n/use [combat[ item:25937\n/console Sound_EnableSFX 1\n/castrandom [nomod]ghostly                                        strike,hemorrhage,ghostly strike; [target=mouseover,harm,nodead,mod][harm,nodead] Blind"

Firstly, you can't chain calls like that. Ever.

Code:

frame:SetAttribute("type", "macro");
frame:SetAttribute("macrotext", "...macro goes here");

Secondly, you can't have line breaks in the middle of a string. If you really need them, you can use a long string style string, however keep in mind that when you use long strings, no escaping is done, so your \n will have to become actual line breaks (though this is probably better anyway):

Code:

frame:SetAttribute("macrotext", [[
#showtooltip
/startattack
/console Sound_EnableSFX 0
/use [combat] 14
/use [combat] item:25633
/use [combat] item:25937
/console Sound_EnableSFX 1
/castrandom [nomod] Ghostly Strike, Hemorrhage, Ghostly Strike; [target=mouseover,harm,nodead,mod][harm,nodead] Blind
]]);


laeg 07-26-08 10:50 AM

Thanks. I created a files GSHB2.lua and places it in a directory GSHB2 in my addons directory. It contains the following code:

Code:

        <Button name="GSHB2" inherits="SecureActionButtonTemplate" virtual="true">

                <Scripts>

                        <OnClick>

                                SecureActionButton_OnClick(self, button);

                                GSHB2:SetAttribute("type", "macro");
                                GSHB2:SetAttribute("macrotext", [[
                                #showtooltip
                                /startattack
                                /console Sound_EnableSFX 0
                                /use [combat] 14
                                /use [combat] item:25633
                                /use [combat] item:25937
                                /console Sound_EnableSFX 1
                                /castrandom [nomod] Ghostly Strike, Hemorrhage, Ghostly Strike; [target=mouseover,harm,nodead,mod][harm,nodead] Blind
                                ]]);

                        </OnClick>/

                        </OnClick>

                </Scripts>

        </Button>

..but it's not listed on the addons list in game so obviously part of the code on my part is wrong or I've gone about installing it all wrong. The secure frame link you gave me doesn't cover installation.

Seerah 07-26-08 10:56 AM

Firstly, do you have a toc? Second, that's xml code above, not lua.

laeg 07-26-08 12:20 PM

Quote:

Originally Posted by Seerah (Post 96636)
Firstly, do you have a toc? Second, that's xml code above, not lua.

No I don't have a toc, and re .lua somebody on IRC said:

Quote:

inherit means you do inherits="SecureActionButtonTemplate" instead of inherits="SecureFrameTemplate"

and then you name your button something like "MyButton"

and then you remove <OnClick>...</OnClick>, create a lua file for your addon, and do MyButton:SetAttribute("type", "macro"); MyButton:SetAttribute("macrotext", "<your macro here>")
so I thought I had to do something with lua.

I've saved it as GSHB2.xml now instead. What's next?

Seerah 07-26-08 04:06 PM

http://www.wowwiki.com/AddOns

laeg 07-27-08 11:11 AM

Quote:

Originally Posted by Seerah (Post 96636)
Firstly, do you have a toc? Second, that's xml code above, not lua.

Quote:

Originally Posted by laeg (Post 96648)
No I don't have a toc

Quote:

Originally Posted by Seerah (Post 96659)

I followed that guide and created the following file GSHB.toc which now resides in /interface/addons/GSHB:

Code:

## Interface: 20400
## Title: GSHB
## Notes: Extended macro
## Author: laeg
## eMail: [email protected]
## Version: 1.0
## DefaultState: enabled
GSHB.xml

Accompanying GSHB.toc in /interface/addons/GSHB is GSHB.xml which contains the following code:

Code:

        <Button name="GSHB" inherits="SecureActionButtonTemplate" virtual="true">

                <Scripts>

                        <OnClick>

                                SecureActionButton_OnClick(self, button);

                                GSHB:SetAttribute("type", "macro");
                                GSHB:SetAttribute("macrotext", [[
                                #showtooltip
                                /startattack
                                /console Sound_EnableSFX 0
                                /use [combat] 14
                                /use [combat] item:25633
                                /use [combat] item:25937
                                /console Sound_EnableSFX 1
                                /castrandom [nomod] Ghostly Strike, Hemorrhage, Ghostly Strike; [target=mouseover,harm,nodead,mod][harm,nodead] Blind
                                ]]);

                        </OnClick>

                </Scripts>

        </Button>

GSHB is as yet not listed under the Addons list on the character selection screen so I would very much appreciate it if somebody could identify the problem for me and also tell me how to access the button in game when it is working correctly, for example will it appear in my macro list, somewhere on my action bar or perhaps in my spellbook?

Masrim 07-27-08 11:41 AM

You need dependencies and a lua file. Also you need a header in the xml refering to the lua file as script source.
Also have you restarted WoW yet? File tree changes don't take effect until you restart.

laeg 07-27-08 11:48 AM

Quote:

Originally Posted by Masrim (Post 96722)
You need dependencies and a lua file. Also you need a header in the xml refering to the lua file as script source.

I was told on #wowuidev that since I don't have any dependencies I leave out the line ## Dependencies:. What dependencies does it have? I thought that line was for addons that rely on other addons to run.

What needs to go in the lua file? I understood it all to be contained in the xml file. Re: header in the xml refering to the lua file as script source: isn't xml the script?

Quote:

Originally Posted by Masrim (Post 96722)
Also have you restarted WoW yet? File tree changes don't take effect until you restart.

Yes.

Cralor 07-27-08 12:11 PM

I'm novice to Lua and XML, so I don't know if I am wording this correctly.

The code you have in your XML file now is Lua code. XML is used to make the frames and set up the Scripts for Lua.

From what I am reading you should do this: (This won't work, just the idea. (Or at least I don't believe so.))

Lua file:
Code:

local GSHB = CreateFrame("frame")

frame:SetAttribute("macrotext", [[
#showtooltip
/startattack
/console Sound_EnableSFX 0
/use [combat] 14
/use [combat] item:25633
/use [combat] item:25937
/console Sound_EnableSFX 1
/castrandom [nomod] Ghostly Strike, Hemorrhage, Ghostly Strike; [target=mouseover,harm,nodead,mod][harm,nodead] Blind
]]);

What ever you do in the XML file, is continued in the Lua file.

If you set up a button with an OnClick script, you have to go back to the Lua file and make a function for that script.
Example (Lua file):
Code:

function GSHB_OnClick()
 SendChatMessage("I just clicked the Button!")

The XML "makes" the button, positions it, anchors it, etc. The Lua does all the functions and what the button will do when you click it.

Scripts can be made in Lua as well, but I am not sure if you need XML or not for this addon.

Hope this helps clarify some.

Shirik 07-31-08 08:08 AM

Get rid of OnClick. You have no control of OnClick from a secure button.

The type/macrotext attributes need to be set OnLoad. Everything after that will be handled for you automatically.


All times are GMT -6. The time now is 12:19 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI