How do i check for multiple possible words from a variable?

Hi everyone, thanks for checking
How do i check for multiple possible words from a variable?

i have already made this drag n drop word shuffling game where player could shuffle each letter to form a word, im using “formedword” as player inputted variable and checks if the word is valid from “wordlist” variable

I already got it to work using strfind, but its only check for valid 4 letters word, for example if the player shuffled word “OLDC” i want it also detects “OLD” as valid word if they dont know the word COLD, but if they guessed right with words with more letters it checks that one, ignoring the fewer letter words.

english is not my first languange, sorry if there is any confusion

GDevelop_wtZIqAkT24

Hey rezsh, welcome!

This is a very simple way I could think of.

In my example, I added an array with the words [ate, rate, tear, tea]. The event loops through every word in the list and checks if it “contains” the guess (scrambled) word.

First the word “ate” will be matched, then if the length of a new match > previous match, then update the new matched word “rate”.

Just make sure to reset the matched word to " " after every guess.

thanks for taking your time answering insein! :wave:,

I’ve tried your solution and it works perfectly the way i want, however is it possible to do this with bigger words list?, im trying to add a whole dictionary, and adding 1000+ each word manually in the gdevelop array already sounds impossible.

this is what my method before, im using a structure variable with 3 wordlist, each contain approx 500+ words, i divided to 3, cause if i put more word on single variable the gdevelop app becomes unresponsive, idk if this an optimal method but it works.

(group is the letter gameobject, and the timer is for generating new shuffled words)

This only searches until it finds an exact match then stops.

I’m not sure why is that.

I tried a method with 2500 words and it worked fine for me.

  • Convert your list to JSON, there are plenty of online tools that can do this

  • Add the full JSON string to a string variable.

  • Convert the JSON string to an array using this event

Now you have all the words listed in an array and you can use the same event that I shard earlier.

Note: Variables are not resource heavy, they’re just stored information like any text, and GDevelop can store lots of them.

1 Like

it works like charm with my huge word list, thank you!! much appreciated

Glad I was able to help!