WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Concatenate parameters and string (https://www.wowinterface.com/forums/showthread.php?t=59191)

Benalish 08-11-22 02:18 PM

Concatenate parameters and string
 
Hello there. This code should report who cast the buff, which buff cast, and who received it

Lua Code:
  1. local f = CreateFrame("Frame")
  2. f:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
  3. f:SetScript("OnEvent", function(self, event, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10,
  4.                                               arg11, arg12, arg13)
  5.     if (event == "COMBAT_LOG_EVENT_UNFILTERED") then
  6.         if (arg2 == "SPELL_AURA_APPLIED") then --do stuffs
  7.                 end
  8.     end
  9. end)

What exactly do I have to write in order to get a sentence in the form "arg4 cast arg10 on arg7"?

Fizzlemizz 08-11-22 02:45 PM

Depends but the simplest just see it in your chat frame would be:

Lua Code:
  1. if (arg2 == "SPELL_AURA_APPLIED") then --do stuffs
  2.         print(arg4, "cast", arg10, "on", arg7)
  3. end

You could use concatination:
Code:

print(arg4.."cast"..arg10.."on"..arg7)
or string format (%s is replaced with strings, see this for other replacment values:
Code:

local msg = "%s cast %s on %s"
print(string.format(msg, arg4, arg10, arg7))

or ...

The last two are useful if you are using something other than print() (like sending to the chat system)

SDPhantom 08-11-22 09:26 PM

Also since BfA, CLEU doesn't send its payload to the event handler anymore. You need to use CombatLogGetCurrentEventInfo() to query the args now.


All times are GMT -6. The time now is 03:13 AM.

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