GameSalad programing question

BobDBobD Member, PRO Posts: 374
edited July 2012 in Working with GS (Mac)
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

Best Answer

  • J_PANJ_PAN Posts: 140
    Accepted Answer
    infinte means timer is 0 secs

Answers

  • AcceleratedGamesAcceleratedGames Member Posts: 201
    Try this:

    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).
  • BobDBobD Member, PRO Posts: 374
    Thank you - I sorry I did not state the question clearly.

    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
  • AcceleratedGamesAcceleratedGames Member Posts: 201
    Thank you - I sorry I did not state the question clearly.

    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.
    Ok, in that case do this:

    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.

    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.
    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).
  • BobDBobD Member, PRO Posts: 374
    Thank you again. I tried your suggestion but i could not get it to work. If the rows were 90% full it worked most of the time. When I tried it with only one row set it could not find it 99% of the time. I think GameSalad only lets you trigger it once so that you do not get into a infinite loop. I did try using a timer (every .001) and it did trigger the search 5 times. I need a way for GameSalad to trigger the search until it finds a non-empty row or reach a fixed # searches. Any other suggestions?
  • BobDBobD Member, PRO Posts: 374
    Thank you, Still not perfect but works OK! I think I can live with it for my app.
Sign In or Register to comment.