Using Tables to store multiple user input texts, and displaying the texts in actor
Hey everyone,
I'm currently learning to use tables (as suggested by @Japster and @tatiang in my prev question). I looked at the tutorials on tables and pretty much understand how it works and why we use them. After trying it out I have some questions.
Condition:
I want the user to be able to keyboard input multiple text attributes (up to 20), and then have the text stored in one col or row of my table, and then have them each displayed in an actor, before later randomising the texts to result in a winner text.
Problem:
I used one button actor for prompting keyboard input, and an integer attribute +1 for each new input added. And then I use change tableCellValue behaviour to store each of the user input text in the table in hopes to be able to display them in different actors by simply using the expression editor to pull the tableCellValue in display text behaviour in the actor. But it did not work well it worked for only one actor, but not for the second and the rest. The other actors wont display the tableCellValue.
Questions:
1. Where should I put change tableCellValue behaviour? - in the "add button" actor or in each "display text" actor or in other?
2. Where should I put save table behaviour if I want to save every input?
3. Do I have to have up to 20 text attributes and up to 20 actors for this?
4. Additional question: Does the keyboard prompt work properly in both Android and iOS?
That's the questions for now, I hope I can learn from all of you, thank you!
Best Answer
-
tatiang Posts: 11,949
It would look something like this:
When touch is pressed
Change attribute game.input to ""
Keyboard input [game.input]When attribute game.input is not ""
Change table cell value
Save tableYou should only need one text attribute, a game attribute to store the keyboard input each time before it's stored in the table. Twenty actors? Probably just one actor with 20 instances (copies) in the scene.
Note: the "" (double quotes) is just a blank string.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers
Hey thanks @tatiang,
Aha! So that way, the game.text attribute is just a bridge from user to table, very nice. And use my integer attribute+1 to control which row to insert, is that correct?
One actor with multiple instances in one scene, so I should just go in and modify the display text behaviour in the each instance, okay noted! This makes it simple and clean.
I'm already out of my house right now, I can't wait to try this method later tonight. I will update, thanks again!
Yes.
It's not clear from your description how you intend to display the table values. But you might consider the tableMergeValues function described here and shown here. For example, if you wanted to display all 20 rows horizontally, you could merge the cells with a space separator (" ") or if you wanted to display them vertically, you could merge the cells with a newline separate ("\n").
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
This is great! Thanks