Get Table cell value based on self attribute

DuesDues 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

  • ArmellineArmelline Member, PRO Posts: 5,369

    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?

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

    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.

    @Dues said:

    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.

    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.

  • DuesDues Member Posts: 1,159
    edited June 2014

    @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 :)

  • DuesDues Member Posts: 1,159
    edited June 2014

    @Armelline‌ @Braydon_SFX‌
    Works like a charm!
    Thanks guys! :)

Sign In or Register to comment.