So, since the two examples you gave were movies, I cooked up something quicklyâŠ
The javascript you need is the following:
var myWord = runtimeScene.getVariables().get("Word").getAsString();
var myWordC1 = runtimeScene.getVariables().get("WordC1");
var myWordC2 = runtimeScene.getVariables().get("WordC2");
var myWordC3 = runtimeScene.getVariables().get("WordC3");
var myWordCN = runtimeScene.getVariables().get("WordCN");
var myLex = ["La La Land","Lady Macbeth","The Handmaiden","Blade Runner 2049","Call Me By Your Name","Get Out","LadyBird","Mother!","The Shape of Water","Three Billboards Outside Ebbing, Missouri","Black Panther","Phantom Thread","The Greatest Showman","Crazy Rich Asians","Capernaum","A Star is Born","Avengers: Infinity War","Roma","Hereditary","The Favourite","Sorry to Bother You","Vice","BlacKkKlansman","Avengers: Endgame","Portrait of a Lady on Fire","For Sama","Booksmart","Once Upon a Time in Hollywood","The Farewell","Joker","Parasite","Monos","Little Women","The Lighthouse","Toy Story 4","Lamerica","The Vast Of Night","The Assistant","Rocks","Saint Maud","Tenet","Ma Raineyâs Black Bottom","Soul","Never Rarely Sometimes Always","Lovers Rock","Nomadland"];
var match = myLex.filter((str)=>{
return str.toLowerCase().indexOf(myWord.toLowerCase()) >= 0;
});
var lends = match.length;
var myWordCr1 = match[0];
var myWordCr2 = match[1];
var myWordCr3 = match[2];
myWordCN.setNumber(lends);
myWordC1.setString(myWordCr1);
myWordC2.setString(myWordCr2);
myWordC3.setString(myWordCr3);
So, what it does is this:
First it takes the scene variables âWordâ (which is the word we are typing), âWordC1â (the 1st possible match), âWordC2â (the 2nd possible match), âWordC3â (the 3rd possible match) and âWordCNâ (the number of matches)
Then you have the array (myLeX) in my case, with the elements (movie titles)
Then it creates the variable âmatchâ that is essentially an array with all the elements of âmyLexâ that match the variable âWordâ
Then it creates the variable âlendsâ which is the number of elements in the array âmatchâ
Then we set the first 3 elements of âmatchâ to the possible matches.
That is about as simple as I can explain it, but you can download the project here and see it for yourselfâŠ
https://drive.google.com/file/d/18dQO7w8DlpCRWCL4YnILes1IRrtvKszm/view?usp=sharing
Hope that helpsâŠ