Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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. – Jonathan Connell Oct 13 '12 at 13:24
"problem was solved by closing Game maker, going to sleep, then opening it again" This kind of problems is a poor fit for SE – Kromster Sep 4 '14 at 5:37
This question seems unanswerable because the bug it asks about can no longer be reproduced. – Anko Sep 4 '14 at 20:37

Not really a good answer, but my non-loading objects problem was solved by closing Game maker, going to sleep, then opening it again. So hopefully it doesn't come back.

share|improve this answer
You should always try to find the root cause of your bugs, because they can and will come back to haunt you. ;) – knight666 Jun 15 '12 at 12:06
And that includes if the root cause was a bug in GameMaker; don't just assume that, you want to check and know that. – jhocking Jun 10 '13 at 17:05
It Will Come back, Murphy's Law ;) – HgMerk Jun 3 '15 at 17:12

A few things I would check, Maximum line size. Maximum String size.

Try to reproduce the bug by staying in a room without completing it for something like 30 minutes.. while moving around alot. This should give you big strings.

I dont know what language this is written in. But you dont seem to be declaring file_count = 4;, is It a number? or what? Anyhow this probably isnt the problem.

for(i = 0; i < ds_list_size(keyCodes); i += 1) <- Why not i++?

About the randomly skipped files. You dont check if the ds_list_size is empty, if it is, you wont write anything in the file. You could have a case for it to write "NO DATA" or something :P

Anyhow.. Good luck :)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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