Table data check

Hi,
I'm creating a math game and need to be able to check the player's total against a list of numbers I've put in a table. Anybody know how can I do this?
Thanks

Answers

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    You can check an attribute against a table value in a rule. Use the tableCellValue function
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited March 2014

    Hi @mconyers and welcome to GameSalad and the Forums.

    Do you want to cycle through all rows to compare with the player's total, or compare with the highest number in the Table, or something different again?

    Edit: writing while @Braydon_SFX was posting.
  • mconyersmconyers Member Posts: 1
    Hi guys - thanks for your answers. I want to check the player's total against all values in a table to see if there's a match.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited March 2014

    OK, one way would be to create a loop for it to compare each row (make it an integer if you want to start the process off rather than it starting automatically):

    Rule: When Loop is 1
    When RowCount < tableRowCount(YourTable)
    Change Attribute RowCount to Row+1
    When playerTotal = tableCellValue(YourTable,RowCount,1)
    ---whatever you want to do with this info
    Change Attribute Loop to 2

    Rule: When Loop is 2
    Change Attribute Loop to 1
    -----

    hope that helps.
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    @gyroscope‌ how easy this would be with the new table functions. :)
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    @Braydon_SFX So right, Bray. :-)
Sign In or Register to comment.