View Single Post
02-24-24, 12:07 AM   #25
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 140
Originally Posted by Fizzlemizz View Post
Code:
/run print(format("%s %s %s", "Replace", "with", text"))
Each %s is replaced left-to-right with the corresponding argument after the text string ("Replace", "with", text"). There are tokens other than %s various data types/formatting see the docs for format for more information.
Lua Code:
  1. local addonName, addon = ...
  2. addon.db = {
  3.     {
  4.         name = {
  5.             enUS = "Herb-Infused Water",
  6.         },
  7.         questID = 75612,
  8.         icon = "interface/icons/inv_mushroom_11",
  9.         item = 210399, 210400, 210401,
  10.         announce = {
  11.              enUS = format("Awarded for %s outstanding service %s to Dragonkind.\n%s\nBring it to Theozhaklos the Curious at the Wellspring"),
  12.         }
  13.     },
  14.     {
  15.         name = "Emerald Mark of Mastery",
  16.         questID = 74352,
  17.         icon = "interface/icons/inv_mushroom_11",
  18.         item = 193440, 193441, 193442,
  19.         announce = {
  20.              enUS = format("Awarded for %s outstanding service to Dragonkind.\n%s\nBring it to Theozhaklos the Curious at the %s Wellspring)"
  21.         }
  22.     }
  23. }
  24. ---------------------------------------------------------------------------------------------------
  25. -- Code to replace %s in announce texts with item links. Replaces the GetItemLinkById(...) function
  26. local function LoadItem(item)
  27.     for k, v in pairs(addon.db[item.dbID].announce) do -- replace the %s with the itemlink in eal locale in the .announce key
  28.         addon.db[item.dbID].announce[k] = format(v, item:GetItemLink())
  29.     end
  30. end
  31. for i, v in ipairs(addon.db) do
  32.     local item = Item:CreateFromItemID(v.item)
  33.     item.dbID = i
  34.     item:ContinueOnItemLoad(function() LoadItem(item) end)
  35. end

I tried this but it didn't work
  Reply With Quote