[SOLVED] How i can search word from another file?

Hello,

image
I have wordlist.txt which contains approx. 70000 words list…

How i can access and search specific word from worldlist.txt? :thinking:

It would be great if anyone can help…
Thanks in advance…

  1. if you mean by code editor: ctrl + f
  2. if you mean by script you need to get the asset, then get the contents and use contents.split("\n")[contents.split("\n").indexOf(myWord)]
    Since its like 70k Lines of code it may be slow :eyes:
2 Likes

@Fus_ion Thank you very much for HELP! :smiley:

I can understand it… I will do something about it… :thinking:

Here i am posting sample code…

var WordListManagerScript = pc.createScript('wordListManagerScript');

WordListManagerScript.attributes.add('wordListText', {type: 'asset',assetType: 'text'});

// initialize code called once per entity
WordListManagerScript.prototype.initialize = function() {
    
    console.log(this.wordListText);
    console.log(this.wordListText._resources[0]);
    
    var fileData = this.wordListText._resources[0];
    
    var wordByIndexNumber = fileData.split("\n")[9339]; 
    var indexNumberByWord = fileData.split("\n").indexOf("bus");
    
    console.log(wordByIndexNumber);            // Output - bus
    console.log(indexNumberByWord);            // Output - 9339
};

// update code called every frame
WordListManagerScript.prototype.update = function(dt) {
    
};

So attached wordlist
image

Works Great for me! :smiley:
Thanks!

1 Like