So, here's a run-down of what's going on:
I'm trying to make a program as sort of a random cryptogram decoder. At this point it is very unspecific and does not work very well, but I have come to a particular bump in the road.
On pressing the Enter key the program will write 26 different "options" (which are individual strings) to a specific file. This seems to work without error.
However, on pressing the space key, the program is to copy each "option" in the file to a particular array of a variable, generate 26 more, non-matching options, and add them to the text file.
When I press the Enter key, enter my text to encode/decode, and then press the space key, an error message stating that, in the <Space> Key Pressed event for object1, the file is not open for reading. It does not give a particular line of code where the error occurs, it just states exactly that. Then, when I click Abort, the game crashes instead of closing and returning to the game editor.
Here's the code for the Space Key Pressed event, and sorry about my bad, confusing scripting habits. I tend to use single letters often:
file0=file_text_open_read("words.gmdc");
h=0;
do
{
fs[g]=file_text_read_string(file0);
file_text_readln(file0);
h+=1;
}
until file_text_eof(file0)=true
file_text_close(file0);//Program adds the words in the text file into its currently running instance
file1=file_text_open_append("words.gmdc");
ii=0;
for (ii=0; ii=26; if permis=true ii+=1)//I do not even know if I can do that "if permis=true" thing
{
permis=false;//Code set to not allow another iteration
code1="abcdefghijklmnopqrstuvwxyz";//Used to compare scrambled letter sequence to
code2="abcdefghijklmnopqrstuvwxyz";//Used to scramble letter sequence
letter[0]="";
i=0;
repeat(26) {
foo=irandom_range(1,26-i);
letter[i]=string_char_at(code2,foo);
code2=string_delete(code2,foo,1);
i+=1;
}//Scrambles each letter into an array (There was probably an easier way to do this. Oh well.)
i=0;
code3="";
repeat(26) {
code3=code3+letter[i];
i+=1;
}//Puts scrambled letters into one string
i=0;
repeat(len) {
if string_letters(string_copy(str,i+1,1))=""
ch[i]=string_copy(str,i+1,1);
else
ch[i]=string_copy(code3,string_pos(string_copy(str,i+1,1),code1),1);
i+=1;
}//Replaces each letter in the string which the user provided with the corresponding letter in the jumbled sequence
i=0;
str2[ii]="";
repeat(len) {
str2[ii]=str2[ii]+ch[i];
i+=1;
}//Puts the new letters together into one string
l=0;
j=0;
repeat(g) {
if str2[ii]!=fs[l]
j+=1;
}//Checks to see if the new string matches any of the old ones
if j=0
break;//Makes sure there are still options
if j=g {
permis=true;
file_text_write_string(file1,str2[ii]);
g+=1;
}//If the string is new, it should add it to the file and allow the loop to iterate
}
file_text_close(file1)It would be very helpful if somebody could tell me what is wrong with this script for what I am trying to do, or at least confirm that this is a bug in GameMaker. I can provide more source code from the other events if necessary. Thanks!



Find content
Male





