Question

Getting my feet wet in Lua and writing some simple addons for World of Warcraft. Primarily looking through other addons, inspecting the code, etc. I'm seeing one thing that has me confused. I know that ... is a way to pass variable number of parameters to a function, but I'm seeing it used at the beginning of a .lua file:

local parent, ns = ...

Again, this is the first line in the source. The only references I see to the file is in the .xml file, included as a script

<Ui>
    <Script file="unitframes\options\ouf.lua"/>
</Ui>

I'm curious where the values being passed in are coming from...

ANSWER:

As the answer below indicates, WoW is passing the arguments to the script. Aparently, WoW passes the following arguments to a script:

  1. Name of the AddOn as a String (actually the folder name)
  2. A table unique to the AddOn (often used as the AddOn's namespace). This table is shared w/ all the lua files in the addon and provides an "AddOn" only scoped context.
Was it helpful?

Solution

Page 8 of "Programming in Lua"

In the main body of a script, the expression "..." results in the arguments to the script.

So a and ns should receive the first two arguments passed in by WOW.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top