Calling exits
Scrim
12 Dec 2016, 23:14I'm attempting to make a script so that the player can throw objects to rooms connected to the player's current room. Unfortunately I can't seem to figure out how to make the script determine if an exit is present in the requested direction, let alone if it's locked/closed. Any suggestions or a nudge in the right direction would be greatly appreciated.
Additionally, I'm running the browser version of Quest.
The Pixie
13 Dec 2016, 08:24The GetExitByName
function does just this (note that it gets the name of the exit, so use GetObject
to get the exit from the name) (also, all exits have names, even if you do not give them names).
http://docs.textadventures.co.uk/quest/functions/getexitbyname.html
I would guess something like this:
exitname = GetExitByName(player.parent, "north")
exit = GetObject(exitname)
Scrim
13 Dec 2016, 08:47I'll give that a shot and see what I can do. I also didn't realize there was a page devoted to the various functions, many thanks!
Scrim
15 Dec 2016, 03:32Managed to get a rough draft working with no problems that I can find.
For anyone interested:
if (Got(object)) {
msg ("Which direction?")
get input {
if (ListContains(Split ("north;east;south;west;northeast;northwest;southeast;southwest;up;down;in;out" , ";"),(LCase(result)))) {
exitname = "null"
exitname = GetExitByName(player.parent, LCase(result))
if (exitname <> null) {
exit = GetObject(exitname)
msg (("You threw the " + LCase(object.name) + " to the " + LCase(result) + "!"))
MoveObject (object, exit.to)
}
else {
msg (("Thud! You throw the " + LCase(object.name) + " " + LCase(result) + " only to hit a wall and promptly fall to the ground."))
MoveObjectHere (object)
}
}
else {
msg ("You are not quite sure where that is.")
}
}
}
else if (not Got(object)) {
msg ("You have to pick it up first.")
}