Windows Code sometimes works, sometimes doesn't

konkrz

Member
Has anyone else encountered issues with code sometimes working and sometimes not?

Personally I have seen it with instance_place_list and with for loops. I think it only happens in instant events (Create, Destroy etc) not in step/draw.

Thinking more about it, i think it is about variables sometimes not getting the values they are assigned in such events.

I'm on IDE v2.3.1.542 Runtime v2.3.1.409 (latest right now)
 

CloseRange

Member
once you realize that 99.99% of all bugs are the fault of the programmer you'll start to get better at programming.
and that .01% of the time there is always a work around.
 

Nidoking

Member
In almost every case, the code works 100% of the time, but what you've told it to do is to break in a strange fashion under certain circumstances. You need to figure out what those circumstances are, and that will lead you to what the problem actually is and how to fix it.
 

konkrz

Member
Sooo..."check your code for the thousandth time". Ok, got it, thank you.
( I do find the possibility of it being my mistake highly likely though I have checked in many different ways and made changes and revisions to no avail.
Just wanted to check if it was a somewhat common issue or something. Thanks for the replies everyone)
 
Last edited:

Nidoking

Member
Oh, it's absolutely common. There isn't a universal solution, however. The closest thing to a general method I know of is "use the debugger if you can, and if not, print debug messages for absolutely everything until you spot something wrong." Anything more specific than that would require knowing something about the problem, which at this point, only you do.
 

kburkhart84

Firehammer Games
Basic mistakes happen to all of us. The most common issue when you refer to variables not getting values you set(and why it feels more common in create events then step events) is simply mistyping names. The create event only happens once, while the step event happens every step, and so it seems like it happens more often there. The best way to get better at not mistyping names is to use your own system. Some people use snake_case. I like snakeCase, others like SnakeCase, its up to you. I prefer longer descriptive names as well, some people work fine with shorter names.

Another common mistake that makes it seem like create events fail, believe it or not, is to simply forget either to place the object instance in the room(after you spend a long time actually creating the object, its easy to forget this step). And in the same style, people forget to have the game actually go to the room in question. These are also ways to have all that you just wrote, simply not get executed. This is the kind of thing you can figure out once you add debug messages to places. My input system is FULL of debug messages(which are turned off easily by changing a macro), and this is the reason why. And when I used to make those types of mistakes more often then I do now, debug messages are what saved me from wasting too much time figuring out what's happening.
 

CloseRange

Member
check your code for the thousandth time
Trust me nobody claimed that programming was easy.
Every single one of us has been in a spot where we go through the code over and over and over again thinking everything should work perfectly. We can check hundreds of times to no avail until we get frustrated and quit for a few hours or a day.
Eventually we realize it was something dumb on our part like using a wrong variable, using + instead of - ect.
and we all feel stupid and smart at the same time afterwards.
 
Top