Variable Text in Gamebooks

This is probably trivially simple, but I can't work it out. How do you get conditional text to work in a gamebook?

Basically, as I don't know the system very well I'm trying to keep things as simple as possible. I just want text to display differently depending on what pages the player has seen before. Something like:

"So you must be a {if (HasSeenPage(Female)) {
msg ("girl")
}
else if (HasSeenPage(Male)) {
msg ("fellow")
}} then!"


But, you know, something that actually works.

One way to do it...

On the "Female" page, change page type to "Script + Text". Add a script "set variable or attribute" so game.gender = "female".

On the "Male" page, change page type to "Script + Text". Add a script "set variable or attribute" so game.gender = "male".

Now you can use {game.gender} any time you want to print the correct gender, e.g. "So you must be a {game.gender}"

I've not tested the above but hopefully you get the idea.

Unfortunately, it doesn't seem to work. I'm able to set the page types and add the scripts like you put, but {game.gender} doesn't print anything in the text.

Unless I'm missing something, printing variables into the text doesn't appear to be on the list of supported curly bracketed forms understood by the text processor: http://quest5.net/wiki/Text_processor

Ah, I think I get it. Gender is supposed to be an object attribute of the game object, right? Uh, does that need to be defined/set independently of where I set it on a page?

EDIT:

I'm getting the following error at the top of the female page:

Error running script: Error compiling expression 'female': Unknown object or variable 'female'


I can't be sure without seeing the code, but it looks like you're using female somewhere where it should be "female" (in quotes as a string).

Hit the nail on the head. Got it to work in a quick test just now. Great!

It strikes me that conditional text is the bread and butter of modern text games, so this is the sort of thing that should be included on the wiki.