Strings: Partly Match
TheT
Member Posts: 80
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" ?
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
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
Just an idea.Or I can explain more
___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
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
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
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
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
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