Using attribute to choose table

ckck Member Posts: 224
edited February 2012 in Working with GS (Mac)
Does anyone know how to use an attribute to choose the table to read?

I'd like to set an attribute to indicate the level number. The game would then read the attribute number, and use that to determine which table to read, determining the starting point for each actor. This way, I could build all of my levels into a single scene.

I would think it would look like:

When game.LevelNumber = 1, change game.currentTable to Table 00

where Table 00 equals the name of the table for level 1.

Then:

When game.LevelNumber =1
Change attribute self.Position.X to tableCellValue(game.currentTable,1,1)
Change attribute self.Position.Y to tableCellValue(game.currentTable,1,2)

Not working out -- I suspect it's bad logic on my part. Or can you not use a variable in tableCellValue?

Comments

  • calvin9403calvin9403 Member Posts: 3,186
    make an attribute call level?

    when you are on lev1 then change it to 1

    when level=1

    Change attribute self.Position.X to tableCellValue(game.game.level,1,1)
    Change attribute self.Position.Y to tableCellValue(game.game.level,1,2)

    name your table 1,2,3 etc

    dunno if that will work , but I think it will be fine
  • Rob2Rob2 Member Posts: 2,402
    @ck You can't pass the name of a table indirectly via an attribute. Tables can only be referenced directly by selecting them in the expression builder.
  • MotherHooseMotherHoose Member Posts: 2,456
    at this stage … I can't work around this :-t
    I can see that the tables folder is not listed in the assets.xml with the sounds, images, behaviors folders
    (and those 3 have separate panes in the inspector … wish tables had a pane … instead of sometimes being a pain)
    and that assets.xml updates with each sound/image/behavior imported/added
    I note that the table is listed in gameAttributes as a Table type
    and, in object.xml it is referenced with name as well as id

    I have tried everything … including a Table with the table names and ids as cellValues
    and adding the folder to the assets.xml (which will not be included when assets is updated)
    surprisingly with all my finagling … GS doesn't crash … just ignores me!

    I am not upset that we can't do this … or I can get it work … just having Tables is wonderful!
    and believe each GS update will expand our ability to access and use them!

    @};- MH
  • ckck Member Posts: 224
    I'm giving this another try, but with a single table. Each level's data will be contained in a single column. It's one MF of a table, but I think it's the solution. Will report.
  • MotherHooseMotherHoose Member Posts: 2,456
    Good for you … some work in spreadsheet

    on thing I found handy … when table is in GS … saveAs a project that just has the table
    then you can open that and reference the table when working in you actual gameProject … without clicking back and forth alot

    @};- MH
  • ckck Member Posts: 224
    That's a great tip!
Sign In or Register to comment.