View Single Post
02-24-24, 01:37 AM   #27
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 113
Originally Posted by Fizzlemizz View Post
This makes it a bit more complicated as you're getting mutiple items for each row so you have to have them all cached before you can do the format().

I have to head out so I'll look at it in the morning.
Thank you very much, good luck in your business. Maybe this code will help you
Lua Code:
  1. local Item = Class('Item', Reward)
  2.  
  3. function Item:Initialize(attrs)
  4.     Reward.Initialize(self, attrs)
  5.  
  6.     if not self.item then
  7.         error('Item() reward requires an item id to be set')
  8.     end
  9.     self.itemLink = L['retrieving']
  10.     self.itemIcon = 'Interface\\Icons\\Inv_misc_questionmark'
  11.     local item = _G.Item:CreateFromItemID(self.item)
  12.     if not item:IsItemEmpty() then
  13.         item:ContinueOnItemLoad(function()
  14.             self.itemLink = item:GetItemLink()
  15.             self.itemIcon = item:GetItemIcon()
  16.         end)
  17.     end
  18. end
  19.  
  20. function Item:Prepare() ns.PrepareLinks(self.note) end
  21.  
  22. function Item:IsObtained()
  23.     if self.quest then return C_QuestLog.IsQuestFlaggedCompleted(self.quest) end
  24.     if self.bag then return ns.PlayerHasItem(self.item) end
  25.     return true
  26. end
  27.  
  28. function Item:GetText()
  29.     local text = self.itemLink
  30.     if self.type then -- mount, pet, toy, etc
  31.         text = text .. ' (' .. self.type .. ')'
  32.     end
  33.     if self.count then
  34.         text = text .. string.format(' (%sx)', BreakUpLargeNumbers(self.count))
  35.     end
  36.     if self.note then -- additional info
  37.         text = text .. ' (' .. ns.RenderLinks(self.note, true) .. ')'
  38.     end
  39.     return Icon(self.itemIcon) .. text
  40. end
  41.  
  42. function Item:GetStatus()
  43.     if self.bag then
  44.         local collected = ns.PlayerHasItem(self.item)
  45.         return collected and Green(L['completed']) or Red(L['incomplete'])
  46.     elseif self.status then
  47.         return format('(%s)', self.status)
  48.     elseif self.quest then
  49.         local completed = C_QuestLog.IsQuestFlaggedCompleted(self.quest)
  50.         return completed and Green(L['completed']) or Red(L['incomplete'])
  51.     elseif self.weekly then
  52.         local completed = C_QuestLog.IsQuestFlaggedCompleted(self.weekly)
  53.         return completed and Green(L['weekly']) or Red(L['weekly'])
  54.     end
  55. end


And an additional question. - https://www.wowinterface.com/forums/...t=59795&page=2

In the last topic you helped me make a timer.
I plan to make another addon in the future that also uses this timer. The problem is that if a player installs 2 of these addons, the timer will not work correctly. I thought it was enough to fix ZAMROTimer to ZAMRO1Timer, but it looks like something else needs to be done?

Last edited by Hubb777 : 02-24-24 at 02:53 AM.
  Reply With Quote