WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Cast Druid Forms (https://www.wowinterface.com/forums/showthread.php?t=59723)

Buenclima 11-30-23 01:22 PM

Cast Druid Forms
 
Hello! :)

I started developing an addon and I have encounter an issue. (Wotlk Classic)

The addon is able to cast the spell of mounts owned by the user.
The user can store his flying and ground mount and with a simple macro:
“/ms mount” the addon checks if the flying can be done or not (it also checks if possible to use fly in Dalaran), then it casts the spell.

With Druid forms, it is an actual spell and it is protected, I have read the documentation and tried to do like a button using the secure template but no luck… (Example)

Code:

# Example 1
function DebugCastSwiftFlightForm()
    print("Druid Casting")
 
    local btn = CreateFrame("Button", "SwiftFlightFormButton", UIParent, "SecureActionButtonTemplate")
 
    -- Set the macro to cast Swift Flight Form
    btn:SetAttribute("type", "macro")
    btn:SetAttribute("macrotext", "/cast [nostance] Swift Flight Form; [stance:2] !Swift Flight Form")
 
 
    btn:Click("LeftButton")
 
    btn:Hide()
end

Code:

# Example 2
function DebugCastSwiftFlightForm()
    local btn = CreateFrame("Button", "SwiftFlightFormButton", UIParent, "SecureActionButtonTemplate")
 
    -- Set the spell to Swift Flight Form
    btn:SetAttribute("type", "spell")
    btn:SetAttribute("spell", "Swift Flight Form")
 
   
    btn:Click("LeftButton")
end

With Paladins, the mount is available in the new mounts journal so It actually works.

Anyone could help me find information or an example to implement a secure way to cast the flying forms of a druid?

Thank you!

P.S. Here you can have a look at the code (it is my first addon, please forgive me): https://github.com/ravelaso/MountSwitcher

SDPhantom 11-30-23 08:50 PM

Secure actions can't be run from the command line except for /click. The only alternatives are by physically clicking a button or running a keybind.

Xrystal 11-30-23 09:15 PM

This might help, or at least explain if it doesn't help. Sounds like the same problem you are having.

https://github.com/Stanzilla/WoWUIBugs/issues/268

SDPhantom 12-09-23 12:41 AM

They're calling :Click() directly, which carries their addon taint and throws an action blocked error.
This is completely different than the issue with depending on CVar settings, SecureActionButton templates only activate on either up or down, so you have to register both to function reliably.

Xrystal 12-09-23 01:08 PM

Ah .. I totally missed that line


All times are GMT -6. The time now is 08:15 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI