Must Read about crashes related to table

The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
edited October 2015 in Working with GS (Mac)

I've seen this issue a lot around lately. Tables causing crashes. Here is why,

When using an attribute or attributes in a table cell expression like tablecellvalue(table,row,col) ** and you do something like this **tablecellvalue(table,self.row,game.level) at some point those values will start as zero. Since there is no row/column zero this will produce an invalid expression and cause a freeze/crash. Same if you adding rows or columns as you go. The values for the row/column needs to exist before the code looking for that value fires. There are two ways to address this.

  1. Plan your logic properly so the values fill before the code that access that information fires.
  2. Wrap that code in a rule that says when self.row is > 0 do the code.

I often use both methods as sometimes you can't rely on code order in GS or you have multiple events that won't fit a ordered structure. The second method works every time and will eliminate the potential for a crash.

Most crashes, if not because of memory overload, will be related to either invalid expressions or addressing a Boolean as an integer or vise versa.

Comments

  • As_Of_LatteAs_Of_Latte Member, BASIC Posts: 343

    Does the above post still render true for the most recent version of GameSalad? Tables causing crashes? My game crashes during testing and I believe it may have something to do with the tables I have set up...

    Also, if tables are still causing crashes, I'm assuming the above method by @The_Gamesalad_Guru is set with a self.row integer attribute starting at 1? Or does the attribute type/start matter?

    Thanks in advance :)

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069
    edited November 2016

    This is still relevant today, tables don't have a row zero, so it causes issues when it has references to attribute that start at 0. Not anything wrong with the tables, this is the intended and correct behavior.

    The two methods above will work just fine.

    Edit: The start value matters, just make it a 1 whether its a game attribute or self (in the actual attribute list).

    Follow us: Twitter - Website

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    As was said this is not an issue with gamesalad. This is how code works and it's working correctly. You can't ask the computer to look for a row that doesn't exist, especially zero, as there is never a row zero. You must think about what you are asking the code to do. Most people overlook this fact.

  • vikingviking Member, PRO Posts: 322

    Good to see you lurking on the forums again The_Gamesalad_Guru :) Quick question about crashes: My game crashes every time on first load on the device, but then if I run the game again it will not crash on the second or any subsequent load. Does that rule out the table cell value zero issue? Has anyone else had/solved this problem?

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922

    The table cell value issue is only happens when the associated behavior,the expression is in, is called.

Sign In or Register to comment.