Lore archive · Warcraft Wiki, 2023 dump
API format
Last wiki revision 2022-08-03
Formats a string by substituting arguments. result = string.format(pattern, ...) = format = s:format
- pattern: - Contains directives like or (see details). Also called the format string.
- ...: - Substituted into each directive; the type must be a kind that can convert to the type specified by the directive.
- result:
> = string.format("%s %q", "Hello", "Lua user!") -- string and quoted string Hello "Lua user!" > = string.format("%c%c%c", 76,117,97) -- char Lua > = string.format("%e, %E", math.pi,math.pi) -- exponent 3.141593e+000, 3.141593E+000 > = string.format("%f, %g, %.2f", math.pi, math.pi, math.pi) -- float and compact float 3.141593, 3.14159, 3.14 > = string.format("%d, %i, %u", -100,-100,-100) -- signed, signed, unsigned integer -100, -100, 4294967196 > = string.format("%o, %x, %X", -100,-100,-100) -- octal, hex, hex 37777777634, ffffff9c, FFFFFF9C > = string.format("%2$d -> %1$03d", 1, 34) -- 2nd arg, 1st arg with leading zeroes 34 -> 001 > = string.format("Ratio is %u %%",12) -- unsigned, escaped % Ratio is 12 %
This macro prints out the time remaining on the Polymorph debuff in seconds, rounded to the nearest whole number: /run for i=1,40 do local n,_,_,_,_,_,x,_,_=UnitDebuff("focus",i);if (n=="Polymorph")or (n=="Polymorph(Pig)")or (n=="Polymorph(Turtle)")then SendChatMessage(format("%.0f",-1*(GetTime-x)).." secs left on "..UnitName("focus").."'s CC!","EMOTE");end end
- http://www.gnu.org/software/libc/manual/html_node/Formatted-Output.html#Formatted-Output
Source
https://warcraft.wiki.gg/wiki/API_format · retrieved 2023-11-13 · CC BY-SA 4.0
Converted from wikitext with templates, tables and images removed, so some sentences may be missing values.
This archive predates WoW: Forever. For collected gameplay facts see the Forever database. Search the archive.