GameSalad programing question
Hi -
I have a table with 1 column and 50 rows (defined as text).
A player can add a text string into ANY of the 50 rows. (the remaining are blank)
I want to be able to randomly select a row with text (ignoring the rows that do not have text.)
I would like a error flag if no rows have text)
Can this be done in GameSalad?
Thanks,
Bob
I have a table with 1 column and 50 rows (defined as text).
A player can add a text string into ANY of the 50 rows. (the remaining are blank)
I want to be able to randomly select a row with text (ignoring the rows that do not have text.)
I would like a error flag if no rows have text)
Can this be done in GameSalad?
Thanks,
Bob
Answers
1. Make a Text attribute called "BlankChecker" with no text in it.
2. Make an Index attribute called "RowPicker"
3. When a user wants to add to text, change game.RowPicker to random(1,50).
4. Then add this rule directly UNDER the change attribute in #3: If BlankChecker is tablecellvalue(game.table1,game.RowPicker,1), then change table1, row game.RowPicker, and column 1 to whatever the user wanted. Otherwise, change RowPicker to random(1,50).
The user gets to pick which rows to add the text too. They can fill all 50 rows or just only 1 row. On the average the rows will be sparsly filled with text.
Later on in the game the I want to be able to randomly retrieve a row that contains text that was entered by the player. In the case the player did not enter any text I want to set a empty flag attribute.
I can do this if it was possible in GameSalad to loop until a condition was met.
Thanks,
Bob
1. Make a Text attribute called "BlankChecker" with no text in it.
2. Make an Index attribute called "RowPicker"
3. Make an Index attribute called "WhatRow" in the actor that is selected to add the text.
4. Change this attribute in every instance of the actor on the scene to which row it is associated with.
5. Then add this rule to that actor mentioned above: If BlankChecker is tablecellvalue(game.table1,game.RowPicker,1), and touch is released, then change attribute game.RowPicker to self.WhatRow and change table1, row game.RowPicker, and column 1 to whatever the person wants to write with a period at the end
You can do that by adding a .."." to the end of the keyboard prompt expression. For this, it is very similar to what I said before:
1. Make a Text attribute called "WrittenChecker".
2. Make a Text attribute called "Period" and add a period to it.
3. When a user wants to call upon a random row, change game.RowPicker to random(1,50) and change game.WrittenChecker to tablecellvalue (game.table1,game.RowPicker,1)
4. Then add this rule directly UNDER the change attribute in #3: If WrittenChecker contains game.Period, then display game.WrittenChecker. Otherwise, change RowPicker to random(1,50) and change game.WrittenChecker to tablecellvalue (game.table1,game.RowPicker,1).