Game allows North when exit is actually Northwest. Want to block all but NW
kulouie13
04 Feb 2022, 09:42I'm new to Quest - just discovered it two days ago and I'm having a blast struggling mightily with code and Commands and whatnot. But I just ran into a headscratcher for me, when most of what I have is actually running smoothly somehow. I have a room (Living Room) with a NW exit to the Westside Backyard. I created it and created the exit both ways. When traveling from Westside backyard into the Living Room, SE is required (S actually goes to another room). When traveling from the Living room, N should hit a wall (can't go that way) and NW should take me to the Westside backyard. For some reason, both N and NW work. I don't want this - I only want NW to work. Also, why is this happening? Any and all help appreciated.
mrangel
04 Feb 2022, 09:47When the player types an object alias, Quest looks at the beginning of all objects they can see. For example, you can type "comp" to mean "computer", "trash" for "trash can", "sp" for "spanner", or "north" for "northwest".
If you want to block this in a specific case, the easiest way is probably creating a "north" exit in the room, making it scenery, locked, and changing the lock message to "You can't go that way."
kulouie13
04 Feb 2022, 09:58That worked, although I'm guessing I'll have to do that for any/every room that has a diagonal exit and does not have a cardinal exit matching its starting letter. Not too difficult, just with how powerful/picky some of the other processes I've run into thus far, I'm surprised this is needed. Thanks!
mrangel
04 Feb 2022, 14:17I'm guessing I'll have to do that for any/every room that has a diagonal exit and does not have a cardinal exit matching its starting letter
Hmm… I think it should be possible to have some code in your start script that creates them automatically. Off the top of my head…
> Click here to see my thought process as I came up with this
One alternative would be to create an object called "north_wall" or similar. You could put it somewhere it's not accessible, and then give the game a script attribute named `changecommandscope`: ``` if (objtype = "exit") { foreach (direction, Split("north;south;east;west")) { if (ListCount (FilterByType (items, direction+"direction")) = 0) { list add (items, GetObject (direction + "_wall")) } } } ```That changes the way Quest determines what exits are viable candidates before comparing their aliases to what the player typed; if there isn't an exit which inherits the northdirection
type, the object named north_wall
is considered. If there isn't an exit that inherits the westdirection
type, the object named west_wall
is added, and so on.
The exits for this script should be named north_wall
, south_wall
, east_wall
, and west_wall
. You can set their aliases to whatever you want (the player's command is compared to the aliases, and their alt aliases). These will still be expanded if necessary. So you might see:
==> go north
Which object did you mean?
- Northwest
- North wall
To stop the menu appearing, make the dummy exit's alias (or one of the entries in its alt list) exactly "north". It might be worth adding "n" to the alt list as well. Because Quest only considers names that start with what the player typed if there's nothing whose alias is exactly what the player typed.
If the player types "go nor", it will still give them a list of options. But not if they type an option that's in the list.
Actually, if you want to do it with just a single copy-and-paste, this script (which you can put in your game's start script) will create the dummy exits for you and make the change to the parser so that the dummy exits are available whenever there isn't a real exit in that direction.
You can put this in your game's start script, and it should make exits behave like this by default:
foreach (direction, Split("north;south;east;west")) {
create exit (direction+"_wall", direction+" wall", null, null, direction+"direction")
dummyexit = GetObject(direction+"_wall")
if (not dummyexit = null) {
dummyexit.alt = ListCombine (Split (direction), dummyexit.alt)
dummyexit.locked = true
dummyexit.lockmessage = "[UnresolvedLocation]"
}
}
game.changecommandscope => {
if (objtype = "exit") {
foreach (direction, Split("north;south;east;west")) {
if (ListCount (FilterByType (items, direction+"direction")) = 0) {
list add (items, GetObject (direction + "_wall"))
}
}
}
}
(I'm not sure, but it might work if you make the exit dummy invisible rather than locked. If so, that would be more efficient because you don't need to specify a message for that)