Coloring the text in a stringlist

Forgewright
29 Apr 2020, 21:22I need to color all text spoken by an NPC without having to manually add the color to each line in the "thingstosay" stringlist.
New speak to command:
if (HasScript(object, "speak")) {
do (object, "speak")
}
else if (ListCount(object.thingstosay) = 0) {
msg (CapFirst(object.gender) + " says,")
msg ("\"<i>That's all I have for now.\"")
}
else {
line = StringListItem (object.thingstosay, 0)
msg (CapFirst(object.gender) + " says,")
msg ("<em>" {color:silver: + line})
list remove (object.thingstosay, line)
}
I get the following error:
Error running script: Function not found: ')'
I know the line:
msg ("<em>" {color:silver: + line})
is wrong, but I have tried every arrangement I can think of. It allows the <em>
but not the color code.
msg ("<em>{color:silver:}" + line)
This runs but no color.
Any ideas?
mrangel
29 Apr 2020, 22:00When you've put the string together, you want it to look like <em>{color:silver:Your text here}</em>
. The text processor directive is parsed by the text processor when the message is printed; it is a string, not a quest function, so needs to be in quotes.
So the line you want is:
msg ("<em>{color:silver:" + line + "}</em>")
But the text processor automatically changes {color:silver:some text}
to <span style="color: silver">some text</span>
, and uses quite a lot of function calls in the process; so it might be more efficient to generate the HTML yourself. Something like:
msg ("<em><span style=\"color:silver\">" + line + "</span></em>")
Although while you're applying both emphasis and color to the same text, it would be more efficient to combine the two styles:
msg ("<em style=\"color:silver\">" + line + "</em>")

Forgewright
29 Apr 2020, 22:20That is purdy. Thanks again Merlin...I mean Mrangel