Originally Posted by siweia
For example, an addon named "ABC" use title like:
Code:
local A, B, C = unpack(select(2, ...))
A.CreateFrame = function() end
B.CreateColor = function() end
C.CreateName = function() end
If I want to change some of the functions in the table, what should I do in the title to access the addon?
The belowing line seems not working by using the addon name.
Code:
local A, B, C = unpack("ABC")
|
Lua Code:
-- Lib Globals
local _G = _G
local select = select
local unpack = unpack
local tonumber = tonumber
local match = string.match
local floor = math.floor
-- Locals
local Resolution = GetCurrentResolution() > 0 and select(GetCurrentResolution(), GetScreenResolutions()) or nil
local Windowed = Display_DisplayModeDropDown:windowedmode()
local Fullscreen = Display_DisplayModeDropDown:fullscreenmode()
-- Build the engine
local AddOnName, Engine = ...
Engine[1] = {} -- Engine
Engine[2] = {} -- Config
Engine[3] = {} -- Locales
function Engine:unpack()
return self[1], self[2], self[3]
end
Engine[1].WindowedMode = Windowed
Engine[1].FullscreenMode = Fullscreen
Engine[1].Resolution = Resolution or (Windowed and GetCVar("gxWindowedResolution")) or GetCVar("gxFullscreenResolution")
Engine[1].ScreenHeight = tonumber(match(Engine[1].Resolution, "%d+x(%d+)"))
Engine[1].ScreenWidth = tonumber(match(Engine[1].Resolution, "(%d+)x+%d"))
Engine[1].Mult = 768 / match(Engine[1].Resolution, "%d+x(%d+)") / 0.8
Engine[1].Scale = function(x) return Engine[1].Mult * floor(x / Engine[1].Mult + 0.5) end
Engine[1].TexCoords = {0.08, 0.92, 0.08, 0.92}
Engine[1].MyName = UnitName("player")
Engine[1].MyClass = select(2, UnitClass("player"))
Engine[1].MyLevel = UnitLevel("player")
Engine[1].MyRealm = GetRealmName()
Engine[1].MyFaction = select(2, UnitFactionGroup("player"))
Engine[1].MyRegion = GetLocale()
Engine[1].Version = GetAddOnMetadata(AddOnName, "Version")
Engine[1].VersionNumber = tonumber(Engine[1].Version)
Engine[1].WoWPatch, Engine[1].WoWBuild, Engine[1].WoWPatchReleaseDate, Engine[1].TocVersion = GetBuildInfo()
Engine[1].WoWBuild = tonumber(Engine[1].WoWBuild)
_G[AddOnName] = Engine
Heres my code that i use as engine to access all my functions in every file.
Lua Code:
local A, C, L = select(2, ...):unpack()
in every file to access those functions.