Function

From Riftui Wiki

Jump to: navigation, search

A command that processes instructions, usually, but not always, returning a result. The basic globals are all functions. User created functions begin with the word function and finish with the word end. They always have brackets () at the end of their name, which can be used to pass a variable.

Functions can be local to the addon, in which case the code within cannot be seen by other addons or by Rift (although the result might be) or global in scope. Global user created functions are useful if you want other addons to use the code. For example, the :NewLibrary(major, minor) or :GetLibrary(major, [silent]) functions of LibStub.

Example One:

local function PrintPassives()
       -- Get the current list of abilities --
       local list = Inspect.Ability.List()
       -- If the list of abilities are not available, don't proceed --
       if not list then return end

       -- Get detailed information on the ability list --
       local details = Inspect.Ability.Detail(list)

       -- Step through the table --
       for id, ability in pairs(details) do
              -- check if the ability is a passive --
              if ability.passive then
                   -- print out the ability name --
                   print(ability.name)  
              end
       end
end

Example Two:

local function Command(command)
    if command then
        print("command is true!")
    end
end
Personal tools
Namespaces
Variants
Actions
Menu
Wiki
Toolbox