Originally Posted by Fizzlemizz
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:
local addonName, addon = ...
addon.db = {
{
name = {
enUS = "Herb-Infused Water",
},
questID = 75612,
icon = "interface/icons/inv_mushroom_11",
item = 210399, 210400, 210401,
announce = {
enUS = format("Awarded for %s outstanding service %s to Dragonkind.\n%s\nBring it to Theozhaklos the Curious at the Wellspring"),
}
},
{
name = "Emerald Mark of Mastery",
questID = 74352,
icon = "interface/icons/inv_mushroom_11",
item = 193440, 193441, 193442,
announce = {
enUS = format("Awarded for %s outstanding service to Dragonkind.\n%s\nBring it to Theozhaklos the Curious at the %s Wellspring)"
}
}
}
---------------------------------------------------------------------------------------------------
-- Code to replace %s in announce texts with item links. Replaces the GetItemLinkById(...) function
local function LoadItem(item)
for k, v in pairs(addon.db[item.dbID].announce) do -- replace the %s with the itemlink in eal locale in the .announce key
addon.db[item.dbID].announce[k] = format(v, item:GetItemLink())
end
end
for i, v in ipairs(addon.db) do
local item = Item:CreateFromItemID(v.item)
item.dbID = i
item:ContinueOnItemLoad(function() LoadItem(item) end)
end
I tried this but it didn't work