Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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_find_close();

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)));
    file_text_writeln(file);

}
file_text_close(file);

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

1 Answer 1

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
6  
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
1  
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

Your Answer

 
discard

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.