Can't get tables to work
RossmanBrothersGames
Member Posts: 659
I have gotten to the point in my project where I am making a table to handle level data (completion, best time, score).
I am entering in the code for the way I think tables should work but am unable to get my game to interact with tables.
I made a scene with an actor to test the problem. I try and make it by pressing a button it changes a table cell value that is set up as a real number to a certain value, and then displays the text of that number, when I try it I just get an invalid expression.
This is my rule and behaviors all under the same rule
Rule: actor receives event: key: space is down:
(Change Table Value
Table:levels
Row:1
Column: 1 Value: 2)
(Save Table
Table: levels)
(Display text
text:tableCellValue(levels,1,1)
)
When I press spacebar a text comes up displaying invalid expression
This is what happened when I was trying it in my game, I had a rule for when the attribute for the level ending was true to save the level score to the table, then display it in text, still invalid expression. If I make an attribute and change that attribute to the table cell value, and then display that attribute the attribute always displays as zero. Rather than what the actual table cell value is.
Am I missing something? Seems pretty straightforward to me. Thanks for taking the time to look at this and help me out.
I am entering in the code for the way I think tables should work but am unable to get my game to interact with tables.
I made a scene with an actor to test the problem. I try and make it by pressing a button it changes a table cell value that is set up as a real number to a certain value, and then displays the text of that number, when I try it I just get an invalid expression.
This is my rule and behaviors all under the same rule
Rule: actor receives event: key: space is down:
(Change Table Value
Table:levels
Row:1
Column: 1 Value: 2)
(Save Table
Table: levels)
(Display text
text:tableCellValue(levels,1,1)
)
When I press spacebar a text comes up displaying invalid expression
This is what happened when I was trying it in my game, I had a rule for when the attribute for the level ending was true to save the level score to the table, then display it in text, still invalid expression. If I make an attribute and change that attribute to the table cell value, and then display that attribute the attribute always displays as zero. Rather than what the actual table cell value is.
Am I missing something? Seems pretty straightforward to me. Thanks for taking the time to look at this and help me out.
Comments
make a game attribute text : change
than change attribute "change" to tablecellvalue(game.table,tablerowcount(game.table),col)
display text game.change
then make another rule
key space is down
change attribute game.change to table.row or col+1
I didn't need it to change the text, I was just using it for a test. But your code helped me figure out the problem. I didn't know it need to be game.tablename. I thought you would just write in the table name, its working now. Thanks!
www.rossmanbrosgames.com
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS