v4.5.1.stable.official [f62fdbde1] Arch based CachyOS Linux distro x86_64
Question
Hi,
Working now on Beta 1 of “LettersFall 110%” educational word spelling game using Godot v4.5.1.
The below source code fails to finish on Web HTML5, but on Linux x86_64 it finishes in about 2 seconds?
How would I fix the loading of the American English word dictionary on Web HTML5 version?
WordDictionary.resize(500000)
var endOfFile = false
var file = FileAccess.open(“res://media/Dictionary/words.txt”, FileAccess.READ)
var index = 0
while (endOfFile == false):
WordDictionary[index] = file.get_line()
if (file.eof_reached() == true):
endOfFile = true
else:
EndOfWordsFile+=1
index+=1`
Any help would be appreciated, very close to Beta 1…
You can press F12 in the browser to open the developer console, it seems to load the file okay so I’d guess somehow you have an infinite loop. You could see print statement appear in this console if you add them into the code.
In my own tests I can load in 370,107 words on web about as fast as it loads on desktop. 500,000 words really isn’t that much to a computer, and you’ve already optimized a by resizing the array before use.
This is the code I used.
func loadWords() -> void:
var file = FileAccess.open("res://a_combined_list.txt", FileAccess.READ)
assert(file != null, "Failed to open word list")
words_array.resize(500_000)
var idx := 0
while not file.eof_reached():
words_array[idx] = file.get_line()
idx += 1
var success := words_array.resize(idx+1)
assert(success == OK, "Failed to resize by trim")
Add some print statements, show more of your code.