Reply
Thread Tools Display Modes
Unread 12-07-13, 06:35 PM   #1
jjforums
A Flamescale Wyrmkin
Join Date: Jul 2009
Posts: 106
Call lua script from Macro?

Is possible to call a lua script from Macros?

I was search about it, and I saw that macros can't perform some actions, but lua scripts can.

Via /run, because using this, seems that we can bypass the "default macro conditionals".

Is there way to do that?
Thanks.

Last edited by jjforums : 12-07-13 at 06:45 PM.
jjforums is offline   Reply With Quote
Unread 12-07-13, 09:27 PM   #2
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,746
You can put a "/run" command in a macro. "/run" is just a slash command that executes whatever comes after it as raw Lua code, whereas "/cast" is a slash command that takes what comes after it and passes it to a pre-defined block of Lua code that casts the named spell, etc.

However, if there is something you cannot do in a "macro" (eg. "cast Spell A if it's off cooldown, otherwise Spell B" or "if the unit's health is below 20% cast X, otherwise cast Y") then you cannot do that from a "Lua script" either. Most "macro commands" -- like /cast and /use -- exist because Blizzard does not want your macro or addon making decisions about which spells to cast. They want you, the player, to have to pay attention and use a little brain power to go "oh, this unit's health is below 20%, I should use my execute ability" -- not be able to mash a single button and have some lines of code look at all the conditions and make the decision for you.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!
Phanx is offline   Reply With Quote
Unread 12-07-13, 10:47 PM   #3
jjforums
A Flamescale Wyrmkin
Join Date: Jul 2009
Posts: 106
thanks phanx...

i thought if theres possible to make it in lua, would be possible to make a macro with it... i saw some examples with health conditional (didn't try)

so, is it possible to make something like:

cast spell x; cast y and keep repeating y spell for x seconds

tried with reset but i think it doesn't work as i expected
jjforums is offline   Reply With Quote
Unread 12-07-13, 11:43 PM   #4
Phanx
A Pyroguard Emberseer
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 4,746
/castsequence reset=20 SpellA, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB, SpellB

... is about the closest you can get. It sounds like you're trying to make a button that casts X if it's off cooldown, or Y otherwise, and that is exactly the kind of thing Blizzard does not want an addon/macro to be able to do. They want you to pay attention to your cooldowns, pay attention to your target's health, and make your own decisions in realtime about what abilities to use.

Personally I just use a modifier key for combining a cooldown ability with another ability. It's really no more effort than having a manual reset on the castsequence, and gives me much better control over when the cooldown ability gets used.

/cast [mod:alt] SpellA; SpellB

Edit:
I'm not sure what kind of addon you're talking about with a "health conditional" but I can tell you right now that it's not automatically casting Spell A or Spell B based on the target's health without the user doing anything different when pressing the button, such as holding a modifier key or clicking with a different mouse button. You can have an addon show you some kind of alert, such as flashing a giant icon on your screen, when you should cast Spell A instead of Spell B, but the addon can't change which spell your button casts based on that information.
__________________
Author/maintainer of Grid, PhanxChat, ShieldsUp, and many more.
Troubleshoot an addonTurn any code into an addonMore addon resources
Need help with your code? Post all of your actual code! Attach or paste your files.
Please don’t PM me about addon bugs or code questions. Post a comment or forum thread instead!

Last edited by Phanx : 12-07-13 at 11:48 PM.
Phanx is offline   Reply With Quote
Unread 12-12-13, 11:05 AM   #5
jjforums
A Flamescale Wyrmkin
Join Date: Jul 2009
Posts: 106
But here's a conditional:

/run local t="target"if (UnitHealth(t) / UnitHealthMax(t)) < 0.90 then SendChatMessage("Die, scum!","yell")end

The thing is, this just show a text instead of casting a spell, and for sending chat message, it works.

i thought about using modfiers but i already use modifiers to cast different spells with keys: 1-6, f1-f6, and shift as modifier, i guess i have to start using alt and ctrl too.
jjforums is offline   Reply With Quote
Unread 12-12-13, 11:49 AM   #6
Resike
A Molten Giant
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 654
Originally Posted by jjforums View Post
But here's a conditional:

/run local t="target"if (UnitHealth(t) / UnitHealthMax(t)) < 0.90 then SendChatMessage("Die, scum!","yell")end

The thing is, this just show a text instead of casting a spell, and for sending chat message, it works.

i thought about using modfiers but i already use modifiers to cast different spells with keys: 1-6, f1-f6, and shift as modifier, i guess i have to start using alt and ctrl too.
You can't cast spell based on functions like that, only sending messages, else you could make macros which only kick the target when it's casting, making it almost impossible to fake cast. Thats how rtards got Gladiator in Season 1 and Season 2.
Resike is offline   Reply With Quote
Unread 12-12-13, 01:46 PM   #7
ravagernl
Premium Member
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 1,156
This is what AddOns like AutoRogue used to do in vanilla. It's just plain cheating. You can't do it anymore and I'm glad for it.
ravagernl is offline   Reply With Quote
Unread 12-12-13, 02:59 PM   #8
jjforums
A Flamescale Wyrmkin
Join Date: Jul 2009
Posts: 106
Ok, thanks!
jjforums is offline   Reply With Quote
Reply

Go BackWoWInterface » AddOns, Compilations, Macros » Macro Help » Call lua script from Macro?

Thread Tools
Display Modes

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