Using addon in a macro
Hi all,
I have written a tiny addon that can summon different mounts randomly on categories depending on a custom parameter it will be passed. The general syntax is /mrc category1 /mrc category2 etc etc Now I like to use this addon in a macro so something like: /mrc [btn:1] category1 /mrc [btn:2] category2 but I suppose I have to use something more than this and probably to modify the addon to add some code to deal with it. P.s. The addon discussion and the addon is here: http://www.wowinterface.com/forums/s...ad.php?t=45113 Thanks for attention. |
Try /run SlashCmdList["MOUNTRNDCAT"]("category1")
|
If you're saying you want to implement macro option parsing for your addon, you can use SecureCmdOptionParse() for this.
Code:
SlashCmdList["MOUNTRNDCAT"] = function(args) On a side note, the usage of the underscore as a variable has no special meaning. It's just another valid variable name and is often used as such to shove unwanted values into to fetch values further down the list. |
Hi,
Thanks really very much for you replies and fixes to my bad code:-) I'll apply them and try as soon as I return home from work in the afternoon. Thanks again. |
Hi,
It seems to works (almost) everything. If I create a simple macro like this: /mrc [btn:1] ground /mrc [btn:2] flying ... etc etc ... It works like expected ... button1 cast a ground mount, button2 cast a flying mount but I got an error in bugrabber. Code:
MountRndCat-0.4\core.lua:11: bad argument #1 to "lower" (string expected, got nil) Code:
SLASH_MOUNTRNDCAT1 = "/mntrndcat"; |
I fixed the code I posted earlier. It appears when none of the conditions match for SecureCmdOptionParse(), it returns nil. At this point, the command should not be run. I added the check for this and have it exit immediately. I also fixed a potential error if the user were to call for a category that doesn't exist. The code is also more robust in the way that both the names in the table and the category name given through the arguments are case-insensitive.
|
Thanks really much for the patches and fixes SDPhantom.
I have corrected and modified the core.lua and everything seems to work great ... Only a little thing seems to not work as expected and I report (and continue to stress you :-) because I really don't understand why it is happening. The addon works great if you create a macro: Code:
/mrc [btn:1] ground But if add something like: Code:
/mrc [mod:shift, btn:1] funny Quote:
Probably it is due the fact it matches both the btn:1 condition and the shift+btn:1 condition retrieved by SecureCmdOptionParse. Now I experimenting a little bit and googling around to understand why this condition is not treated as one condition and not as matched as two different conditions. Thanks again really for your kind replies. |
If this is your macro:
Code:
/mrc [btn:1] ground If you want everything to be evaluated at the same time, you need to change it to only one slash command, so that all of the arguments are passed to the handler function at the same time: Code:
/mrc [btn:2] flying; [btn:3] repair; [mod:shift] funny; ground Code:
/cancelaura [btn:1] Lightning Shield |
Hi,
thanks for your reply. Even if I play wow for long time now I am really newbie in the macro and addon / lua field. Your fixes of my wrong way of write the macro works like a charm. Thanks again. |
All times are GMT -6. The time now is 01:43 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI