Tables - dynamically selecting tables to read data from?

durasrodurasro Member Posts: 1
edited March 2012 in Working with GS (Mac)
Is it possible to pass the table name value in tableCellValue(table,row,col) from a text attribute stored in some selector actor? I noticed in the Cookbook instructions that is manually browsed and selected. The "row" and "col" do work when assigned dynamically from some other variable but I could not figure out how to pass the first value, table. (I am trying to load different values from different tables based on the user's selection).

Comments

  • LumpAppsLumpApps Member Posts: 2,881
    edited March 2012
    I don't think it is possible but a workaround would be to put everything in one table and use offsets to find your data.

    For example (and to simplify this: we will use only one row):
    In column 1 to 5 you have stored values for a background images in world 1.
    In column 6 to 10 you have stored values for background images in world 2.

    When you look up backgrounds for level one you would normally do:
    tableCellValue(table,1,1)
    tableCellValue(table,1,2)
    tableCellValue(table,1,3)
    tableCellValue(table,1,4)
    or
    tableCellValue(table,1,5)

    Now in the situation sketched earlier you would do:
    tableCellValue(table,1,1+((world-1)*5))
    tableCellValue(table,1,2+((world-1)*5))
    tableCellValue(table,1,3+((world-1)*5))
    tableCellValue(table,1,4+((world-1)*5))
    or
    tableCellValue(table,1,5+((world-1)*5))

    Now when world = 1 it wil lookup column 1 to 5 (for example for column3: 3+(world-1)*5) = 3+(1-1)*5) = 3
    when world 2 is active it wil lookup 6 to 10 (for example for column3: 3+(world-1)*5) = 3+(2-1)*5) = 8

    Hope that helps.

    Cheers,
    Ludwig
  • durasrodurasro Member Posts: 1
    It does help!
    Thank you for your workaround suggestion!
Sign In or Register to comment.