29 October 2011

Facepalm Programming

I spent over six hours of my life on Thursday trying to modify one of the older utility scripts.  I was initially pleased when I activated the script and saw the expected result, but I then grew perplexed when (upon further testing) saw variations in the results.  Some results were just plain wrong, and other conditions had no results at all.

I laced the script with multiple lines of diagnostic code, and ran it again.  And again.  I was not annoyed so much in that the script was not working as I was with the seemingly randomness of the results: I could not predict the result nor could I see the pattern within what was happening.  What the heck was going on with my beautiful script!  At no time did I dread "I broke the script," as my additional code was working perfectly: it was the original code that appeared to be misbehaving.  There was something larger happening that I was not seeing.

I turned to researching other scripts that had similar functionality.  What were their scripts doing that mine was not doing?  I could not see any differences, and my eyes began to tire from all of the reading.  I was about to end my debugging session when I had a sudden realization; within the World Editor Tool there are some "script check boxes" (for want of a better description) which basically set behavior preferences for a script's interaction with the world.  Did I have my check boxes checked?

Nope.  I had left one check box unchecked.  And after checking it, my script worked perfectly and predictably.

Oh brother.

3 comments:

  1. So sorry to hear that you ran into problems, but I do admire your dedication. 6 hours is a long time to work on a Clan Lord script and we're lucky to have you working for us.

    ReplyDelete
  2. I think the title should be "Facepalm Debugging." I remember I spent at least a few hours once trying to get something to run properly with no proper debugger only to find I was missing 1 character in 1 script that I had glanced at without actually reading character by character… So, I know exactly how you felt.

    ReplyDelete
  3. That reminds me an epic debugging session. The more I was adding comments and debug info, the less the bug was happening. And it was already random to begin with. Found out that it was in fact a timing issue, adding additional debug steps was slowing the software enough that it didn't run in to the bug. The solution was to actually move one line up (or more exactly to move one instruction down so that it happened at the proper time all the time). Took the most part of a night to find out though :P Frustrating but then happy to finally achieve the expected result ;)

    ReplyDelete