Get Table cell value based on self attribute
Dues
Member Posts: 1,159
Hey guys!
Im about to go crazy, so some advice would be great
If I want to check if a table cell value is true based on a self attribute, what would be the best way to do that?
Here is what I want to achieve:
I have 1 actor. (It will be placed 10 times on the scene with different self number 1-10)
I create a table with one column (column represents self number)
And lets say ten rows (each row representing a level)
So if we are on level 3, and my actors self attribute is 1, I want my actor to get value from table on column 1 and row 3. If that value is true, change self position x and y to tablecellvalue of my choice.
Comments
tableCellValue(Tablename,game.Level,self.Attribute)
Though you'd need to have 10 columns, one per actor. Is there a particular reason you're wanting only one column?
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support
Instead of having your table values being booleans, which I assume is what they're currently set to, I would recommend changing them to integer types. 0 means false, 1 means true.
Create a game.Level attribute (integer). You will need to update this attribute based upon the level the player is currently on.
You would create a new self attribute called "True/False" -- or something like that. Do this in the actor that you want to move if the attribute is true. This is the attribute that will hold the condition in the table.
Change self.True/False to tableCellValue(Table1, game.Level, 1)
This will grab the value in the table at row 3, for example, if the player is currently on level 3.
You would then create a rule that says something like this:
Rule:
-If attribute self.True/False = 1,
-- Change Attribute: self.Position.X to XLocation in table
-- Change Attribute: self.Position.Y to YLocation in table
Hope that helps
EDIT: Ah, @Armelline beat me to it.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
@Armelline Thanks i will try that.
I was thinking 10 columns thats is the self value, and 10 rows that is each level.
I think what i have been doing wrong is the game, level in the tablecellvalue expression.
Hopefully this will do the trick. Ill post to let you know.
@Braydon_SFX Thanks
@Armelline @Braydon_SFX
Works like a charm!
Thanks guys!