Roody_Yogurt wrote:I haven't tested it, so there very well could be some typos somewhere, but in theory, it should work.
Yes, your code works great! I learned a couple of things too.
First the routine, "InList", looks like another one of those obscure yet extremely useful library routines. I had seen you use it before and meant to look it up. I'm going to start using it regularly. Also, I noticed that you used "break" to exit a loop. I had mistakenly thought that it would always cause a
routine to exit immediately. HbE states clearly: "If the game is in a loop (for, while, etc.), break immediately exits the current loop."
Roody_Yogurt wrote:I think the main thing it doesn't do that your routines do is it doesn't check for open doors as early as your code does as it is basically a souped-up version of the original routines. Your take sounds appealing, but I didn't really want to think on it long enough to decide what's best for me.
You know, I'm not sure that one approach is necessarily better than the other. Your approach has the advantage of being closer, in form, to the original so that It might be easier for someone to modify. It also doesn't require any modification to the messages and I can imagine that being a plus for some people.
The main advantage to my approach is that it keeps the message: "(With the [key]) / Unlocked," message intact. It also checks if a door is open before trying to unlock it. But, really, the player should know that an open door is unlocked already, so this isn't a huge plus. Also, if the player tries to lock a door with a coat, for instance, the routine will tell him he needs to shut the door first without letting him know that the coat isn't a valid key object.
Thinking about this caused me to wonder if the best solution might be to inform the player of all conditions that need to be modified before the door can be locked/unlocked. So if the player tries to unlock a door that is open and unlocked, he would see:
Hugo Interpreter wrote:
The closet door is open.
(It's already unlocked anyway.)
I coded up a fairly crude example of this that can be found here:
http://dl.dropbox.com/u/11102009/newkey.h
It gives the player all of the conditions that have to be met to lock/unlock a door(open/shut, locked/unlocked, no key, wrong key). I also replaced the "NewVMessages" routine with my own "ExMessages". I did this with a mind toward a possible future extension, so that it doesn't interfere with any preexisting replaced verb messages.
I admit that this whole idea could be misguided. The player should be well aware of what needs to happen to lock/unlock a door. But I would like to get someone elses opinion before I abandon the idea. Even if it doesn't work here, it might be nice for other situations.
Thanks for finding these! They look pretty tough. They mostly cover areas that I haven't dealt with yet. I especially like the idea of configuration files. That has serious potential!
[quote="Roody_Yogurt"]I haven't tested it, so there very well could be some typos somewhere, but in theory, it should work.[/quote]
Yes, your code works great! I learned a couple of things too.
First the routine, "InList", looks like another one of those obscure yet extremely useful library routines. I had seen you use it before and meant to look it up. I'm going to start using it regularly. Also, I noticed that you used "break" to exit a loop. I had mistakenly thought that it would always cause a [i]routine[/i] to exit immediately. HbE states clearly: "If the game is in a loop (for, while, etc.), break immediately exits the current loop."
[quote="Roody_Yogurt"]I think the main thing it doesn't do that your routines do is it doesn't check for open doors as early as your code does as it is basically a souped-up version of the original routines. Your take sounds appealing, but I didn't really want to think on it long enough to decide what's best for me.[/quote]
You know, I'm not sure that one approach is necessarily better than the other. Your approach has the advantage of being closer, in form, to the original so that It might be easier for someone to modify. It also doesn't require any modification to the messages and I can imagine that being a plus for some people.
The main advantage to my approach is that it keeps the message: "(With the [key]) / Unlocked," message intact. It also checks if a door is open before trying to unlock it. But, really, the player should know that an open door is unlocked already, so this isn't a huge plus. Also, if the player tries to lock a door with a coat, for instance, the routine will tell him he needs to shut the door first without letting him know that the coat isn't a valid key object.
Thinking about this caused me to wonder if the best solution might be to inform the player of all conditions that need to be modified before the door can be locked/unlocked. So if the player tries to unlock a door that is open and unlocked, he would see:
[quote="Hugo Interpreter"]
The closet door is open.
(It's already unlocked anyway.)
[/quote]
I coded up a fairly crude example of this that can be found here:
http://dl.dropbox.com/u/11102009/newkey.h
It gives the player all of the conditions that have to be met to lock/unlock a door(open/shut, locked/unlocked, no key, wrong key). I also replaced the "NewVMessages" routine with my own "ExMessages". I did this with a mind toward a possible future extension, so that it doesn't interfere with any preexisting replaced verb messages.
I admit that this whole idea could be misguided. The player should be well aware of what needs to happen to lock/unlock a door. But I would like to get someone elses opinion before I abandon the idea. Even if it doesn't work here, it might be nice for other situations.
[quote="Roody_Yogurt"]Here's a list of pages with some kind of coding challenge:
http://hugo.gerynarsabode.org/index.php?title=Window
http://hugo.gerynarsabode.org/index.php?title=Move
http://hugo.gerynarsabode.org/index.php?title=Opportune.h#Hugo_Homework
http://hugo.gerynarsabode.org/index.php?title=Configuration_files[/quote]
Thanks for finding these! They look pretty tough. They mostly cover areas that I haven't dealt with yet. I especially like the idea of configuration files. That has serious potential!