Display text with expression fails with booleans
imjustmike
Member Posts: 450
I'm trying to add some text in front of an attribute value using an expression along the lines of "text: "game.attribute
This works perfectly when the attribute is an integer or something similar, but when the attribute is a boolean this results in an invalid expression. Does gamesalad really not support adding text and a boolean in an expression or am I doing something wrong?
This works perfectly when the attribute is an integer or something similar, but when the attribute is a boolean this results in an invalid expression. Does gamesalad really not support adding text and a boolean in an expression or am I doing something wrong?
Comments
If game.attribute = true then
display text "text: true"
else
display text "text: false"
Hi @imjustmike Yes, it's either a bug, an oversight or intended... (i.e not able to concatenate with a boolean in a Display Text behaviour)... you decide which! ;-)
That's a really neat solution from @JamieOneil - a good workaround.
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
"text: "..((game.attribute)and(1)or(0))
you can also turn a Boolean into text:
"text: "..((game.attribute)and("true")or("false"))
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@BlackCloakGS Thanks for the explanation, BC, appreciated. :-)
""You are in a maze of twisty passages, all alike." - Zork temp domain http://spidergriffin.wix.com/alphaghostapps
@tatiang -- Boolean logic is its own universe. It sometimes seems (to me) to be counter intuitive, but it can be very useful.
What is this, and how do I learn more? I can't find any reference to an and() or or() inside GameSalad, and I feel like would be really helpful in other uses.
Go to learn.gamesalad.com and see @Armelline tutorial learning to love the expression editor.
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS