Best way to add data to the first row of a table
I know this is a simple question but that's what the forums are for, right? ![;) ;)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/wink.png)
Now that I'm using tables extensively for a game I'm building, I'm finding some quirks with the first row data that's causing problems. If I have a blank table and I want to add data to the table by adding a row at the end each time, I have to do:
When TableRowCount(TableName)=1 and TableCellValue(TableName,1,1)=”” change table value for row 1; Otherwise, add row to table at end and change table value at end row.
Without the RowCount rule, if I just add a row at the end of a "blank" table, it adds it at row 2, not row 1, and I end up having a table with a blank row at the top which causes all sorts of problems for counting rows, etc.
Is this just a fact of life or am I missing something? I really wish that tables could have zero rows.
![;) ;)](http://forums.gamesalad.com/plugins/emojiextender/emoji/twitter/wink.png)
Now that I'm using tables extensively for a game I'm building, I'm finding some quirks with the first row data that's causing problems. If I have a blank table and I want to add data to the table by adding a row at the end each time, I have to do:
When TableRowCount(TableName)=1 and TableCellValue(TableName,1,1)=”” change table value for row 1; Otherwise, add row to table at end and change table value at end row.
Without the RowCount rule, if I just add a row at the end of a "blank" table, it adds it at row 2, not row 1, and I end up having a table with a blank row at the top which causes all sorts of problems for counting rows, etc.
Is this just a fact of life or am I missing something? I really wish that tables could have zero rows.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Best Answer
-
The_Gamesalad_Guru Posts: 9,922
Answers
Here's an illustration:
*BEFORE*
Table
Row 1:
Add row to end of table
Change row 1, col 1 to "hello"
*AFTER*
Table
Row 1:
Row 2: "hello"
What I want is for my table to start out blank and after adding a row, to have ONE row.
*AFTER*
Table
Row 1: "hello"
Maybe it's a pipe dream.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
First, I have Constrain behavior: game.TableRows to tableRowCount(game.Rotation).
And a rule (after some actions):
If (here are some attributes, but unimportant for this message):
Change attribute: self.RowAdded to true
Add row: Table: Rotation; Action: Add Row, At The End.
Timer, after 0.1 seconds. Change attribute self.MyRow to game.TableRows
And then I have some other unimportant rules, and then:
Rule, if self.RowAdded is true
Timer, every 0.0001 seconds. Change Table Value: Table: Rotation; Row: self.MyRow; Value: self.Rotation.
That's all
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
@FryingBaconStudio... mostly text: about 5 integer columns out of 500 columns.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User