View Single Post
04/26/24, 03:03 PM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,004
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:
  1. GOLDMetrics = GOLDMetrics or {}
  2. GOLDMetrics.name = "GOLDMetrics"
  3. GOLDMetrics.variableVersion = 2
  4.  
  5. -- ---------------------------------------------------------------------------------------------------------------------------------
  6. -- LIBRARIES
  7. -- ---------------------------------------------------------------------------------------------------------------------------------
  8.  
  9. -- LibChatMessage
  10. local chat = LibChatMessage.Create("GOLDMetrics", "GOLDMetrics")
  11.  
  12. -- LibAddonMenu
  13. local LAM = LibAddonMenu2
  14. local saveData = {}
  15. local GOLDPanel = "GOLDMetrics"
  16.  
  17. local GOLDpanelData = {
  18.  
  19.     type = "panel",
  20.     name = "GOLDMetrics",
  21.     displayName = "GOLDMetrics",
  22.     author = "VessVelendas",
  23.     version = "1.0",
  24.     slashCommnad = "/GOLDMetrics",
  25.     registerforRefresh = true,
  26.  
  27. }
  28.  
  29. local GOLDoptionsTable = {
  30.     [1] = {
  31.         type = "header",
  32.         name = "Where you started...",
  33.         width = "full",
  34.     },
  35.     [2] = {
  36.         type = "description",
  37.         title = nil,
  38.         text = "Date Initialized:",
  39.         width = "half",
  40.     },
  41.     [3] = {
  42.         type = "description",
  43.         title = nil,
  44.         text = "00/00/0000",
  45.         width = "half",
  46.     },
  47.     [4] = {
  48.         type = "description",
  49.         title = nil,
  50.         text = "Initial Gold:",
  51.         width = "half",
  52.     },
  53.     [5] = {
  54.         type = "description",
  55.         title = nil,
  56.         text = "100,000,000",
  57.         width = "half",
  58.     },
  59.     [6] = {
  60.         type = "header",
  61.         name = "Where you are now...",
  62.         width = "full",
  63.     },
  64.     [7] = {
  65.         type = "description",
  66.         title = nil,
  67.         text = "Current Date:",
  68.         width = "half",
  69.     },
  70.     [8] = {
  71.         type = "description",
  72.         title = nil,
  73.         text = "00/00/0000",
  74.         width = "half",
  75.     },
  76.     [9] = {
  77.         type = "description",
  78.         title = nil,
  79.         text = "Current Gold:",
  80.         width = "half",
  81.     },
  82.     [10] = {
  83.         type = "description",
  84.         title = nil,
  85.         text = "100,000,000",
  86.         width = "half",
  87.     },
  88.     [11] = {
  89.         type = "description",
  90.         title = nil,
  91.         text = "Goal (Daily):",
  92.         width = "half",
  93.     },
  94.     [12] = {
  95.         type = "description",
  96.         title = nil,
  97.         text = "100,000,000",
  98.         width = "half",
  99.     },
  100.     [13] = {
  101.         type = "description",
  102.         title = nil,
  103.         text = "Daily Goal Fulfilled?",
  104.         width = "half",
  105.     },
  106.     [14] = {
  107.         type = "description",
  108.         title = nil,
  109.         text = "NO",
  110.         width = "half",
  111.     },
  112.     [15] = {
  113.         type = "description",
  114.         title = nil,
  115.         text = "Daily Difference:",
  116.         width = "half",
  117.     },
  118.     [16] = {
  119.         type = "description",
  120.         title = nil,
  121.         text = "-000",
  122.         width = "half",
  123.     },
  124.     [17] = {
  125.         type = "header",
  126.         name = "Settings",
  127.         width = "full",
  128.     },
  129.     [18] = {
  130.         type = "description",
  131.         title = nil,
  132.         text = "NOTE: The formula is Current Gold + Slider Value.",
  133.         width = "full",
  134.     },
  135.     [19] = {
  136.         type = "slider",
  137.         name = "Daily Goal",
  138.         tooltip = "Amount to add to your current gold",
  139.         min = 0,
  140.         max = 1000000,
  141.         step = 1000,
  142.         getFunc = function() return 3 end,
  143.         setFunc = function(value) d(value) end,
  144.         width = "full",
  145.         default = 500000,
  146.     },
  147.     [20] = {
  148.         type = "checkbox",
  149.         name = "Ignore Changes",
  150.         tooltip = "Transactions that happen while this is checked won't be counted.",
  151.         getFunc = function() return true end,
  152.         setFunc = function(value) d(value) end,
  153.         width = "full"
  154.     }
  155. }
  156.  
  157. -- ---------------------------------------------------------------------------------------------------------------------------------
  158. -- SAVEDVARIABLES
  159. -- ---------------------------------------------------------------------------------------------------------------------------------
  160.  
  161. -- Defaults
  162. GOLDMetrics.Default = {
  163.  
  164.     FirstInit = 0,
  165.     InitDate = 0,
  166.     InitGold = 0,
  167.     CurDay = 0,
  168.     CurGold = 0,
  169.     GoalAmount = 0,
  170.     CurGoal = 0,
  171.     GoalFulfilled = 0,
  172.     Difference = 0
  173.  
  174. }
  175.  
  176. -- ---------------------------------------------------------------------------------------------------------------------------------
  177. -- CODE BEGINS HERE
  178. -- ---------------------------------------------------------------------------------------------------------------------------------
  179.  
  180. -- When Player is Loaded
  181. function GOLDMetrics.PlayerLoaded()
  182.  
  183.  
  184. end
  185.  
  186. function GOLDMetrics.Init()
  187.  
  188.     -- Only if first init
  189.     if GOLDMetrics.savedVariables then
  190.  
  191.         if GOLDMetrics.savedVariables.FirstInit == 0 or nil then
  192.  
  193.             GOLDMetrics.savedVariables.InitDate = GetDateElementsFromTimestamp(GetTimeStamp())
  194.             GOLDMetrics.savedVariables.CurDay = GetDateElementsFromTimestamp(GetTimeStamp())
  195.  
  196.             -- Reset Goal Completion
  197.             GOLDMetrics.savedVariables.GoalFulfilled = 0
  198.             chat:Print("RESET Goal Fulfillment")
  199.  
  200.             -- Reset Difference
  201.             GOLDMetrics.savedVariables.Difference = 0
  202.             chat:Print("RESET Difference")
  203.  
  204.             -- Update Money
  205.             curMoney = GetCurrentMoney()
  206.             GOLDMetrics.savedVariables.CurGold = curMoney
  207.             chat:Print("UPDATE Current Gold")
  208.  
  209.             -- Update Goal
  210.             GOLDMetrics.savedVariables.CurGoal = GOLDMetrics.savedVariables.CurGold + GOLDMetrics.savedVariables.GoalAmount
  211.             curGoal2 = GOLDMetrics.savedVariables.CurGoal
  212.             chat:Print("UPDATE Daily Goal")
  213.  
  214.             GOLDMetrics.savedVariables.FirstInit = 1
  215.  
  216.             chat:Print("Initialized")
  217.  
  218.         end
  219.  
  220.         -- Check the date
  221.         oldYear, oldMonth, oldDay = GetDateElementsFromTimestamp(GOLDMetrics.savedVariables.CurDay)
  222.         year, month, day = GetDateElementsFromTimestamp(GetTimeStamp())
  223.  
  224.         if day ~= oldDay then
  225.  
  226.             chat:Print("Date has changed")
  227.  
  228.             -- Reset Goal Completion
  229.             GOLDMetrics.savedVariables.GoalFulfilled = 0
  230.             chat:Print("RESET Goal Fulfillment")
  231.  
  232.             -- Reset Difference
  233.             GOLDMetrics.savedVariables.Difference = 0
  234.             chat:Print("RESET Difference")
  235.  
  236.             -- Update Money
  237.             curMoney = GetCurrentMoney()
  238.             GOLDMetrics.savedVariables.CurGold = curMoney
  239.             chat:Print("UPDATE Current Gold")
  240.  
  241.             -- Update Goal
  242.             GOLDMetrics.savedVariables.CurGoal = GOLDMetrics.savedVariables.CurGold + GOLDMetrics.savedVariables.GoalAmount
  243.             CurGoal2 = GOLDMetrics.savedVariables.CurGoal
  244.             chat:Print("UPDATE Daily Goal")
  245.  
  246.         else
  247.  
  248.             chat:Print("Date has NOT changed")
  249.  
  250.             -- Update Money
  251.             curMoney = GetCurrentMoney()
  252.             GOLDMetrics.savedVariables.CurGold = curMoney
  253.             chat:Print("UPDATE Current Gold")
  254.  
  255.         end
  256.  
  257.     end
  258.  
  259. end
  260. function GOLDMetrics.AddOnLoaded(eventId, addonName)
  261.     if addonName ~= GOLDMetrics.name then return end
  262.     EVENT_MANAGER:UnRegisterForEvent(GOLDMetrics.name, EVENT_ADD_ON_LOADED)
  263.  
  264.     GOLDMetrics.savedVariables = ZO_SavedVars:NewAccountWide("GOLDMetricsVar", GOLDMetrics.variableVersion, nil, GOLDMetrics.Default, GetWorldName())
  265.     chat:Print("SavedVariables created")
  266.  
  267.     -- LibAddonMenu
  268.     LAM:RegisterAddonPanel("GOLDMetrics", GOLDpanelData)
  269.     LAM:RegisterOptionControls("GOLDMetrics", GOLDoptionsTable)
  270.  
  271.     GOLDMetrics.Init()
  272.  
  273.     --EVENT_MANAGER:RegisterForEvent(GOLDMetrics.name, EVENT_PLAYER_ACTIVATED, GOLDMetrics.PlayerLoaded)
  274.     EVENT_MANAGER:RegisterForEvent("GOLDMetrics", EVENT_MONEY_UPDATE, GOLDMetrics.Update)
  275. end
  276.  
  277. EVENT_MANAGER:RegisterForEvent(GOLDMetrics.name, EVENT_ADD_ON_LOADED, GOLDMetrics.AddOnLoaded)

Last edited by Baertram : 04/26/24 at 03:09 PM.
  Reply With Quote