Match with table row values
wolala123
Member Posts: 249
Hi, sorry my bad english.
For example, i have number 123456 on the screen. When i press the number and match with table values. For the table side, r1 c1 is 123, r2 c2 is 345, r3 c3 is 56 and etc. How to make it? Thanks.
Modified:(r1 c1 is 123, r1 c2 is 345, r1 c3 is 56)
Comments
Can you explain more about what you're trying to do. I understand you have a table that looks like this:
123
345
56
Are you trying to see if those three values when joined make 123456? If you concatenate them, you'll get 12334556 so it will be difficult to determine a match.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang sorry i type wrong info for you. table look like this:
123 345 56
i will try to make maths game. one screen or level got 3 questions. 1st question's value or answer is 123 and etc.
Okay, then it's not hard to do. When attribute game.guess = tableCellValue(tableName,game.level,game.questionNumber) ... [behaviors].
The value of game.questionNumber should start at 1 and increase by one after each question is answered and then change back to 1 when the level changes. The value of game.level should start at 1 and increase by one on each new screen.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang i understand it. What if that 3 question, i answer randomly. It means that i answer start from question 2, 3, 1 which is not start from question 1 to 3 ? Thanks for help.
If you are presenting the questions in a random order, that makes it tricky to work with the table the way you have it. I would probably set up the table so that each level is a column with possible answers going down in rows:
123 408 544
345 229 678
56 180 300
For each level, I would copy the three rows from that level's column into a separate table that has a single column and three rows:
123
345
56
And then do:
Change attribute game.questionNum to random(1,tableRowCount(tableName)) and use game.questionNum within tableCellValue(separateTableName,game.questionNum,1) to compare the answer. Remove the row at index game.questionNum and repeat this process until the table is empty. Then go on to the next level by changing game.level to game.level+1 where game.level represents the current column in the original table.
As you can see, this type of app is complex and takes a lot of work to get right.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@taitang possible table do like this:
Q1 123 345 56
Q2 408 229 180
Q3 544 678 300
Of course it's possible! I just recommend doing it the way I suggested because some of the table behaviors and functions are only available for rows (specifically, Add/Remove Row).
I edited my post above to include the step of removing the row after it's used.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User