There may be a couple different problems here. One is, when you set up grammar defs, it's expecting the words you type after the verb to be nouns or adjectives of objects -- not object names. So something like this is going to be problematic:
verb "teleport"
* object DoTeleport
Even if DoTeleport checks to make sure object is a room and gives an error otherwise, it's probably going to tell you that you haven't encountered that yet.
There is a way to specify object names in the syntax of a verb, but I think that's going to pose the same problem. And you probably don't want to set the "known" flag on all rooms from the start (messes up verbose descriptions, for instance). And even if you did, the room would have to be "visible" (in scope) for that to work anyway.
So... what you have to do is use the "string" identifier in the verb def, and then test against all possible rooms. If there's an easier way (and probably there is -- I'd just have to think longer) I'm not aware.
Download the source for Trading Punches or Swordsman and take the IsEqual function out of utils.hug. This basically lets you test up to 5 strings against a target and see if any match. It's overkill for what you need, and you *could* write a down-and-dirty IsEqual function that just tests one. Basically you use the string() function to turn dictionary words into strings, and then test two using the StringEqual() function.
So your grammar def would look like this:
Code: Select all
xverb "teleport"
* string DoTeleport
And DoTeleport would look like this:
Code: Select all
routine DoTeleport
{
local newroom = nothing
if IsEqual(parse$,"deck") {
newroom = deck
} elseif IsEqual(parse$,"loft") {
newroom = loft
}
if (newroom ~= nothing) {
"You teleport to..."
MovePlayer(newroom)
} else {
"You can't teleport to there."
}
return true
}
The problem here is that all the room names would have to be in quotes. Players would have to type:
>teleport "loft"
There are other, trickier ways to handle it though. You could define the verb as "* anything" and then capture for it in PreParse (you'd need to look at the parsing portion of the Hugo library to see how to handle that). That would let you get around the problem of the room not being in scope. You could even customize the error handling and check for this particular verbroutine there. There is a *lot* you can do by messing around with the parsing.
There may be a couple different problems here. One is, when you set up grammar defs, it's expecting the words you type after the verb to be nouns or adjectives of objects -- not object names. So something like this is going to be problematic:
verb "teleport"
* object DoTeleport
Even if DoTeleport checks to make sure object is a room and gives an error otherwise, it's probably going to tell you that you haven't encountered that yet.
There is a way to specify object names in the syntax of a verb, but I think that's going to pose the same problem. And you probably don't want to set the "known" flag on all rooms from the start (messes up verbose descriptions, for instance). And even if you did, the room would have to be "visible" (in scope) for that to work anyway.
So... what you have to do is use the "string" identifier in the verb def, and then test against all possible rooms. If there's an easier way (and probably there is -- I'd just have to think longer) I'm not aware.
Download the source for Trading Punches or Swordsman and take the IsEqual function out of utils.hug. This basically lets you test up to 5 strings against a target and see if any match. It's overkill for what you need, and you *could* write a down-and-dirty IsEqual function that just tests one. Basically you use the string() function to turn dictionary words into strings, and then test two using the StringEqual() function.
So your grammar def would look like this:
[code]xverb "teleport"
* string DoTeleport[/code]
And DoTeleport would look like this:
[code]routine DoTeleport
{
local newroom = nothing
if IsEqual(parse$,"deck") {
newroom = deck
} elseif IsEqual(parse$,"loft") {
newroom = loft
}
if (newroom ~= nothing) {
"You teleport to..."
MovePlayer(newroom)
} else {
"You can't teleport to there."
}
return true
}[/code]
The problem here is that all the room names would have to be in quotes. Players would have to type:
>teleport "loft"
There are other, trickier ways to handle it though. You could define the verb as "* anything" and then capture for it in PreParse (you'd need to look at the parsing portion of the Hugo library to see how to handle that). That would let you get around the problem of the room not being in scope. You could even customize the error handling and check for this particular verbroutine there. There is a *lot* you can do by messing around with the parsing.