When you write
Lua Code:
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:
local function OnAddOnLoaded(eventCode, addon)
if addon == "LootDice" then
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
d("LootDice_SavedVariables.isAddOnEnabled = "..tostring(LootDice_SavedVariables.isAddOnEnabled))
end
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