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.
; 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".
)