Tuesday, April 1, 2014

Dev Log: Horror Text Adventure #45

I previously had not taken into account the possibility of more than one of the same type of object in a room, so I've been working on making adjustments to the code so if there are two chalkboards, for instance, you can draw and erase on both of them.  Right now it only picks the first in the list, and once it's full, you can't draw anymore or choose the other chalkboard to draw on.

To make that work, first came a little restructuring to recognize that there may be more than one object in the room of a given type.  So I switched a few single item variables into arrays to detect for erasable items, so more than one erasable item could be erased, instead of just the first.  Doing this was handy because it actually removed the type warnings I was getting when I compiled.  So that's one thing I never have to see again.

While I did that, I removed the for loop breaks so the loop doesn't stop when it finds the first possible item in the list, but keeps going to get all of them.

Next, I did the same with the draw command.  At this time, there is no change for what the player does, it's just set up for later when I fully implement it.

I also made it so the player can say "move north" or "go north" or whathaveyou, but can also just give a direction (just "north") and the player will move properly.  Actually, with the way the parser is currently set up, I probably don't even need to specify the words "move", etc.  But I'll keep them for now, in case something else at some point requires a direction as part of it's command (like "look up" or something might later give a description of what's above).

I also made a repeat command.  Now the player can type "/r" and their previous command will be carried out (as long as it's a verb command, so you can't just spam the chat with a long message a thousand times).

Lastly, an invalid command will be repeated in the error box so you don't have to look two places to see that you made an error and then search for what the error is.

No comments:

Post a Comment