Navigation
Usage Information
Developer Information
Addon and Plugin Documentation
Addons
Plugins
Navigation
Usage Information
Developer Information
Addon and Plugin Documentation
Addons
Plugins
This is an old revision of the document!
The common library is a simple Lua file that includes other libraries that are the most often used in addons. This is a simple way for addons to include most of the other libraries in a single go rather than cluttering the top of their file with a bunch of require statements.
The common library also includes a helpful 'switch' function to mimic C++ style switch statements within Lua.
An example usage of the switch case function:
function get_container_name(id) return switch(tostring(id)) : caseof { ['0'] = function() return 'Inventory'; end ['1'] = function() return 'Mog Safe'; end, ['2'] = function() return 'Storage'; end, ['default'] = function() return nil; end, }; end -- This should print 'Mog Safe'.. print(get_container_name(1));