WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Questions on macro texts (https://www.wowinterface.com/forums/showthread.php?t=56711)

zork 09-26-18 04:06 AM

Questions on macro texts
 
I lately wrote myself a pull timer since I do not use DBM or Bigwigs atm.
https://github.com/zorker/rothui/blo...Timer/core.lua

The pull timer activates when I click the pull timer button on my raid manager.
https://github.com/zorker/rothui/blo.../core.lua#L157

What happens is the following. The raid manager has a secure button with a macrotext attribute set to "/pull 3".

The pull timer addon registers the slash command "pull" and reacts on the time given.

It triggers the Pull() function that calls itself recursively as long as there are seconds left. And either /y yells the pull timer or uses /rw in raids. I am able to adjust the pull timer macro text on the fly to print: "Pull in 3", "Pull in 2", "Pull in 1", "Pull now!!!".

I am even able to access WoW API functions like IsInRaid().

That got my thinking. What would prevent me from accessing functions like UnitPower("player") or spell cooldown functions?

If the above holds up shouldn't it be possible to create an addon that registers a slash command like /easywarrior which checks for specific conditions and alternates the macro text to cast specific spells under certain conditions?

All that would be needed is to put an action button on your bar using a macro which is calling /easywarrior.

Did I just get lucky that I (A) either did not test the addon well in combat or (B) the functions I am using right now are part of the secure environment or (C) I have found a hole in the system.

Example
Lua Code:
  1. local MacroEditBox = MacroEditBox
  2. local MacroEditBox_OnEvent = MacroEditBox:GetScript("OnEvent")
  3. local shortcut = "easywarrior"
  4.  
  5. local function EasyWarrior()
  6.   local command = "/cast Shield Block"
  7.   if UnitPower("player") > 60 then
  8.     command = "/cast Ignore Pain"
  9.   end
  10.   MacroEditBox_OnEvent(MacroEditBox, "EXECUTE_CHAT_LINE", command)
  11. end
  12.  
  13. SlashCmdList[shortcut] = function(cmd)
  14.   EasyWarrior()
  15. end
  16. _G["SLASH_"..shortcut.."1"] = "/"..shortcut

*edit*
The above does not work right? Because if it does one could in theory call the function recursively every 0.2 seconds.


All times are GMT -6. The time now is 02:21 AM.

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