View Single Post
04/25/14, 01:07 PM   #23
Fathis Ules
Thief Guild Master
 
Fathis Ules's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 42
When you write


Lua Code:
  1. EVENT_MANAGER:RegisterForEvent("LootDice", EVENT_ADD_ON_LOADED, OnAddOnLoaded)

the code is looking for a local function OnAddOnLoaded and your is not declared so it will never execute

you need to write the OnAddOnLoaded as any other local function outside the handler

Lua Code:
  1. local function OnAddOnLoaded(eventCode, addon)
  2.     if addon == "LootDice" then
  3.         LootDice_SavedVariables = { "lolilol", isAddOnEnabled = true} -- you don't really need the New() as long as you write ## SavedVariables: LootDice_SavedVariables in you toc .txt file, the variable is saved automatically
  4.         d("LootDice_SavedVariables.isAddOnEnabled = "..tostring(LootDice_SavedVariables.isAddOnEnabled))
  5.     end
  6. end

you don't really need the New() as long as you write ## SavedVariables: LootDice_SavedVariables in you toc .txt file, the variable is saved automatically when you declare it LootDice_SavedVariables = {} so anything you will create inside will be saved on disconnect or reloadui LootDice_SavedVariables.option1 LootDice_SavedVariables.option2 etc..

If you try the sample function I showed you and you hit /reloadui, you will see "lolilol" written in you savedvariable file and isAddOnEnabled ^^


Also no need to name MyAddonRollDice, when I wrote MyAddon that a sample to replace with the name of your addon, like LootDiceRollDice , LootDicePrint, LootDiceShow, etc etc so that the functions are globally identifiable to belong to the addon called LootDice

Last edited by Fathis Ules : 04/25/14 at 01:27 PM.
  Reply With Quote