Community

General and Everything Else => The Games and other Sierra Adventure stuff => Topic started by: claudehuggins on September 23, 2016, 11:27:24 AM

Title: (Just for fun) Why sleep is important when programming
Post by: claudehuggins on September 23, 2016, 11:27:24 AM
I decided it would be a good idea to stay up late last night to program one of the games I've been working on. Turns out, unsurprisingly, that's not a good idea at all.
I found my code riddled with stupid mistakes. I spent all morning fixing it. I figured it might be entertaining to show off some of these mistakes as an example of just how tired I really was.
This isn't really a "guide" or "what not to do" so much as a humorous (at least to me) look into the facepalm-inducing errors that come pre-packaged with an interest in programming.

Code: [Select]
; On an unrelated note, I'm coding this at night. Who in the world codes at night? I don't even like being on the computer in the dark. My eyes hurt and I want to go to bed.

; It's morning now. I'm reading this again. I made so many mistakes it's not even funny. Ay yi yi. Don't code at night, kids. Or when you're tired at all, really.

(method (handleEvent pEvent)
(super handleEvent: pEvent)
;
;         * Handle the possible said phrases here *
(if (Said 'look>')
(if (Said '/sign<gold,front,desk') (Print 2 12))  ; To my embarrassment, I had forgotten the word separator on all of these. Also, for some reason, I hadn't changed "front" to count as a qualifying adjective.
(if (Said '/sign<bin') (Print 2 2))  ; I flat-out wrote and coded a response for looking at a sign that does not exist. There is no sign on the sale bin. On another note, I probably could have coded this entire sign section more gracefully if I had actually been thinking about what I was doing.
(if (Said '/sign<door') (Print 2 3))
(if (Said '/sign') (Print 2 0))
(if (Said '/door') (Print 2 4))
(if (Said '/desk') (Print 2 5))
(if (Said '/bin')
(if (& (gEgo onControl:) ctlTEAL)
(Print 2 6)

else (Print 2 13)  ; For some reason, I had referenced a text resource here that does not exist.
)
)
(if (Said '[/around]') (Print 2 9))
)
(if (Said 'dance[/desk]') (Print 2 11))  ; The word separator here was outside the brackets, for some reason. This meant that only "dance desk" would work, and not "dance", which was the point of the brackets in the first place.
(if (Said 'open/door')
(if (& (gEgo onControl:) ctlGREEN)
;(gRoom newRoom: 3) FORGET THIS I'M NOT CODING RM003 TONIGHT LET ME SLEEP NOW BYE
else (Print 2 14)
)  ; This close parenthesis was the bane of my existence when trying to figure out where my code went wrong this morning. It was one line too high, meaning any input from the user whatsoever triggered this print statement, unless it was the engine parsing the phrase "open door".
)
Title: Re: (Just for fun) Why sleep is important when programming
Post by: Cloudee1 on September 23, 2016, 11:41:43 AM
Also, your if statements don't seem to close before the else statement is called

Does this actually work?
(if
 else
)

*Ah wait, I see by the comments you are using sierra syntax... which I have barely looked at, so it may very well work... nevermind
Title: Re: (Just for fun) Why sleep is important when programming
Post by: troflip on September 23, 2016, 12:25:54 PM
I generally like to use cond statements for things like your look statements. e.g:

Code: [Select]
(cond (Said 'look>')
    ((Said '/sign<gold,front,desk')
         (Print 2 12)
    )
    ((Said '/blahblah')
         (Print 2 13)
    )
)


fwiw, I code best at night
Title: Re: (Just for fun) Why sleep is important when programming
Post by: lance.ewing on September 23, 2016, 03:07:05 PM
I think I'm fine with the coding after midnight; the code itself seems to turn out fine. It's the other decisions outside of coding that don't turn out too well, such as at 2 am thinking "I'm sooooo tired... Let's just submit this thing now without testing it on anyone else's machine, or any other browser, even though I've still got 10 hours before the deadline."

Regretting it now, but at the time I really wanted to sleep.