Invalid Expression when concatenating text and variables in 13.23 Mac

Agent ArgyleAgent Argyle Member, PRO Posts: 188
edited June 2015 in Working with GS (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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Can you post a sample file that has both a working behavior and a non-working behavior?

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Here's an example that works in Mac Creator 13.23.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • ArmellineArmelline Member, PRO Posts: 5,369

    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.

  • Agent ArgyleAgent Argyle Member, PRO Posts: 188
    edited June 2015

    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?

  • BlackCloakGSBlackCloakGS Member, PRO Posts: 2,250
    edited June 2015

    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

  • ArmellineArmelline Member, PRO Posts: 5,369
    edited June 2015

    @BlackCloakGS said:
    you can not concatenate bools you need to convert them to a string.

    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.

  • Agent ArgyleAgent Argyle Member, PRO Posts: 188
    edited June 2015

    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...

    2.2 – Booleans

    The boolean type has two values, false and true, which represent the traditional boolean values. However, they do not hold a monopoly of condition values: In Lua, any value may represent a condition. Conditionals (such as the ones in control structures) consider false and nil as false and anything else as true. Beware that, unlike some other scripting languages, Lua considers both zero and the empty string as true in conditional tests.

  • ArmellineArmelline Member, PRO Posts: 5,369
    edited June 2015

    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:

  • Agent ArgyleAgent Argyle Member, PRO Posts: 188

    Cool. Thanks for that! Can you explain the logic you used?

    "Toggle is: "..((( game.Boolean ==true))and("On")or("Off"))

  • ArmellineArmelline Member, PRO Posts: 5,369

    @Agent Argyle said:
    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.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Nice technique, @Armelline!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • Agent ArgyleAgent Argyle Member, PRO Posts: 188

    Thanks!

Sign In or Register to comment.