Cheat codes using table

SolarPepperStudiosSolarPepperStudios Member Posts: 754
edited February 2013 in Working with GS (Mac)
I want to make it so that a player can use keyboard input to enter a cheat code. It would work with a table like the following:
Type: User input: Correct input:
money "user text" moneybags
etc.

I would have an actor that you tap to pull up the keyboard input and how would I put the inputed text into the User input column? Thanks for help!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Keyboard input is stored in an attribute. Just use a Change Table Value behavior to store that attribute in a table cell. I'd recommend considering having a series of boolean values instead of text values in the table. That way, if the person types "moneybags", you change the table cell value for that row and column to true. Otherwise, you'd have to search the table for certain text strings, which is a pain.

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

  • SolarPepperStudiosSolarPepperStudios Member Posts: 754
    @tatiang Ok thanks! One question though, how would I go about that with more than one cheat code? Lets say I have 3 rows, how would I check all of them to see if any match?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    If you use tables, you would have a rule for each row of the table to check that boolean value.

    Another way to do this is to store the name of the cheat code in a text attribute that is saved to the device. If the player inputs something that matches one of your codes ("moneybags"), you would do Change Attribute game.cheatCodes to game.cheatCodes..game.keyboardInput.."#"

    So if they player entered two correct codes, such as "moneybags" and "doublescore", your text attribute would look like:

    moneybags#doublescore#

    And then your rule to check the codes would be:

    When attribute game.cheatCodes contains "moneybags"
    .....[behaviors]
    When attribute game.cheatCodes contains "doublescore"
    .....[behaviors]

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

  • SolarPepperStudiosSolarPepperStudios Member Posts: 754
    @tatiang Ok thanks a lot! I'll try that out and see if it meets my needs! :D Thanks!
Sign In or Register to comment.