Can i use a table attribute as a rule condition?

Im doing a large item database in a table and i need to use a column text attribute in a rule condition, but i dont know how.

Comments

  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    edited March 2013
    We REALLY need this feature ^ ... Sigh

    You cannot grab the cell from a table in a rule, currently. When you need to do is constrain or grab the value of the table and put that into another game attribute. Then reference that attribute in your rule.
  • SolarPepperStudiosSolarPepperStudios Member Posts: 754
    I was just wondering that too... That would have REALLY helped out one of my games... *sigh* maybe one day. [-O<
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    If you must use tableCellValue in your rule conditions make a game attribute called ConstantZero which equals 0. When game.ConstantZero = (other expression)-tableCellValue()...

    a = b => 0 = b-a
  • If you must use tableCellValue in your rule conditions make a game attribute called ConstantZero which equals 0. When game.ConstantZero = (other expression)-tableCellValue()...

    a = b => 0 = b-a
    It could be that it's 2AM for me right now, but I'm not quite understanding the method to your madness...and I really wish I did. My app will end up having several hundred attributes unless I could retask my behaviors to work with tables. Would you be able to give some more examples with your formula?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Hmm. I didn't get it either, but I'm intrigued...

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Instead of using the tableCellValue on the left side of a rule condition, use it on the right side.

    e.g. If you wanted:
    If tableCellValue(myTable,2,3) > 56

    Instead try,
    If game.ConstantZero > 56 - tableCellValue(myTable,2,3)
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Aha! Clever way of using zero instead of creating a specific attribute for each value you need. Thanks!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Instead of using the tableCellValue on the left side of a rule condition, use it on the right side.

    e.g. If you wanted:
    If tableCellValue(myTable,2,3) > 56

    Instead try,
    If game.ConstantZero > 56 - tableCellValue(myTable,2,3)
    this is what I do to track high scores. I have my code like this:


    if levelScore > tableCellValue(tblLevelSettings,currentLeve,2)
    then do this

  • Ah, I see. Very nice work-around. I'll definitely take a close look at my app and see how long it'll take me to re-work what I already have built into multiple attributes.

    On another note, though, do you have any clever solutions to cells/colums that are not integers or real values? Several of my tables would use text.
  • CodeMonkeyCodeMonkey Head Chef, Member, PRO Posts: 1,803
    Change a text attribute to the tableCellValue and use that for the left side of the rule condition?
Sign In or Register to comment.