Save / Load Character from tables

3itg3itg Member, PRO Posts: 382
edited June 2012 in Working with GS (Mac)
I played with trying to set this up for a couple hours, but I keep getting invalid expressions when I try to recall data from my tables.
Im new but I think I have a pretty good idea of what I'm trying to do ( I have used other game engines successfully).

Would someone be willing to explain where I am going wrong?

Quick explanation of what I was trying:
from my character creation scene, I made a keyboard so the player can enter their name, this becomes the game.Name.
then I tried to save game.Name to a table (called GameSave) by creating an actor that takes the text input, changes the game.Name to match the input and then save the game.Name to the GameSave table in row1 / column 1. after saving, go to the next scene.
In my next scene, I made a test actor to attempt to display the value of row1/column1 of the GameSave table to check that the data is being saved to the table. However, I only seem to be able to get "Invalid Arguments". (I made an actor with a self.PilotName attribute, and am trying to make it equal the data from row1/column1 in a "Display Text" behavior in the actor)

So just to be succinct, What is the correct process to save a name (or other player stats) to a table to be called later?
Can you provide an example of what the actual expression looks like from the editor? (maybe for loading and saving, since I'm not sure where I'm going wrong(and yes I watched videos))

I am attempting my first larger project in game salad after being very pleased with 2 other games I was able to make in less than a week. I want to expand on the type of games I can make and I figured saving, loading character data is a good way for my audience to pick up where they left off.

If anyone who is feeling helpful needs more info, I would love to provide it to you :)

Best Answer

  • HC_DKHC_DK Posts: 92
    Accepted Answer
    I asume that you first COL is TEXT.

    I have done a simple test and I used to LOCAL text attributes (Text From Table and Text To Table) and two rules.

    First rule:

    When Actor receives event TOUCH is PRESSED:
    Change Attribute: self.Text From Table to tableCellValue(MyTable, 1, 1)
    Change Attribute: self.Text To Table to tableCellValue(MyTable, 1, 1)
    Keyboard Input:
    Change Attribute: self.Text To Table
    Keyboard Prompt: (This is used for a headline)

    Second rule:
    When Attribute self.Text From Table is self.Text To Table
    (DO NOTHING)
    Otherwise:
    Change Table Value:
    Row: 1
    Column: 1
    Value: self.Text To Table
    Save Table: MyTable

    The for your next scene have an actor with Display Text: tableCellValue(MyTable, 1, 1)

    Hope this can help you.

    HC

Answers

  • 3itg3itg Member, PRO Posts: 382
    I was only using linear, wasn't using otherwise...
    Also, i was typing "self." and "game." instead of using the menus to select those and that also stopped it from working
  • mrpacogpmrpacogp Member Posts: 400
    I`m using this method too, but i take "Invalid Expression" all time, and the tablet on my project maybe saved the value?
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    It is best to select the attributes using the drop down list instead of typing. i don't know but sometimes it happens that self typed expression are not being registered when running. Also capital letters or wrong spelling could have cause error.
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    edited November 2012
    http://i48.tinypic.com/2w2lixi.png

    I made a demo to show text saving and loading from table works.
    You can use the actor that displays the name text in any scene you want.
    Just convert the name saving part to user input.
    Attached a window & Mac GS file.
  • mrpacogpmrpacogp Member Posts: 400
    Thank you very much for the demo.
    I`m working on that, and i think i can do a lot of things using tablets instead
  • mrpacogpmrpacogp Member Posts: 400
    I`m doing the same of your template and dont work... i open a blank project, copy the same of your and nothing... i have something wrong..
  • mrpacogpmrpacogp Member Posts: 400
    My gamesalad breaks all time when i do it that:
    Create Scene. Add attribute text name player
    Create actor, collect name, input rule, when player hit, keyboard input, and set that to name player, change value table row 1 col 1 to game.nameplayer
    Create actor, display text, display table and row 1 col 1

    Why breaks all???
  • mrpacogpmrpacogp Member Posts: 400
    edited November 2012
    Ok, finally found something, i have to input two time the value for record it to table, what its worng?
    https://docs.google.com/open?id=0B1KHen0jvlLzSVBDQ1JseTN6LTQ

    I have modfy that

    https://docs.google.com/open?id=0B1KHen0jvlLzYXd2Y0xTb2VJNDA

    Now dont breaks, because i dont repeat the attribute en game and actor values, but, still to repeat the input value for take it the final actor...
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    Well then good luck with the rest of the game making :P
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    @mrpacogp Well taking a look at the file you sent me, it was easy to spot the problem.
    The name won't show once you key in the name because you need to separate the save to table function seperately. The conditions you stated run keyboard input and save to table at the same time so it registered a blank entry. but by using a seperate save button you will be able to see the updated name after clicking save button after you enter the name.
  • mrpacogpmrpacogp Member Posts: 400
    Just tested your file and all time crashes gamesalad.
    I use last version of it.
    0.10.00 beta
  • GLGAMESGLGAMES SingaporeMember Posts: 988
    edited November 2012
    you cannot run it in preview, the one you sent me has the same problem. it hangs the whole GS. i ran it in my gs viewer on my ipod it's fine.
    @StraightSaladShooter hi not sure if it's a bug but the keyboard input doesn't work in preview . It hangs the whole GS.
Sign In or Register to comment.