Quantcast LUA inside macro? - WoWInterface
Thread Tools Display Modes
06-25-19, 10:06 AM   #1
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 100
LUA inside macro?

I was looking to swap forms depending on conditions, and I have looked at some published macros but they use terminology which I do not understand, they do not work, or a bit of both.

In pseudo code I would like to press the same button to do this:

if indoors then Prowl if you can, else Cat
if outdoors then travel form
if already in some form then cancel form

During one of my attempts I tried to use a function (now I forget which) and I got a popup error "function only available to Blizzard UI"...

Could anyone please tell me if such a macro can be written ?
  Reply With Quote
06-25-19, 11:45 AM   #2
d87
A Flamescale Wyrmkin
 
d87's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 144
/cancelform [noform:0]
/stopmacro [noform:0]
/cast [nocombat,indoors] Prowl; [indoors] Cat Form; Travel Form
idk if it'll actually work, but along those lines

https://wow.gamepedia.com/Macro_conditionals
  Reply With Quote
06-25-19, 12:53 PM   #3
jeruku
A Chromatic Dragonspawn
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 199
So if memory serves, and I'm reading that wiki page right, the noform condition indicates you're not shapeshifted and form indicates you are.
Code:
/cancelform [form]
/stopmacro [form]
/cast [nocombat,indoors,form:2] Prowl; [indoors] Cat Form; Travel Form
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison

Last edited by jeruku : 06-25-19 at 12:54 PM. Reason: Force of habit to use $showtooltip
  Reply With Quote
06-25-19, 12:54 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,851
Originally Posted by d87 View Post
idk if it'll actually work, but along those lines
Code:
/cancelform [noform:0]
/stopmacro [noform:0]
/cast [nocombat,indoors] Prowl; [indoors] Cat Form; Travel Form
https://wow.gamepedia.com/Macro_conditionals
I don't think [form:0] exists. It's just [form] to match any. Also, /cancelform takes effect immediately and doesn't require a server response, making /stopmacro not actually work as you intended. On the other hand, /cast does require the server to respond so we can use that quirk instead. I also modified the macro to handle using Aquatic Form (part of Travel Form) while swimming too.

Here's the revised macro
Code:
/cast [form] ;[outdoors][swimming] Travel Form; [combat] Cat Form; Prowl
/cancelform [form]
PS: We force /cast to do nothing by sending no ability if in a form already. This lets you cancel your current form without casting a new one unintentionally. You can add a /stopmacro followed by a /cast to set a default icon if the question mark bothers you.



Originally Posted by jeruku View Post
So if memory serves, and I'm reading that wiki page right, the noform condition indicates you're not shapeshifted and form indicates you are.
Code:
/cancelform [form]
/stopmacro [form]
/cast [nocombat,indoors,form:2] Prowl; [indoors] Cat Form; Travel Form
In modern WoW, Prowl automatically activates Cat Form if not already in it. This may be the intended condition for the macro. However, in classic you can duplicate this effect by using /cast Cat Form on the line immediately preceding /cast Prowl. It works most of the time. I've only observed it failing once while playing a druid for 2 months.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 06-25-19 at 01:21 PM.
  Reply With Quote
06-25-19, 03:21 PM   #5
jeruku
A Chromatic Dragonspawn
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 199
I believe [form:0] is the equivalent to [noform]; of course it doesn't really matter since it doesn't change the amount of characters in use.

Wouldn't the empty [form] cause the macro to then do nothing while in any form causing it to skip Prowl even while in Cat Form? Also, doesn't Travel form already select its form based on internal conditions not unlike [swimming] and [noflying]?
  Reply With Quote
06-25-19, 04:21 PM   #6
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 100
Thanks for the ingenious macro coding.

Unfortunately it does not work, if Prowl is on CD it should just go to cat, but it just waits for Prowl to become available once more.

I will see if I can understand that wiki page.
  Reply With Quote
06-25-19, 05:31 PM   #7
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 100
OK, this is the macro that might be needed. Unfortunately we are severely limited by the macro buffer size as well as I do not know how to cast spells however I used print statements to show what the macro should do.

/script lST,lDR,lEN=GetSpellCooldown("Prowl");lCD=lST and (lST+lDR-GetTime()) or 9;lFRM=GetShapeshiftForm();lID=IsIndoors();if (lFRM==0) then if (lID) then if (lCD<=0) then print("PR"); else print("CT");end;else print("TR");end;else print("NR");end;
  Reply With Quote
06-26-19, 02:19 AM   #8
doofus
A Flamescale Wyrmkin
Join Date: Feb 2018
Posts: 100
Just to explain, I do not know how to combine a /script with /cast - eg

/script if (true) then /cast Moonfire; else /cast Sunfire; end;

Is that even possible ?
  Reply With Quote
06-26-19, 09:45 AM   #9
LudiusMaximus
A Flamescale Wyrmkin
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 116
The spell casting functions are PROTECTED so you cannot call them at will from within your lua code.
Otherwise, you could easily program a bot that plays by itself.
https://wow.gamepedia.com/API_CastSpellByName

There must always be an active user action triggering a spellcast, which you could maybe do with a SecureActionButtonTemplate. But as far as I understand, this will only allow you to cast one particular spell, so you would not be able to have some logic making the decision about which spell to cast.
Otherwise you could make a single button that always executes the ideal next spell of your rotation...

Last edited by LudiusMaximus : 06-26-19 at 10:00 AM. Reason: ...on second thought.
  Reply With Quote
06-26-19, 10:13 AM   #10
LudiusMaximus
A Flamescale Wyrmkin
 
LudiusMaximus's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2018
Posts: 116
Maybe you can do something similar to this:
https://us.forums.blizzard.com/en/wo...man-form/64405

So you would have one button, and depending on your current situation you bind the appropriate spell to that button... Have not thought this through. Just what came to mind...
  Reply With Quote
06-26-19, 01:11 PM   #11
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,851
Originally Posted by jeruku View Post
Wouldn't the empty [form] cause the macro to then do nothing while in any form causing it to skip Prowl even while in Cat Form?
It passes over /cast and triggers the following /cancelform.
Originally Posted by doofus View Post
if already in some form then cancel form


Originally Posted by jeruku View Post
Also, doesn't Travel form already select its form based on internal conditions not unlike [swimming] and [noflying]?
It shifts you into the appropriate sub-form, but it doesn't activate itself if it isn't already active.



Originally Posted by doofus View Post
if Prowl is on CD it should just go to cat, but it just waits for Prowl to become available once more.
Blizzard specifically removed the capability to cast spells by what's on cooldown. Since Prowl starts it's CD when you leave stealth, you can't even do this with /castsequence. The best bet is to take Prowl off your main shapeshift macro.

Alternatively, since Prowl doesn't work in combat, it is possible to create a SecureActionButton to run a default macro when in combat and monitor the cooldown when out of combat. This will likely be too large for a macro, so you'll need a custom addon to do it. You can either trigger it from a macro using /click or set a click binding.



Originally Posted by doofus View Post
Just to explain, I do not know how to combine a /script with /cast
Is that even possible ?
/script (and its alias /run) executes Lua code. The only thing you can do there is mess with the UI. It can't cast spells, activate abilities, or perform any other protected action directly.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 06-26-19 at 01:33 PM.
  Reply With Quote
06-26-19, 07:09 PM   #12
jeruku
A Chromatic Dragonspawn
 
jeruku's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 199
I see, just realized what you used [swimming] for, whether you're [indoors] or [outdoors] you'll use Travel Form so long as you're swimming.

And doofus(the OP), if you're not adverse to using modifiers you can always use Alt, Shift, and/or Ctrl.

Code:
#showtooltip
/cast [mod];[nocombat,form:0/2,indoors]Prowl;[outdoors][swimming] Travel Form;Cat Form
/cancelform [mod,form]
__________________
"I have not failed, I simply found 10,000 ways that did not work." - Thomas Edison
  Reply With Quote
06-28-19, 01:57 PM   #13
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 1,851
Originally Posted by jeruku View Post
Code:
#showtooltip
/cast [mod];[nocombat,form:0/2,indoors]Prowl;[outdoors][swimming] Travel Form;Cat Form
/cancelform [mod,form]
Even though it should technically work, not checking form on /cast when /cancelform is to run invites a race condition where /cancelform may cancel the /cast if the server responds fast enough.

Also, the auto-shift to cat form when using Prowl works in all forms.



PS: If Prowl is on CD and conditions are met, it would block use of Cat Form. This is why I suggested it should be seperated from the macro or at the very least, used on a modifier.
__________________
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 06-28-19 at 02:03 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » LUA inside 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