Should I use attributes when reading and writing to tables

Can I read and write directly to tables using the expression editor or is it better to use attributes for this?

I am about to set up my achievements and I can do it without attributes but I am concerned it may cause problems if I don't. This may be a silly question but I am new to coding and don't want to create a problem for myself down the road.

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Since you're a PRO user, you have the ability to download and use the Nightly Builds. They have the option to use the Expression to Expression Comparisons. That feature is currently not available to others. I'd use that feature, it's much easier than creating several attributes and then using those attributes in your rule conditions.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @colander Excellent advice from @Braydon_SFX; just to add, it's like having a tool box and using the right tool at the time... what I mean by this is a lot of times attributes outside of tables is more than fine, and using attribute values in tables aren't necessarily any better.... then again, other times tables would be a far better option to access attribute values, especially if this is in an array-type scenario. I guess it comes down to experience with GSC as to which is the more efficient at any one time.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • colandercolander Member Posts: 1,610
    Thanks for your replies, I appreciate all the help the community provides.

    @Braydon_SFX that is good to know. I have thought about using the nightly builds but because of my lack of experience and confidence I decided to stay with what is working and not causing me any problems. I have nearly finished my first game and intend to start using the nightly builds for my next project. I don't need expression to expression to do this as it is checking or changing a table value depending on the score.

    @gyroscope sounds like it will be ok and it will save me creating 84 attributes, loading them at the start and all the double handling in the code.

    Just to check here is a brief description of what I want to do. The table will have 28 rows and 3 columns. All entries are a single integer and I will be using tableCellValue(table,row,col) function to check and change the values in the table one, two or three of them at a time. Is this ok? Also do I need to use a timer with run to completion checked for the Save Table action to make sure it runs?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    OK, got it now what you want, so yes, I see, it'd be fine to use tables in this situation...

    From what you've described, it seems fine, i.e change values in one to three tables. You shouldn't need a timer really unless you're saving hundreds of attributes at a time, they'll save quick enough before any other Rules/behaviours need to run after... and if your Save Table behaviour is after all of the attribute changes in the tables anyway, it'll only start when everything's been updated, so that'll be OK as is.

    One really important thing to consider if you are using Tables to save and load attributes: for every individual table you have, you need to make a blank new table, and right at the beginning, before saving even the first attribute, you need to copy the table to the blank, then save any changes to the copy, and load any changes from this copy too....

    And the reason is simple: say your app is a game, and you are changing all your attributes as the game progesses, these will load just fine next time the game is opened BUT you will not be able to start a new, fresh game with the original attributes. Does that make sense? (Hope I've explained it clearly enough for you...) ;-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • colandercolander Member Posts: 1,610
    edited October 2013
    @Braydon_SFX I should have waited a bit before replying. I now realise I do need to use expression to expression to do part of my routine, thanks.

    @gyroscope I don't think I need to worry about this as my game has no end and I have a reset score function if someone really wants to do that. If a player's score goes negative they can reset it but if they need it at all it will only be when they first start using the game. But I am going to think about it and do some more testing before I proceed.
Sign In or Register to comment.