• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Silly reasons your code didnt work.

Gamebot

Member
I was creating a playfair cipher in GM and I figured why not use this to my advantage to create other useful scripts such as moving rows, columns, and even translating one row and one column.

I was able to figure out the code myself...until it came to run time when all but my translate code didnt work.

It didnt take me long to figure out I was running the wrong script since I copied and pasted in the step event. :mad:

Thought I had checked my code carfully. Apparently , not.

I know we all have done something like this at least once. Just curious what others have experienced.
 
"At least once"? Ha ha, you're funny. Not counting all the times I misspelled one word, switched the greater than or less than symbols, or forgot to initialize a variable, here's all sorts of crazy silly things I've done. (Multiple times):

- Switch the x and y coordinates (in a grid lookup or draw function, or whatever). Often leads to issues that don't throw errors, and code that looks perfectly correct with a quick glance.
- Forget to actually place the instance I was programming into the room in the first place. So I end up thinking it's just not doing anything.
- Forget that a ds_grid width and height includes 0, so I create a grid one space too small, or assign a value out of the bounds of the grid.
 
One time I was pulling hairs out at the sandboxed file system, trying to import 3d model data. It wasn't finding the files, so I tried to use file_copy to copy them to the working directory, and used file_delete to remove the copies after it had imported the data. I ran the code, and it didn't work because the file system was still sandboxed. Then I had a brilliant idea! Remove the file copy call, and put the files I wanted to load in the working_directory. I cut them from the other folder, put them there, ran the code and... It didn't find them, because it deleted the files. Worst thing about it is they were the only copy of the files I had.

That's probably the stupidest coding error I've ever made. I'm just glad I don't make software for banks hehe.
 
Z

zendraw

Guest
im sure i can find some silly topics here where the problem was obvious but i was so fatigued i was blind to them..
 

kburkhart84

Firehammer Games
In Gamemaker I've coded an object all nice and pretty, couldn't figure out why it wasn't doing anything.......forgot to actually add an object instance to the room.

For you guys that use Unity, I've done similar there too, coded a script....forgot to add it to the object, wondering why it wasn't doing anything.
 
M

MishMash

Guest
Had a brutal bug today. Using a bit of floating point math to calculate an array index. The value displayed came out as 8001.00 after flooring (original value perhaps 8001.2), however when passed into the array index, value 8000 was returned instead :S! The reason being, there was no pure floating point representation of 8001.00 given the floating point inaccuracy, so instead, value 8000.9999999997.. was used instead. Subsequently, when this was converted to an int, it got rounded down to 8000 due to how that operation works.

Fixing this was a bit of a pain, and inconsistent between YYC and Windows VM (due to a bug in int64(..) which has now apparently been fixed). In the VM, just wrapping int64 around the value instead of flooring it worked, however in YYC, it appeared to still be flooring the value (in float form) first before converting, so even passing in 8001.90 returned 8000.
Luckily, a simple, but not so elegant fix was just to dump the float value straight into the array as 8001.2 which meant it instantly got converted to an int, so it never got floored in floating point form.

This bug took me all day to find, and the side effects of it were quite funny, because the array stored list indices, in the empty cells, they still had 0 and so list with index 0 was used which was a random other list to do with the soundtrack manager. The end result was the game crashing because "ost_SnowNight" was being written to the game world grid rather than a block index haha :p
 

Rob

Member
Spent freckin weeks off and on trying to fix a bug. My code was referencing an array and after an ini file save/load it didn't work.

I had debug information on screen to show me the values in the array, and they matched up to what they should be so I was really scratching my head for ages.

Rewrote entire sections of code, messed around in every nook and cranny...

Finally I discovered (or should I say, realised) that I was saving the whole array as real numbers/integers and reloading them as the same, when in fact some values were strings.

I was dumb because I initialised the whole array as -1's upon creation and didn't take into count the fact that I was using some values as strings and that led to my future failure.

The values that were being shown to me were the correct values but weren't the correct TYPE - a real "doh!" moment. My code was checking for a string and I'd saved/reloaded it as a real number.

The whole thing stalled my development for ages.
 
Last edited:

Neptune

Member
Spend a couple hours writing a large script, and then forget to call the damn thing...
grid[# y,x] is always fun...

aaand var my_0_width_grid = ds_grid_create[0,30];
 
Last edited:
One of the worst ones I've ever encountered:

You'll notice that at the top of a script window (in GMS1.4) there are three radio buttons that say Applies To: Self, Other, Object.

I've never purposefully used those radio buttons for anything, but on at least two occasions I must have accidentally changed the settings. It took SO long to figure out what had gone wrong.
 
Last edited:
B

Binary Orange Studios

Guest
One of the worst ones I've ever encountered:

You'll notice that at the top of a script window there are three radio buttons that say Applies To: Self, Other, Object.

I've never purposefully used those radio buttons for anything, but on at least two occations I must have accidentally changed the settings. It took SO long to figure out what had gone wrong.
In GMS 1? That was a very common pitfall of mine as well! I don't seem to see those options in GMS 2, unless they buried them because they knew people didn't really use them too much.
 
G

Guest User

Guest
Not GML but PHP
Code:
if(strlen(htmlspecialchars($_POST['message'])) > 256 && strlen(htmlspecialchars($_POST['message'])) < 2) {
    return true;
} else {
    return false;
}
I hope you take a moment to admire the messed up logic...
 
G

Guest User

Guest
tbh i find that typos and not actually putting the object in the room are the source of probably like 96% of my errors.

but another stupid one that gets me a lot is...not actually remembering to finish the feature. e.g. writing the inventory system but forgetting to do one part of the code such as the part that actually calls the inventory up, or gets rid of it, or changes the cursor position.
 
How about this:

https://forum.yoyogames.com/index.php?threads/solved-instances-not-drawing.45921/

- In GMS 2, thinking I found a drawing bug, where instances were not drawing at depths of >= 100.

- Spending over an hour creating an elaborate demo within GMS 2 to highlight the issue, complete with debug keys, instructions, and reproduction steps.

- Creating a new thread just to highlight the aforementioned bug.

- Feeling very proud of myself for being very thorough in preparing to submit a bug report.

>>> Finding out that the instances couldn't be seen due to the default black background layer in a new room (which defaults to layer 100) was hiding them <<<

:confused::confused::confused::confused::confused:
 
A

AnonyMouse

Guest
That depth "problem" happened to me also :)
Today I revealed a nasty bug:
instead of
Code:
alarm[0] = ceil(62) + text.mesta/2
it was:
Code:
alarm[0] = (ceil(62+text.mesta))/2
:eek::oops::confused:
 
Last edited by a moderator:

Gamebot

Member
My computer was not turned on....
Did you find the "On" switch?
Make sure it's plugged in too!


- In GMS 2, thinking I found a drawing bug, where instances were not drawing at depths of >= 100.
Iv'e done that too. You think you get your depths right then realize there backwards. (Subtracting instead of adding / Adding instead of subtracting)


Today I revealed a nasty bug:
instead of
Code:
alarm[0] = ceil(62) + text.mesta/2
it was:
Code:
alarm[0] = (ceil(62+text.mesta))/2
IN:

Code:
 // If mouse is over grid get array[x, y] as array coordinates. (ie. 0,0 or 5,2)
 xx = ceil((mouse_x - sprite_width)/sprite_width) - (ceil(x - sprite_width)/sprite_width) - 1;
 yy = ceil((mouse_y - sprite_height)/sprite_height) - (ceil(y - sprite_height)/sprite_height) - 1;
I accidentally added the X but DID subtract the Y in the original code. Somehow I wasn't quite getting the grid numbers like I thought I would. The odd part is I've programmed this ceiling formula many times without a hitch.


Spend a couple hours writing a large script, and then forget to call the damn thing...
grid[# y,x] is always fun...
Just call it out it in your head like calling a dog...here script, script, script such a good script.
See the idea is so crazy it's stuck in your head forever. Now you won't forget...maybe.
 
Last edited:
Top