Function parameter in text message

Doctor Agon
17 May 2020, 06:07

There's probably a simple solution to this, and I've tried all the permutations I can think of.
I have a message, but I want a different message to be displayed depending on the Boolean value of the parameter being passed to it. The parameter name is 'pre'. I'm using the text processor {…}
So I've tried.

{if pre = true:crosses}{if pre = false:crossing}
{if pre = "true":crosses}{if pre = "false":crossing}
{if pre:crosses}{if not pre:crossing}
{if pre:crosses|crossing}

But it doesn't seem to like any of them.
Any help as always is much appreciated.


Dcoder
17 May 2020, 07:33

The text processor only takes attributes, not variables. Try this:

game.pre = pre
msg ("{either game.pre:crosses|crossing}")

mrangel
17 May 2020, 08:45
game.text_processor_variables = QuickParams ("pre", pre)
msg ("{either pre:crosses:crossing}")

The only variables the text processor can access are the ones in the text_processor_variables dictionary.
The third option is correct, but if you're checking both true and false it's quicker to use either.


Doctor Agon
19 May 2020, 08:17

Thanks for the help guys. That works great. Much appreciated.