In World of Warcraft addons, a table is passed as the second vararg:
-- This is often at the top of WoW lua files
local AddonTable = select(2, ...)
Is there a way to do that with regular lua? I'm attempting to write some unit tests with minimal changes to my current code. So far when I just use require, I can use select(1, ...)
to get the first parameter to require (the module), but I can't seem to figure out how to populate the second argument.
Update:
Instead of using require
, I can use loadfile
to do what I need. When World Of Warcraft loads an addon, it passes the name of the addon and a table that can be populated with your addon's functions. I can reproduce that functionality with this code:
local addon = loadfile('MyAddon.lua')
local AddonTable = {}
addon('AddonName', AddonTable)