The reason white space is collapsed is because output in Quest is HTML, and this is the standard for HTML. It makes sense on a web page, but perhaps less so here. Quest uses HTML to make output for online games easier.
In HTML you could do this using
<pre> tags or
entities, but this is a cut down version of HTML, and neither are available here.
As guzmere has said, Pertex has a function that will give a specified number of white spaces. The way it works is that Quest interpretes a row of space inside an HTML element as a row of spaces instead of collapsing it, so this will work:
msg ("FP: " + this.fp + "<b> </b>CP: " + this.fp)
The <b> tag turns on bold, and stops the spaces getting collapsed. However, if the whole line is in bold, white space is still collapsed. This does not work:
msg ("<b>FP: " + this.fp + " CP: " + this.fp + "</b>")
This is not stardard HTML, and I have no idea why it should work, but it does.
Anyway, I was actually thinking about formatting a table last night, and this has prompted me to create these functions (the Whitespaces function is Pertex's).
<function name="FormatText" parameters="columns, strings">
FormatTextLists (Split (columns, ";"), Split (strings, ";"))
</function>
<function name="FormatTextLists" parameters="columns, strings"><![CDATA[
str = ""
for (i, 0, ListCount (columns) - 1) {
s = StringListItem (columns, i)
if (not IsNumeric (s)) {
error ("ERROR: " + s + " is not a number in FormatText")
}
cols = ToInt (s)
if (ListCount (strings) > i) {
s = StringListItem (strings, i)
str = str + s + Whitespaces (cols - LengthOf (s))
}
}
msg (str)
]]></function>
<function name="Whitespaces" parameters="number" type="string"><![CDATA[
text = ""
for (x, 1, number) {
text = text+ " "
}
return ("<b>"+text+"</b>")
]]></function>
With FormatText, send it two strings, the first being the number of characters allocated to each column, the second being the values for each column, separated by semi-columns in both cases (alternatively, use FormatTextLists and send string lists with the data). Your
look script now looks like this:
<look type="script">
msg (this.alias)
msg (this.desc)
msg ("HP: " + this.hp)
cols = "12;10;12;10"
FormatText (cols, "FP:;" + this.fp + ";CP:;" + this.cp)
FormatText (cols, "FP Refresh:;" + this.fprefresh + ";CP Refresh:;" + this.cprefresh)
</look>
It looks best if you set the font to one like
Courier New where all the characters are the same width. You could do that in the script so only the table is in that font.