Super Moderator
Join Date: Mar 2014
Posts: 5,188
|
You got a typo in there then, or did something else wrong (filenames of lua in your txt got a typo or whatever).
Code:
if addonName ~= GOLDMetrics.name then return end
Watch out that the name in GOLDMetrics.name is compared here with your Addon's folder and txt file name in live/AddOns!
So if "GOLDMetrics" is not your folder and txt file name you need to change for the EVENT_ADD_ON_LOADED the name chekc to your folder & txt file name!!!
Lua Code:
GOLDMetrics = GOLDMetrics or {} GOLDMetrics.name = "GOLDMetrics" GOLDMetrics.variableVersion = 2 -- --------------------------------------------------------------------------------------------------------------------------------- -- LIBRARIES -- --------------------------------------------------------------------------------------------------------------------------------- -- LibChatMessage local chat = LibChatMessage.Create("GOLDMetrics", "GOLDMetrics") -- LibAddonMenu local LAM = LibAddonMenu2 local saveData = {} local GOLDPanel = "GOLDMetrics" local GOLDpanelData = { type = "panel", name = "GOLDMetrics", displayName = "GOLDMetrics", author = "VessVelendas", version = "1.0", slashCommnad = "/GOLDMetrics", registerforRefresh = true, } local GOLDoptionsTable = { [1] = { type = "header", name = "Where you started...", width = "full", }, [2] = { type = "description", title = nil, text = "Date Initialized:", width = "half", }, [3] = { type = "description", title = nil, text = "00/00/0000", width = "half", }, [4] = { type = "description", title = nil, text = "Initial Gold:", width = "half", }, [5] = { type = "description", title = nil, text = "100,000,000", width = "half", }, [6] = { type = "header", name = "Where you are now...", width = "full", }, [7] = { type = "description", title = nil, text = "Current Date:", width = "half", }, [8] = { type = "description", title = nil, text = "00/00/0000", width = "half", }, [9] = { type = "description", title = nil, text = "Current Gold:", width = "half", }, [10] = { type = "description", title = nil, text = "100,000,000", width = "half", }, [11] = { type = "description", title = nil, text = "Goal (Daily):", width = "half", }, [12] = { type = "description", title = nil, text = "100,000,000", width = "half", }, [13] = { type = "description", title = nil, text = "Daily Goal Fulfilled?", width = "half", }, [14] = { type = "description", title = nil, text = "NO", width = "half", }, [15] = { type = "description", title = nil, text = "Daily Difference:", width = "half", }, [16] = { type = "description", title = nil, text = "-000", width = "half", }, [17] = { type = "header", name = "Settings", width = "full", }, [18] = { type = "description", title = nil, text = "NOTE: The formula is Current Gold + Slider Value.", width = "full", }, [19] = { type = "slider", name = "Daily Goal", tooltip = "Amount to add to your current gold", min = 0, max = 1000000, step = 1000, getFunc = function() return 3 end, setFunc = function(value) d(value) end, width = "full", default = 500000, }, [20] = { type = "checkbox", name = "Ignore Changes", tooltip = "Transactions that happen while this is checked won't be counted.", getFunc = function() return true end, setFunc = function(value) d(value) end, width = "full" } } -- --------------------------------------------------------------------------------------------------------------------------------- -- SAVEDVARIABLES -- --------------------------------------------------------------------------------------------------------------------------------- -- Defaults GOLDMetrics.Default = { FirstInit = 0, InitDate = 0, InitGold = 0, CurDay = 0, CurGold = 0, GoalAmount = 0, CurGoal = 0, GoalFulfilled = 0, Difference = 0 } -- --------------------------------------------------------------------------------------------------------------------------------- -- CODE BEGINS HERE -- --------------------------------------------------------------------------------------------------------------------------------- -- When Player is Loaded function GOLDMetrics.PlayerLoaded() end function GOLDMetrics.Init() -- Only if first init if GOLDMetrics.savedVariables then if GOLDMetrics.savedVariables.FirstInit == 0 or nil then GOLDMetrics.savedVariables.InitDate = GetDateElementsFromTimestamp(GetTimeStamp()) GOLDMetrics.savedVariables.CurDay = GetDateElementsFromTimestamp(GetTimeStamp()) -- Reset Goal Completion GOLDMetrics.savedVariables.GoalFulfilled = 0 chat:Print("RESET Goal Fulfillment") -- Reset Difference GOLDMetrics.savedVariables.Difference = 0 chat:Print("RESET Difference") -- Update Money curMoney = GetCurrentMoney() GOLDMetrics.savedVariables.CurGold = curMoney chat:Print("UPDATE Current Gold") -- Update Goal GOLDMetrics.savedVariables.CurGoal = GOLDMetrics.savedVariables.CurGold + GOLDMetrics.savedVariables.GoalAmount curGoal2 = GOLDMetrics.savedVariables.CurGoal chat:Print("UPDATE Daily Goal") GOLDMetrics.savedVariables.FirstInit = 1 chat:Print("Initialized") end -- Check the date oldYear, oldMonth, oldDay = GetDateElementsFromTimestamp(GOLDMetrics.savedVariables.CurDay) year, month, day = GetDateElementsFromTimestamp(GetTimeStamp()) if day ~= oldDay then chat:Print("Date has changed") -- Reset Goal Completion GOLDMetrics.savedVariables.GoalFulfilled = 0 chat:Print("RESET Goal Fulfillment") -- Reset Difference GOLDMetrics.savedVariables.Difference = 0 chat:Print("RESET Difference") -- Update Money curMoney = GetCurrentMoney() GOLDMetrics.savedVariables.CurGold = curMoney chat:Print("UPDATE Current Gold") -- Update Goal GOLDMetrics.savedVariables.CurGoal = GOLDMetrics.savedVariables.CurGold + GOLDMetrics.savedVariables.GoalAmount CurGoal2 = GOLDMetrics.savedVariables.CurGoal chat:Print("UPDATE Daily Goal") else chat:Print("Date has NOT changed") -- Update Money curMoney = GetCurrentMoney() GOLDMetrics.savedVariables.CurGold = curMoney chat:Print("UPDATE Current Gold") end end end function GOLDMetrics.AddOnLoaded(eventId, addonName) if addonName ~= GOLDMetrics.name then return end EVENT_MANAGER:UnRegisterForEvent(GOLDMetrics.name, EVENT_ADD_ON_LOADED) GOLDMetrics.savedVariables = ZO_SavedVars:NewAccountWide("GOLDMetricsVar", GOLDMetrics.variableVersion, nil, GOLDMetrics.Default, GetWorldName()) chat:Print("SavedVariables created") -- LibAddonMenu LAM:RegisterAddonPanel("GOLDMetrics", GOLDpanelData) LAM:RegisterOptionControls("GOLDMetrics", GOLDoptionsTable) GOLDMetrics.Init() --EVENT_MANAGER:RegisterForEvent(GOLDMetrics.name, EVENT_PLAYER_ACTIVATED, GOLDMetrics.PlayerLoaded) EVENT_MANAGER:RegisterForEvent("GOLDMetrics", EVENT_MONEY_UPDATE, GOLDMetrics.Update) end EVENT_MANAGER:RegisterForEvent(GOLDMetrics.name, EVENT_ADD_ON_LOADED, GOLDMetrics.AddOnLoaded)
Last edited by Baertram : 04/26/24 at 03:09 PM.
|