View Single Post
02-23-24, 10:37 PM   #23
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 120
Originally Posted by Fizzlemizz View Post
Lua Code:
  1. local locale = GetLocale() -- get the current locale eg. "frFR"
  2. local function updateData()
  3.     wipe(data)
  4.     for _, item in ipairs(addon.db) do
  5.         local announceText = item.announce[locale] or item.announce.enUS -- default to enUS if the locale text doesn't exist.
  6.         tinsert(data, {announceText, item.icon, item.name})
  7.     end
  8. end
Yes, this option is ideal (after all, I don’t know what languages the players who install the addon speak, but many speak English)

Lua Code:
  1. local addonName, addon = ...
  2. addon.db = {
  3.     {
  4.         name = {
  5.             enUS = "Herb-Infused Water",
  6.             deDE = "Mit Kräutern aromatisiertes Wasser"
  7.         },
  8.         questID = 75612,
  9.         icon = "interface/icons/inv_mushroom_11",
  10.         item = 210399,
  11.         item = 210400,
  12.         item = 210401,
  13.         item = 210402,
  14.         item = 210403,
  15.         item = 210404,
  16.         announce = {
  17.              enUS = "Awarded for %ss outstanding service %sss to Dragonkind.\n%s\nBring it to Theozhaklos the Curious at the Wellspring \nOverlook in the Emerald %ssss Dream to receive powerful \nequipment for your efforts",
  18.         }
  19.     },
  20.     {
  21.         name = "Emerald Mark of Mastery",
  22.         questID = 75624,
  23.         icon = "interface/icons/inv_mushroom_11",
  24.         item = 20897,
  25.         announce = {
  26.              enUS = "Awarded for outstanding service to Dragonkind.\n%s\nBring it to Theozhaklos the Curious at the Wellspring \nOverlook in the Emerald Dream to receive powerful \nequipment for your efforts"
  27.         }
  28.     },
  29.     {
  30.         name = "Emerald Mark of Mastery",
  31.         questID = 74352,
  32.         icon = "interface/icons/inv_mushroom_11",
  33.         item = 193440,
  34.         announce = {
  35.              enUS = "Awarded for outstanding service to Dragonkind.\n%s\nBring it to Theozhaklos the Curious at the Wellspring \nOverlook in the Emerald Dream to receive powerful \nequipment for your efforts"
  36.         }
  37.     }
  38. }
  39. ---------------------------------------------------------------------------------------------------
  40. -- Code to replace %s in announce texts with item links. Replaces the GetItemLinkById(...) function
  41. local function LoadItem(item)
  42.     for k, v in pairs(addon.db[item.dbID].announce) do -- replace the %s with the itemlink in eal locale in the .announce key
  43.         addon.db[item.dbID].announce[k] = format(v, item:GetItemLink())
  44.     end
  45. end
  46. for i, v in ipairs(addon.db) do
  47.     local item = Item:CreateFromItemID(v.item)
  48.     item.dbID = i
  49.     item:ContinueOnItemLoad(function() LoadItem(item) end)
  50. end
During the creation of the addon, a question arose. One link to a item in the text is missing; you need to insert 2,3 or more links into one text. As I understand it, you need to set different variables, for example %ss or %sss or %d, so that each one is tied to a specific position of the link to the item.

Last edited by Hubb777 : 02-23-24 at 10:53 PM.
  Reply With Quote