[Solved] Multiplying Table Values

theRealFireFoxtheRealFireFox Member Posts: 6
edited February 2015 in Working with GS (PC)

Hello, I am trying to create an RPG game. I want to make data sets that modify the value of the player tables, so there would be a value in one row on one table that would multiply another value on another table. But only when the player collided with an object, so like tableCellValue("valueTable1", 1, 2)tableCellValue("Value", 12, 25) but only when they move over an item. Then I want them to display to an output table like "OutputTable", so that another actor can display the information. I tried to use the functions changeTableValue and change attribute on the actor so that the tableCellValue("valueTable1", 1, 2)tableCellValue("Value", 12, 25) would put value in a self.Output attribute then write with changeTableValue(game.Output, 1, 1) = self.Output and then using a timer on the other actor to display(game.Output, 1, 1) after 2 seconds and it does not seem to ever change the value. Am I missing a command? Or is my operator in the tableCellValue command string incorrect? Please Advise!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited February 2015

    It may be the forums formatting but I don't see an operator. Multiplication would be done with an asterisk (*). Is that what you tried? If so, you should verify your table cell values by using a Log Debugging Statement or Display Text behavior to make sure they contain the values you think they do.

    Edit: I see that you did use asterisks.

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

  • theRealFireFoxtheRealFireFox Member Posts: 6
    edited February 2015

    I did use when writing self.Output a *, basically it looked like ChangeAttribute(self.Output) = tableCellValue((valueTable1), 1, 2)*tableCellValue((valueTable2), 12, 25). Then I did a changeTableValue((game.Output), 1, 1) = self.Output and then a basic display text = tableCellVaule((game.Output), 1, 1) on a timer of every 2 seconds (to show the changes) and I got nothing but the value that was already in game.Output, 1, 1 which was 55. I ran a debug and it did not show any variable structure, am I writing this info in correctly? do I need a space for the operator?

  • colandercolander Member Posts: 1,610
    edited February 2015

    If you upload a test project to Dropbox or similar showing the problem someone will be able to have a look and find a solution for you. No spaces for anything in the expression editor.

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2015

    To add to what's already been said- I note that in your first example, you seem to be putting the names of your Tables in quotes, then in the second example, the names of your tables with extra brackets - neither is correct. Hope that helps.

    So a quick test using DisplayText and an integer attribute called Output would show correctly as a test with

    Change Attribute Output to tableCellValue(TableA,x,y)*tableCellValue(TableB,x,y)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • theRealFireFoxtheRealFireFox Member Posts: 6

    I was using the " "'s to just show the values in this post, I will post up the file Im using to dropbox today. Basically the Change Attribute self.Output = tableCellValue(game.valueTable1, 1, 2)*tableCellValue(game.valueTable2, 12, 25) is what I was doing on a collide with player. Ill upload to see if someone can help.

  • theRealFireFoxtheRealFireFox Member Posts: 6

    I figured it out! I was doing the Change Table Value outside of the collision call, so it was not writing the variable properly. Thank you guys for the help, and Im sure this will help others at some point in the future =)

Sign In or Register to comment.