Thursday, October 15, 2020

GetRandomArgument Removed or Renamed

 I have a new found respect for those who develop and more specifically maintain add-ons when things can break without warning each patch/expansion. I had a couple macros making use of the GetRandomArgument function to randomize emotes expressed when putting up a pull timer or marking a priority kill target, and only discovered they were broken on raid night. Luckily I was at least prepared class change wise, and more importantly barber shop wise, so I had a bit of time to fiddle while others were figuring out other gameplay changes.

I plan to do a little more looking into the LUA code to see if there is still an equivalent function somewhere, but in the meantime my workaround was just to create an array of values and index into that with a random number (luckily that function still works). Maybe I'll get lucky and someone else will find a more elegant solution while I procrastinate. The array workaround eats up an extra 3-4 characters depending on whether or not you like to keep optional spaces in for readability, so it would be nice to have those characters available for other things given that macros can only be 255 characters total. Now that everyone is thoroughly confused, here is an example:

My original macro:
/run SetRaidTargetIcon("target",SecureCmdOptionParse('[btn:2][mod]7;8'))
/stopmacro [nocombat][btn:2][mod]
/run DoEmote(GetRandomArgument("helpme","attackmytarget","openfire"))
/s Please assist me in killing %t {rt8}!
/rw Please kill %t {rt8}!

My edited macro:
/run SetRaidTargetIcon("target",SecureCmdOptionParse('[btn:2][mod]7;8'))
/stopmacro [nocombat][btn:2][mod]
/run local e={"helpme","attackmytarget","openfire"} DoEmote(e[random(3)])
/s Please assist me in killing %t {rt8}!
/rw Please kill %t {rt8}!

Pretty trivial change, and probably more future proof in the long run. In case anyone is interest this macro just marks the target with an X and stops when the right mouse button is used, otherwise it marks the target with a skull. Additionally when in combat it emotes, asks for help in chat, and pops up a raid warning, because out of combat that would get a little annoying.

Hopefully this get caught by search engines so the next person to search for GetRandomArgument not working gets here instead of a useless bunch of outdated pages.

No comments:

Post a Comment