Update: Turns out it's not an issue with this code (or at least not entirely). Somehow the objects I use for keylogging and player automation (basic ai that plays the game) are being 'skipped' or not loaded about half the time. These are invisible objects in a room that have basic effects such are simulating button presses, or logging them.

I don't know how to better explain this problem without putting up all my code, so unless someone has heard of this issue I guess I'll be banging my head against the desk for a bit /Update

I've been continuing work on modifying Spelunky, but I've run into a pretty major issue with GameMaker, which I hope is me just doing something wrong.

I have the code below, which is supposed to write log files named sequentially. It's placed in a End Room event such that when a player finishes a level, it'll write all their keypress's to file. The problem is that it randomly skips files, and when it reaches about 30 logs it stops creating any new files.

var file_name;
file_count = 4;
file_name = file_find_first("logs/*.txt", 0);
while (file_name != "") {
    file_count += 1;
    file_name = file_find_next();

file = file_text_open_write("logs/log" + string(file_count) + ".txt");
for(i = 0; i < ds_list_size(keyCodes); i += 1)

    file_text_write_string(file, string(ds_list_find_value(keyCodes, i)));
    file_text_write_string(file, " ");
    file_text_write_string(file, string(ds_list_find_value(keyTimes, i)));


My best guess is that the first counting loop is taking too long and the whole thing is getting dropped?

Also, if anyone can tell me of a better way to have sequentially numbered log files that would also be great. Log files have to continue counting over multiple start/stops of the game.

  • \$\begingroup\$ It may be an inherent problem with the fact that your code is executed on the End Room event, you may want to try executing your code before the end room event, and triggering the room change once your code has finished executing. \$\endgroup\$ – Jonathan Connell Oct 13 '12 at 13:24
  • \$\begingroup\$ "problem was solved by closing Game maker, going to sleep, then opening it again" This kind of problems is a poor fit for SE \$\endgroup\$ – Kromster Sep 4 '14 at 5:37
  • 5
    \$\begingroup\$ This question seems unanswerable because the bug it asks about can no longer be reproduced. \$\endgroup\$ – Anko Sep 4 '14 at 20:37

Though I am unsure why, my non-loading objects problem was solved by closing Game Maker, going to sleep, then opening it again.

Hopefully, it doesn't come back.

  • 8
    \$\begingroup\$ You should always try to find the root cause of your bugs, because they can and will come back to haunt you. ;) \$\endgroup\$ – knight666 Jun 15 '12 at 12:06
  • 2
    \$\begingroup\$ And that includes if the root cause was a bug in GameMaker; don't just assume that, you want to check and know that. \$\endgroup\$ – jhocking Jun 10 '13 at 17:05
  • \$\begingroup\$ It Will Come back, Murphy's Law ;) \$\endgroup\$ – HgMerk Jun 3 '15 at 17:12
  • \$\begingroup\$ While the other comments are right, I have been told countless times by professionals that sometimes the system just bugs out, and with uncertainty of how or when. In these cases,a simple "turn it off, turn it on again" solution is the best I've ever got. \$\endgroup\$ – Gnemlock Dec 28 '16 at 0:17
  • \$\begingroup\$ Note I'm also removing the initial comment. It would be helpful if we knew why it was happening, but if it solved your problem, its certainly good enough. You should accept this answer, so others know it worked. \$\endgroup\$ – Gnemlock Dec 28 '16 at 0:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.