Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

What's the stupidest thing you've tried to fix that wasn't broken?

edited July 2013 in General Posts: 15

First off, I want briefly express how much I love Codea and most of all the forums. I've been mostly a lurker because I love to learn without actually coming out and asking for what it is I need to know (I'd rather understand the problem better through reading on the forums then code the answer myself, than just copy code that will solve the problem for me).

Anyway, I thought it would be fun and informative to find out, well, what I asked in the title. A sub-question of that would also be "What's the longest you've worked on fixing something that was actually working perfectly?"

I thought of this when I worked for 30 frustrating and confusing minutes the other night trying to use sin and cosine to move a screen object along a certain angle, only to realize that my code said something like:

x = cos(angle) * hypotenuse

...rather than:

x = x + cos(angle) * hypotenuse

My stupid dot was jumping on the screen to a seemingly random position and driving me batty.

More advanced stupidity is welcome and appreciated, as I think mistakes like these can really help others understand coding better (and feel less stupid themselves for making similar mistakes).

And a sincere thank you to everyone in the forums for all of the anonymous help in the past and going forward!

Comments

  • Jmv38Jmv38 Mod
    edited July 2013 Posts: 3,295

    My most frequent stupid mistake (with codea) is trying to fix myClass.myFunc() not working properly. And working on the code of myFunc.
    While the good syntax is myClass:myFunc()
    Probably 20 cummulated hours? Over 50 times? but it is ok now. I've learned my lesson.

  • Oh i did a lot of . Instead of : as well

  • Posts: 1,595

    most stupid thing I tried to fix was the algorithm to smooth out lines when it turned out worse than before so I had to rewrite it all over again, other than that its probably just missing obvious brackets and stuff

  • edited July 2013 Posts: 391

    Lol, that : has gotten me too. When I look at the reference and it shows the functions with periods, that makes me want to use the period instead of a colon. Then not realizing I am calling the function wrong I try to change my function instead, hehe.

  • Posts: 1,976

    : and . confused me at first when I was going from Java to Lua. :P

  • Posts: 398

    I tend to get in a muddle sometimes - as I code a fair bit in Python at work and then do a bit of Codea in the evening and often get my syntax and semantics mixed up. e.g. Lua tables start at index 1 - Python at 0.. Aaaaargh!

    There are far too many schoolboy errors of this ilk that have caused sleepless nights ;-)

  • Posts: 1,976

    I'm learning Java, Python, and Lua. Whenever I switch which one I'm using I always mix up syntax. In Java I forget semicolons, in Python I use Lua if statements, and in Lua I use Python if statements.

  • IgnatzIgnatz Mod
    Posts: 5,396

    : and .

    It really needs its own error message!

  • Posts: 2,042

    ':' vs '.' Has got to be the single most made mistake

  • I've only dabbled in coding in the past, though Codea has been something that lets me do it as much as I'd like to since it's so portable.

    That said, I have lots of friends who are "real" programmers (mostly at Google), and I honestly have no idea how you keep all of the different languages straight. It would be one thing if the differences were major, it would almost be easier, but as others have pointed out it seems to be minor differences that trip you up the most!

  • Posts: 2,820

    When I rename variables and Codea's search functions doesn't catch something is a common mistake for me. It's stupid, but common for me.

  • edited July 2013 Posts: 688

    It'd be pretty hard to detect : and . errors simply because they can both be used interchangeably.

    MyTable:myFunc(a) is simply syntactic sugar for MyTable.myFunc(MyTable,a)

    and the definition for MyTable:myFunc() can be written either as

    function MyTable:myFunc(a)

    or

    function MyTable.myFunc(self,a)

    In the first case the "self" parameter is implicit but regardless of which format you use both are correct and either calling method will work.

    That said - I've been caught out myself a few times as well, and as for the OP's original question, the most annoying bugs for me are mis-spelling a variable and not realising it's using a (new) global instead of the one I intended (damm - I hate dynamically typed languages on occasions! :) )

  • Posts: 2,161

    @TechDojo:

    MyTable:myFunc(a) is simply syntactic sugar for MyTable:myFunc(MyTable,a)

    I think you meant:

    MyTable:myFunc(a) is simply syntactic sugar for MyTable.myFunc(MyTable,a)

    !!

  • Posts: 688

    @Andrew_Stacey - yes I did, see how easy it is to mix up the two :))

    (fixed my previous entry)

  • Posts: 1,976

    I think I just accomplished by stupidest thing I tried to fix that wasn't broken... I was working n Expansion+, trying to get saving/loading worlds in but it kept giving me a nil error when I tried to use loadstring(). I made it print out the generated code, and found in tables it was saying (example) {, 1, 2, 3}. I went into the code for about a half an hour trying to figure out why it was having a , after the { when I specifically told it not to only to realize when the half hour was done that the world I was testing it on was before I had fixed it, and I had fixed it a long time ago. When I re-saved the world, and tried loading it no ,s appeared after {s.

  • Posts: 391

    The other day I made a bunch of stupid mistakes. I basically rewrote my mapGeneration function because NPCs weren't rendering correctly over certain objects. After hours of writing and rewriting the rendering code, I finally noticed that I didn't include the drawing of the NPCs in the translation of the map, so they were simply being drawn off the screen.

    Then, even after fixing this, I ran into another problem where I was clearing the NPC meshes in the wrong location, which caused me to rewrite some more code.

    After finding both the problems, I had to revert most of my code back to previous versions, lol.

  • Last night I was working on this thing I'm doing, where you flick a coin and it bounces off walls and other coins, etc. I wanted the coins to slightly rotate as they collided, but couldn't get the sprite to rotate in tandem with the physics body it was covering.

    I finally realized after about an hour that instead of using self.body.angle in my rotate() call I was just using self.angle. Dynamic variable typing to the "rescue"!

    THEN! Then I got it working but they were spinning like little tops on a surface that was supposed to simulate felt. I spent 20 minutes adjusting "angularDampening" before realizing I should have been adjusting "angularDamping"... then spent another 20 minutes before I realized that it, too, should have been "self.body.angularDamping".

    This weekend I'm going to convert all of the coins to texture-covered meshes (on physics bodies), because I'm just a glutton for punishment. At least I've already written the (working) code for the circular mesh and textures.

  • edited July 2013 Posts: 1,976

    self.body.angularDampening*

  • Posts: 502

    In codea I've wasted most time in creating a joint, which I didn't save a reference to, so it got garbeage collected. Really strange behaviour when the physics system just breaks down..

Sign In or Register to comment.