In a modification script I’m developing for an online game, I’m attempting to display the current percentage of a number.
function()
local z = math.max(0, UnitPower("player")) / math.max(1, UnitPowerMax("player")) * 100;
return string.format("%.f", z);
end
The code above displays the percentage correctly.
However, I am having a difficult time getting the actual percentage sign to show up without throwing errors everywhere.
I’ve tried adding print("%%") before ending the function as well as after the function, but it doesn’t seem to work.
The function
string.format, likeprintfin C, requires the percent sign to be doubled when you want it verbatim. This is not the case forprintorio.writefunctions !So you certainly want this :