Author Topic: How would you guys feel about a gamemode that uses BlocklandLua?  (Read 701 times)

I'm wanting to try my hand at a Scrabble gamemode, so of course you need a dictionary of words.
That would be a lot of words. /usr/share/dict for example (on linux systems) has ~250k words, some uploaded databases have even more.

I don't expect TorqueScript to be able to handle it that well (looping through a file that would inevitably create 250k+ variables), but I know Lua can handle it fine as per my own tests (the corpus on that bot currently contains about 50,000 lines on my end, initially loads all lines in about a half second, adding is instant).

I'd like to release this, but I know the community probably doesn't feel great about a DLL injection being required.

what would be used: https://github.com/portify/BlocklandLua

Technically, a somewhat feasible, but still quite an inefficient way of doing it would be make a text file, which would be empty, but named after the word. You can do an isFile check. To make the file explorer not lag his ass off when opening the folder, you could separate the words into folders by starting letter, then another named after a number that represents the number of characters in the word.

No parsing is necessary to load a dictionary file, so just make a simple test function like this:

function test()
{
   %start = getRealTime();

   %a = new FileObject();
   %a.openForRead("config/dictionary.txt");

   while(!%a.isEOF()) {
      $IsWord[%a.readLine()] = true;
   }

   %a.delete();

   echo(getRealTime() - %start);
}


Took 0.2 seconds to load 350000 words from a 3MB file. There's no need to use lua for this.

Then you can easily query it like this:


No parsing is necessary to load a dictionary file, so just make a simple test function like this:

function test()
{
   %start = getRealTime();

   %a = new FileObject();
   %a.openForRead("config/dictionary.txt");

   while(!%a.isEOF()) {
      $IsWord[%a.readLine()] = true;
   }

   %a.delete();

   echo(getRealTime() - %start);
}


Took 0.2 seconds to load 350000 words from a 3MB file. There's no need to use lua for this.

Then you can easily query it like this:

That's what I was initially going to do, but wouldn't that eat through memory?

Not much more than the size of the words themselves. Global variable arrays are actually a pretty reasonable data structure in ts.