View Single Post
04/28/23, 03:31 AM   #6
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,989
Choose any addon's main lua file, search for the EVENT_ADD_ON_LOADED line.
At this event the game loads this addon and changing the actionabr or other controls before might bring an error.

It will look like this e.g.
Code:
EVENT_MANAGER:RegisterForEvent("NameOfAddonHere", EVENT_ADD_ON_LOADED, functionName)
functionName is either a name of a callback function used in that addon OR it is defined there directly as anonymous fucntion like this
Code:
function(eventId, addOnName) 
 --something is done here
end

Inside that functionName function the code of the addon will be executed as the addon loads.
It normally starts with something like a comparison of the addon name to the parameter "addOnName" of that function.

e.g.

Lua Code:
  1. if "MyAddonName" ~= addOnName then return end


This is done as the event triggers for EACH active addon once! And only the current addon's call should be processed here in this addon file.
So at the end of that function functionName you can try to add that script, without the /script though as we are in a lua script already.

So your function functionName would look like this e.g. in the end:

Lua Code:
  1. function MyAddon.OnEventAddonLoaded(eventId, addOnName)
  2.    if "MyAddonName" ~= addOnName then return end
  3.    --other code here
  4.    ZO_ActionBar1:SetScale(2)
  5. end

or like this:
Lua Code:
  1. local function OnEventAddonLoaded(eventId, addOnName)
  2.    if "MyAddonName" == addOnName then
  3.       --other code here
  4.       ZO_ActionBar1:SetScale(2)
  5.    end
  6. end

or like this if it's an anonymous function directly in the EVENT_MANAGER:RegisterForEvent line:
Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("NameOfAddonHere", EVENT_ADD_ON_LOADED, function(eventId, addOnNam)
  2.    if "MyAddonName" == addOnName then
  3.       --other code here
  4.       ZO_ActionBar1:SetScale(2)
  5.    end
  6. end)

Last edited by Baertram : 04/28/23 at 03:33 AM.
  Reply With Quote