Invalid Expression when concatenating text and variables in 13.23 Mac
Anyone else having trouble with this? I can no longer seem to concatenate text and data in the expression editor using the Display Text behavior. Now, with 13.23 on Mac I get an invalid expression when using the format: "Text: "..game.attribute
My old expressions still work but I can't create new ones that work.
Comments
Can you post a sample file that has both a working behavior and a non-working behavior?
Here's an example that works in Mac Creator 13.23.
Don't forget you can't concat booleans. Other than that, it should work fine. I've had no problems doing so in 0.13.23.
Thanks guys.
Ah, that's it- booleans. That's unexpected- is that normal? I understand that if the language is strongly typed why you couldn't intermingle variables, but doesn't the display text behavior convert the value to text?
It has to do with lua and for now that is the expected behavior you can not concatenate bools you need to convert them to a string. we have it on our list to fix
Well you can throw two display texts inside a rule. I thought I had another way but it only seems to work for the initial state of the boolean.
Edit: No, I was right - it can be done with one display text behaviour. Demo incoming.
So the display text behaviour doesn't convert bools to strings? I guess I expected it to since it outputs true / false vs 1/0 but I guess LUA uses true/false. In fact, looks like 0 can mean true! Guess I need to read up on LUA...
Well it's not truly concatenating a boolean, but the effect is the same. One display text, no converting to a string, no extra rules or attributes needed.
Demo:
Cool. Thanks for that! Can you explain the logic you used?
"Toggle is: "..((( game.Boolean ==true))and("On")or("Off"))
It's a lot to get into, but in essence it's doing this:
If game.Boolean is true, say "On", otherwise say "Off".
Just all in the expression editor.
Nice technique, @Armelline!
Thanks!