Thread Tools Display Modes
07-26-08, 07:52 AM   #1
laeg
A Murloc Raider
Join Date: Jul 2008
Posts: 5
Question 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?

Last edited by laeg : 07-26-08 at 08:39 AM.
  Reply With Quote
07-26-08, 09:16 AM   #2
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
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
]]);
__________________
たしかにひとつのじだいがおわるのお
ぼくはこのめでみたよ
だけどつぎがじぶんおばんだってことわ
しりたくなかったんだ
It's my turn next.

Shakespeare liked regexes too!
/(bb|[^b]{2})/
  Reply With Quote
07-26-08, 10:50 AM   #3
laeg
A Murloc Raider
Join Date: Jul 2008
Posts: 5
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.
  Reply With Quote
07-26-08, 10:56 AM   #4
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Firstly, do you have a toc? Second, that's xml code above, not lua.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-26-08, 12:20 PM   #5
laeg
A Murloc Raider
Join Date: Jul 2008
Posts: 5
Originally Posted by Seerah View Post
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:

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?
  Reply With Quote
07-26-08, 04:06 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
http://www.wowwiki.com/AddOns
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
07-27-08, 11:11 AM   #7
laeg
A Murloc Raider
Join Date: Jul 2008
Posts: 5
Question

Originally Posted by Seerah View Post
Firstly, do you have a toc? Second, that's xml code above, not lua.
Originally Posted by laeg View Post
No I don't have a toc
Originally Posted by Seerah View Post
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?

Last edited by laeg : 07-27-08 at 12:01 PM.
  Reply With Quote
07-27-08, 11:41 AM   #8
Masrim
A Defias Bandit
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 3
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.

Last edited by Masrim : 07-27-08 at 11:43 AM.
  Reply With Quote
07-27-08, 11:48 AM   #9
laeg
A Murloc Raider
Join Date: Jul 2008
Posts: 5
Originally Posted by Masrim View Post
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?

Originally Posted by Masrim View Post
Also have you restarted WoW yet? File tree changes don't take effect until you restart.
Yes.
  Reply With Quote
07-27-08, 12:11 PM   #10
Cralor
Mmm... cookies!!!
 
Cralor's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2007
Posts: 772
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.
__________________
Never be satisfied with satisfactory.

Last edited by Cralor : 07-27-08 at 12:14 PM.
  Reply With Quote
07-31-08, 08:08 AM   #11
Shirik
Blasphemer!
Premium Member
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2007
Posts: 818
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.
__________________
たしかにひとつのじだいがおわるのお
ぼくはこのめでみたよ
だけどつぎがじぶんおばんだってことわ
しりたくなかったんだ
It's my turn next.

Shakespeare liked regexes too!
/(bb|[^b]{2})/
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Creating a secure macro (>255) frame


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