Xzempt

EventLogger addon WOW

Aug 12th, 2025
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.29 KB | None | 0 0
  1. -- Choose a unique identifier for your addon
  2. local MYADDON_NAME = "MyToggleAddon"
  3.  
  4. -- Define the slash commands for your addon
  5. SLASH_MYTOGGLEADDON1 = "/mytoggle" -- This is the primary slash command.
  6. SLASH_MYTOGGLEADDON2 = "/mta"      -- This is an alias (optional).
  7.  
  8. -- Create a variable to store the toggle state (true for on, false for off)
  9. local isMyFunctionEnabled = false
  10.  
  11. -- Function to be toggled
  12. local function MyToggledFunction()
  13.     if isMyFunctionEnabled then
  14.         print(MYADDON_NAME .. ": My toggled function is performing its action!")
  15.         -- Put the actual code for your function here
  16.         local EventLoggerFrame = CreateFrame("Frame", "EventLoggerFrame", UIParent);
  17.  
  18. -- This function will be called every time an event fires
  19.         local function EventLogger_OnEvent(self, event, ...)
  20.  
  21.     -- Get the additional arguments passed with the event
  22.         local args = { ... };
  23.  
  24.     -- Construct a string to display in chat
  25.         local message = "Event Fired: " .. event;
  26.         if event ~= "UPDATE_UI_WIDGET" then
  27.  
  28.     -- Append the event arguments to the message (if any)
  29.         if #args > 0 then
  30.             for i, v in ipairs(args) do
  31.                 message = message .. ", arg" .. i .. ": " .. tostring(v);
  32.                 if isMyFunctionEnabled == true then
  33.                     print('|cff00b4ffArguments: '.. #args,'|r' .. message);
  34.                 end
  35.             end
  36.         end    
  37.     end
  38. end
  39.     -- Print the message to the chat window
  40.    
  41.  
  42.  
  43. -- Set the OnEvent script for our frame
  44. EventLoggerFrame:SetScript("OnEvent", EventLogger_OnEvent);
  45.  
  46. -- Register our frame to listen for ALL events
  47. EventLoggerFrame:RegisterAllEvents();
  48.     else
  49.         print(MYADDON_NAME .. ": My toggled function is currently disabled.")
  50.     end
  51. end
  52.  
  53. -- Slash command handler function
  54. local function MyToggleAddon_HandleSlashCommand(msg, editBox)
  55.     -- Toggle the state
  56.     isMyFunctionEnabled = not isMyFunctionEnabled
  57.  
  58.     -- Inform the user of the new state
  59.     if isMyFunctionEnabled then
  60.         print(MYADDON_NAME .. ": My function is now enabled!")
  61.     else
  62.         print(MYADDON_NAME .. ": My function is now disabled.")
  63.     end
  64.  
  65.     -- You can also call your toggled function here to see its effect
  66.     MyToggledFunction()
  67. end
  68.  
  69. -- Register the handler function with the slash command list
  70. SlashCmdList["MYTOGGLEADDON"] = MyToggleAddon_HandleSlashCommand
  71.  
  72.  
Advertisement
Add Comment
Please, Sign In to add comment