Displaying text... in a dynamic way (not working, need help, please!)

ryastryast Member Posts: 145
edited February 2015 in Working with GS (Mac)

I have 5 text attributes:
Note1 = "one"
Note2 ="two"
Note3 ="three"
Note4 ="four"
Note5 ="five"

I have one more INDEX attribute called counter, and its set at 1
eg: counter = 1

I have a display-text set up like this:
scene.note..game.counter

Running the above gives me "Invalid Expression" :(

Basically, as the counter goes up, I want my display-text to first show me the value of
Note1,
then Note2
then Note 3
etc

What am I doing wrong?

Thanks!

Comments

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

    Scene.note is a text attribute and game.counter is an index attribute, right?

    Make sure you are selecting both attributes from the drop-down menu and not just typing them into the expression editor.

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

  • ryastryast Member Posts: 145

    Scene.note1 is a text attribute.
    game.counter is an index attribute.
    I have to double click the note1 to make it editable and take out the "1" from that string... I think its there that I am making things go screwy... :(

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

    Also, the Display Text behavior should be outside of any Loop behaviors.

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

  • ryastryast Member Posts: 145

    @tatiang said:
    Also, the Display Text behavior should be outside of any Loop behaviors.

    No loops. Just a simple display text and those 5 variables... nothing else.

  • ryastryast Member Posts: 145

    Attaching one of the most simplest project files you will ever see! :p

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

    You can't access attributes using an expression for the name of the attribute. You can display Scene.note..game.counter if Scene.note is an attribute name but you can't use that expression to display Scene.note1, Scene.note2, Scene.note3, etc.

    For that you really need... wait for it... tables.

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

  • ryastryast Member Posts: 145

    Yes, I want it to dynamically call each of the variables as my counter gets increased.

    So, I put in scene.note then the counter gets added (1,2 or 3) and it becomes scene.note1 which should get the value from the attribute...scene.note1, then scene.note2 etc

    For that you really need... wait for it... tables.

    Heh! I was trying to bypass tables in my little experiment but you caught me :p

Sign In or Register to comment.