Storing Game Attributes in a Table - refer to the Table or to the Attribute?

In order to make it extremely convenient for me to tweak the game calculations, I was going to store all of the constants in a Table and refer calculations to it there, instead of writing constants directly into the equations.

My question is this: in the interest of game speed, is it better to refer to the table directly, or to update a global attribute to the table value?

  • Table directly: Damage calculation would be (tablecellvalue(TB_Constant,1,2)*Self.Damage)
  • Attribute: Damage calculation would be (Game.DamageMod*Self.Damage), and then I'd have an actor that updates the Game.DamageMod attribute to match tablecellvalue(TB_Constant,1,2)

Best Answer

  • Braydon_SFXBraydon_SFX Posts: 9,273
    Accepted Answer

    @TheAlchemyst said:
    I'd prefer tables as well, but I'm expecting some pretty heavy calculations so I wanted to check. I know there are some... intricacies to what impacts game speed that are hard to tell from a beginner's perspective

    It can get messy and complicated doing calculations in a table expression. If that's the case perhaps you want to use global variables. Again, it's up to you.

Answers

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    edited March 2015

    I don't know if you'll see much difference if you see difference at all. I'd say you should go with your preference.

    My preference would be to use tables.

  • TheAlchemystTheAlchemyst Member Posts: 16

    I'd prefer tables as well, but I'm expecting some pretty heavy calculations so I wanted to check. I know there are some... intricacies to what impacts game speed that are hard to tell from a beginner's perspective

  • TheAlchemystTheAlchemyst Member Posts: 16

    What complications would that be? Being an Excel geek by day, I figured I could just do something like (tablecellvalue(TB_Constant,1,2)*Self.Damage)^(tablecellvalue(TB_Constant,1,3))-tablecellvalue(TB_Constant,1,4) or what have you and still be fine

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273

    @TheAlchemyst said:
    What complications would that be? Being an Excel geek by day, I figured I could just do something like (tablecellvalue(TB_Constant,1,2)*Self.Damage)^(tablecellvalue(TB_Constant,1,3))-tablecellvalue(TB_Constant,1,4) or what have you and still be fine

    If you use Excel a lot, then you would most likely spot errors in your expression. I don't use Excel much but do a lot of table expressions. If it's a long expression, sometimes I leave out a parenthesis or two. That's just me.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.