[HOWTO] How To: Round Numbers in Dialogue Text

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Tony Li
Posts: 23238
Joined: Thu Jul 18, 2013 1:27 pm

[HOWTO] How To: Round Numbers in Dialogue Text

Post by Tony Li »

If you have a Dialogue System variable such as: Variable["x"] = 2.499999 and you want to show it in dialogue text rounded to a specific number of decimal places (e.g., 2.50), use the [lua(code)] markup tag with the string.format() Lua function. In the Dialogue System's Lua implementation, this function uses standard .NET format strings.

Example:

- Dialogue Text: Your GPA is [lua(string.format("{0:0.00}", Variable["x"]))]
Post Reply