by Merk » Sat Jan 13, 2007 10:37 pm
Sure. I did this in TTS. There is spot where a ladder leads up (south of you) and steps lead up (north of you). If the player tries to go UP, the game asks them to be more specific.
I didn't do it exactly like you want, though. I think I give a message like "you can climb the ladder to the south or the stone steps to the north" -- something like that. They'll either type "climb ladder" or "climb steps" or maybe "north" or "south". What you're looking for is something that the Hugo engine itself does -- disambiguation. But that only happens when it's trying to match objects to a verb definition, and more than one object qualifies without any rules to treat one as more important than the other.
I know of know good way to mimic *that* behavior. In order for the user to answer the question, you'd either have to (a) have verbs set up that *are* the answers, or (b) maybe give a custom prompt. But that's not ideal, because the user should be able to pick neither, and type something else entirely.
You *might* be able to do it with a PreParse() routine. I think, though, that PreParse() doesn't get called until the engine has already parsed the command line into the word[] array. Actually, it'd have to be like that, else PreParse() would have nothing to look at. If that's the case, the engine will already have complained that their answer ("red door" or "green door") doesn't start with a verb.
But again, you could make pseudo verbs "red" and "green". Have a flag any time the game is actually expecting the user to type one of them (otherwise the flag is false). When it's false, the VerbRoutine can call the library "that's not a verb I recognize" mesasge (or whatever it says).
If I think of any other ideas, I'll post again. It seems like maybe I'm forgetting something that might help.
Sure. I did this in TTS. There is spot where a ladder leads up (south of you) and steps lead up (north of you). If the player tries to go UP, the game asks them to be more specific.
I didn't do it exactly like you want, though. I think I give a message like "you can climb the ladder to the south or the stone steps to the north" -- something like that. They'll either type "climb ladder" or "climb steps" or maybe "north" or "south". What you're looking for is something that the Hugo engine itself does -- disambiguation. But that only happens when it's trying to match objects to a verb definition, and more than one object qualifies without any rules to treat one as more important than the other.
I know of know good way to mimic *that* behavior. In order for the user to answer the question, you'd either have to (a) have verbs set up that *are* the answers, or (b) maybe give a custom prompt. But that's not ideal, because the user should be able to pick neither, and type something else entirely.
You *might* be able to do it with a PreParse() routine. I think, though, that PreParse() doesn't get called until the engine has already parsed the command line into the word[] array. Actually, it'd have to be like that, else PreParse() would have nothing to look at. If that's the case, the engine will already have complained that their answer ("red door" or "green door") doesn't start with a verb.
But again, you could make pseudo verbs "red" and "green". Have a flag any time the game is actually expecting the user to type one of them (otherwise the flag is false). When it's false, the VerbRoutine can call the library "that's not a verb I recognize" mesasge (or whatever it says).
If I think of any other ideas, I'll post again. It seems like maybe I'm forgetting something that might help.