WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   LUA inside macro? (https://www.wowinterface.com/forums/showthread.php?t=57229)

doofus 06-25-19 10:06 AM

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 ?

d87 06-25-19 11:45 AM

Quote:

/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

jeruku 06-25-19 12:53 PM

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


SDPhantom 06-25-19 12:54 PM

Quote:

Originally Posted by d87 (Post 332528)
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.



Quote:

Originally Posted by jeruku (Post 332531)
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.

jeruku 06-25-19 03:21 PM

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]?

doofus 06-25-19 04:21 PM

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.

doofus 06-25-19 05:31 PM

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;

doofus 06-26-19 02:19 AM

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 ?

LudiusMaximus 06-26-19 09:45 AM

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...

LudiusMaximus 06-26-19 10:13 AM

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...

SDPhantom 06-26-19 01:11 PM

Quote:

Originally Posted by jeruku (Post 332537)
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.
Quote:

Originally Posted by doofus (Post 332524)
if already in some form then cancel form



Quote:

Originally Posted by jeruku (Post 332537)
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.



Quote:

Originally Posted by doofus (Post 332546)
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.



Quote:

Originally Posted by doofus (Post 332560)
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.

jeruku 06-26-19 07:09 PM

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]


SDPhantom 06-28-19 01:57 PM

Quote:

Originally Posted by jeruku (Post 332587)
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.


All times are GMT -6. The time now is 11:41 AM.

vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2019 MMOUI