GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Strings: Partly Match

Hi,
I am trying to do a logo quiz style game ( I know, surprise ) but I struggle on how to check if the answer by the user partly matches the expected answer, instead of only true false.

I worked on GS a couple of years ago, but since a lot of additions have been made (ex. tables).
So I would be happy if someone could advise me on the right way to go to check for this.

Thx !

BTW: Is it possible by now to compare two strings (like user input vs. table cell) against each other ?
Or only game.StringText = "String" ?

Comments

  • ElfizmElfizm Posts: 489Member
    Hi

    This is how I did mine a while back.

    Have a game.attribute that the users text is saved to called players word.

    Have another attribute called answer.


    Then using a rule on a "check answer" actor:

    If game.players word is "correct answer"
    Change game.answer to 1.

    Then to have partly match, have a rule that says when game.players word contains "similar or misspelled words"

    (this is where you put in a rule for each word you think would be close to the word you have chosen and set the rule to any)

    For example if your correct word is house.

    You would have a separate rule for houes, houses ect.

    If the any of the above is true change it game.answer to 2.

    This is placed in the otherwise section of your first rule.

    Then in the otherwise section of previous rule have it change game.answer to 3


    This way:
    1 is equal to correct answer
    2 is equal to almost correct answer
    3 is equal to wrong answer.

    This gives you option to have actions such as text goes red if wrong or orange ect.

    Hope that helps.

    Cheers
    Elfizm
  • TheTTheT Posts: 80Member
    thanks, that's also a quite good way, but I was more looking for something like check first character = first right character, check 2nd character =?
  • ElfizmElfizm Posts: 489Member
    Well from the top of my head, if your using a custom keyboard one you made your self you can save each letter to an attribute and then compare that with the correct letter from a different attribute.

    Just an idea.Or I can explain more
  • tatiangtatiang Posts: 11,790Member, Sous Chef, PRO, Senior Sous-Chef
    @Elfizm is right. With a custom keyboard, you can manipulate individual letters. You would need to have each letter of the correct answer in a column of a table row. So if the first answer is LEGO and the second answer is SONY, your table would look like this:

    ___1_2_3_4
    1...L_E_G_O
    2...S_O_N_Y

    If you need to keep track of how long each answer is. I'd add a column in front of the answers:

    ___1_2_3_4_5
    1...4_L_E_G_O
    2...4_S_O_N_Y

    And then you'd compare When game.KeyPressed is tableCellValue(tableName,game.AnswerNumber,2) ... [first letter is correct!]

    And increment game.KeyNumber by one each time a custom key is pressed. That way, you know that the second key press is the second letter of the guess. And you'd check to see if game.KeyPressed is tableCellValue(tableName,game.AnswerNumber,game.KeyNumber+1) if column 1 has the word length. Otherwise, you'd check tableCellValue(tableName,game.AnswerNumber,game.KeyNumber).

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

  • ElfizmElfizm Posts: 489Member
    @tatiang as provide an example using tables which I have limited know how of.

    But the way I was think off was with out tables. If the word is LEGO

    And assuming you limit your amount of letters input to ten. That would mean ten attributes labelled one to ten. So when the player types for example LOGO, you can compare each letter with another set of correct letter attributes. Then check and it could say that you have 75% correct.

    I don't know how it tables work with this but I figured this could provide some freedom with checking ect
  • tatiangtatiang Posts: 11,790Member, Sous Chef, PRO, Senior Sous-Chef
    @Elfizm the problem with that is if you have one answer word, you need ten (or in this case, four) attributes, one for each letter. If you have 100 answer words, you need hundreds of attributes.

    Tables are much, much easier. By the way, a table is just another word for a spreadsheet. Manipulating tables in GameSalad is not terribly difficult as there are a limited number of things you can do with them, but they are very powerful.

    You can import a spreadsheet (.csv file) with the answers all entered in columns and then GameSalad can read the data from that table.

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

  • ElfizmElfizm Posts: 489Member
    @tatiang good point, I did have a work around if such a question arisen but given the fact tables are way cooler and easier I will just keep it to myself.

    I am currently learning adance functions with tables in regards to my current projected so I don't feel confident to give recommend adivce about tables. So @TheT use tables :)

    But for the fun of it here is my solution, using a table :D

    Still have the ten attributes or how many ect. The ones that display the correct get thier letter from the table. So row 1 column 1 is equal to L. Row 1 column 2 is equal to E and so on.

    Have a game.attribute that has a number in relation to the word needed to be correct. So Lego is represented as 20 for example. Then on the correct letters attribute they can change to the table(row(game.attribute) ect.

    This way you can still compare each letter ect.

    But having it all in tables may seem easier and more effiectent but I am still unsure what capabilities lay in tables and referencing and comparing ect

    But thanks for teaching :) learning new skill
  • tatiangtatiang Posts: 11,790Member, Sous Chef, PRO, Senior Sous-Chef
    Here's a demo that can easily be adapted for as many answer words as you care to enter.

    Obviously, I've added a limited number of letter buttons, but you get the idea.

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

This discussion has been closed.