Skip to content
Sinaloit edited this page Jun 7, 2014 · 6 revisions

Place the script tag for GeminiAddon.lua at the top of your toc.xml:

<?xml version="1.0" encoding="UTF-8"?>
<Addon APIVersion="8" Name="MyAddon" Description="Example toc.xml">
  <!-- Libraries -->
  <Script Name="GeminiAddon.lua"/>
  <!-- Addon Init -->
  <Script Name="MyAddon.lua"/>
  <!-- Additional Modules/XML -->
</Addon>
-- MyAddon.lua
-- A small (but complete) addon, that doesn't do anything, but shows usage of the callbacks.

-- Create the addon object and register it with Apollo in a single line
local MyAddon = Apollo.GetPackage("Gemini:Addon-1.1").tPackage:NewAddon("MyAddon", false)
local Timer

-- Replaces MyAddon:OnLoad
function MyAddon:OnInitialize()
  -- do init tasks here, like setting default states
  -- or setting up slash commands.

  -- Currently there is no default provided way to do any kind of Print to screen prior to the ChatLog having
  -- loaded.  GeminiLogging could be used here but that would complicate the example.
end

-- Called when player has loaded and entered the world
function MyAddon:OnEnable()
  -- Do more initialization here, that really enables the use of your addon.
  -- Register Events, Hook functions, Create Frames, Get information from 
  -- the game that wasn't available in OnInitialize.  Here you can Load XML, etc.

  -- Just like in OnInitialize the ChatLog has not loaded at this point so Print is still not possible.
  -- So that this addon does actually print something we'll delay for 1 second then Print.
  -- NOTE: On really slow machines this may still fail as they will still not have loaded ChatLog
  Timer = ApolloTimer.Create(1,false, "DelayedPrint", self)
end

function MyAddon:DelayedPrint()
  Print("MyAddon:DelayedPrint called - " .. GameLib.GetPlayerUnit():GetName() .. " entered the world!")
end

function MyAddon:OnDisable()
  -- Unhook, Unregister Events, Hide/destroy windows that you created.
  -- You would probably only use an OnDisable if you want to 
  -- build a "standby" mode, or be able to toggle modules on/off.
end

Clone this wiki locally