Print variable value

Hi all, I feel this should be really obvious, but im trying to just include a simple print variable command into my game book.

I.e, at an earlier point the variable is set to "XYZ", and later on in the book someone will say "I see you are from XYZ".

I checked through the documentation and couldn't find any way to do this. Any help would be appreciated.


Do you mean a variable, or an attribute? Variables just have a name; attributes belong to an object (which in gamebook mode will normally either be game or player; flags and counters are both attributes belonging to game)

In either case, there are a few ways to do this.

Displaying a variable within the script that created it

msg ("I see you are from " + location + ".")

This uses an expression which takes 3 strings (a string literal in quotes, a string variable, and another literal) and joins them together.

Displaying an attribute within a script

msg ("I see you are from " + game.location + ".")

This is just the same as above, but using an attribute. This is more useful, because attributes are saved between different scripts.

Displaying an attribute within a text section

I see you are from {game.location}.

Immediately before sending text to the screen, any parts inside curly brackets or braces ­– { and } – will be checked to see if they are attribute names, and if so replaced by the contents of the attribute. You can use this both in the string for a msg() command, and in text pages of a gamebook.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums