richtext_scenarios.lua¶
Functions to simplify text formatting in scenarios and make it consistent. Most of these functions are simple wrapper functions for our richtext system. This file will include richtext.lua for you for additional formatting functions.
To make these functions available include this file at the beginning of a script via:
include "scripting/richtext_scenarios.lua"
- speech(img, clr, title, text)¶
Formats a text as spoken by one person in a scenario. Use it as follows:
function jundlina(title, text) return speech("map:princess.png", "2F9131", title, text) end
- Parameters
img (
string
) – name of the image to use for this speakerclr (
string
) – A valid 6 char hex color to use for the name of this speaker. Best practice is to use styles.color() to get a color value from the style manager whenever possible.title (
string
) – Title of this text. Use empty string if you don’t want any.text (
string
) – The text itself.
- Returns
the formatted text.
- paragraphdivider()¶
Closes a paragraph and opens a new paragraph. Use this when you format a richtext string and need to divide it into multiple paragraphs. Just concatenate this function with the Lua string concatenation operator
..
- Returns
close_p() .. open_p()
Example:
include "scripting/richtext.lua" include "scripting/richtext_scenarios.lua" include "scripting/messages.lua" local text = p("This is the first paragraph" .. paragraphdivider() .. "This is the second paragraph" ) campaign_message_box({title = "Window title", body = text, w = 200, h = 150, position = "top"})
- objective_text(heading, body)¶
Provides nice formatting for objective texts.
- Parameters
heading (
string
) – The headingbody (
string
) – The text
- Returns
a rich text object that contains the formatted objective text.