J
James Manning
Guest
I'm new to GML and GMS so please forgive my basic knowledge (first proper attempt at a good game)
I have a set of files all containing words separated by word length in the included files.
How can I create a script that can allow for them to be added as they are needed for the array?
So far I have:
This code is run at the creation of the first room and shoots out this error.
I'm open to suggestions on how to do this another way (whether that be just using 1 file with sections or anything, I just thought this would be more efficient since it only calls the file when it needs it.
I have a set of files all containing words separated by word length in the included files.
I want to load them 1 by 1 into a 2d array called words [ letters in the word , word ].eg. Words with 4 letters are all stored in a file called 4.txt
How can I create a script that can allow for them to be added as they are needed for the array?
So far I have:
Code:
//scrLoadWordFile(MaxWordLength)
maxlength = argument0; //Gets the word length desired
if (maxlength > 21) or (maxlength = 24) // I have files for 1-21 and then another for a 24 letter word
var filename = "/" + maxlength + ".txt";
{
wordsfile = file_text_open_read(working_directory + filename); //Open the word file
var num = 0;
while (!file_text_eoln(file)) //Read until end of file
{
game.words[maxlength-1,num] = file_text_read_string(wordsfile); //Read word into array
file_text_readln(wordsfile); //next line
num++; //increment num up to put word into next cell
}
file_text_close(wordsfile); //Close the word file
}
ERROR!!! :: ############################################################################################
FATAL ERROR in
action number 1
of PreCreate Event
for object guiCounter:
DoAdd :: Execution Error
at gml_Script_scrLoadWordFile (line 6) - filename = "/" + maxlength + ".txt";
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scrLoadWordFile (line 6)
called from - gml_Room_room0_Create (line 2) - scrLoadWordFile(game.max_word_length);
FATAL ERROR in
action number 1
of PreCreate Event
for object guiCounter:
DoAdd :: Execution Error
at gml_Script_scrLoadWordFile (line 6) - filename = "/" + maxlength + ".txt";
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Script_scrLoadWordFile (line 6)
called from - gml_Room_room0_Create (line 2) - scrLoadWordFile(game.max_word_length);
I'm open to suggestions on how to do this another way (whether that be just using 1 file with sections or anything, I just thought this would be more efficient since it only calls the file when it needs it.