Expression to indicate a direction from a room?
kostromama
11 Jan 2018, 18:14If I want to have an expression that pushes the player or an object in a direction from the current room, rather than a specific room, is there a way to indicate that with an expression? For example, if the player can fly, and will fall from upper rooms to lower rooms if they stop flying, is there any way to indicate directional/exit relationships between rooms or force the "go down" command?
The alternative is to code a zillion "ifs" manually linking the rooms but that seems inelegant and tedious.

Forgewright
11 Jan 2018, 20:28I have a player that flies. I structured my rooms to have a walking and flying room description. Inside is easy because the descriptions are the same because the player is constrained to the room.
Outside, I copy the walking description and add "looking down". This was the easiest way for me with out adding extra rooms above every outside room in the game.
However, a player flying in an outside room, created to be above a ground room can be handle easily by placing the above or flying room inside the ground room. The player will not know the difference and when they stop or are forced to land you can use
player.parent = player.parent.parent
So, I use a "fly" and a"land" command for the player to use. The land can be like this:
If (player.flying = true) {
player.parent = player.parent.parent
msg ("You decide to land.")
}
else { msg ("You are not flying.")
}
This places the player in the ground room.
If you have separate rooms already in use.
exitname = GetExitByName(player.parent, "down") <!--- this gets the down exit name -->
exit = GetObject(exitname) <!--- this holds the name in a variable -->
MoveObject (player, exit.to) <!--- this move the player to the named exit-->
Got this from
Calling exits
Also use:
Getexitbyname
Hopefully I got the script right.
If not someone will fix it here in a bit.
hegemonkhan
12 Jan 2018, 05:38you need an indicator/flag (Attribute) on your rooms to specify their location/placement to other rooms, and then you use 'if' to check it.
the best design would be to give your rooms a 'x_coordinate_integer_attribute (west-east)', 'y_coordinate_integer_attribute (north-south)', and 'z_coordinate_integer_attribute (up-down)', aka, basic 3D grid work/math.
your 'if' (and a greater/lesser than and/or also equal to) scripting can then check if/find what room is above/below, north/south, and west/east, via the room you're currently in and its 'x,y,z coordinate' Integer Attributes to the others rooms that are connected to it and their 'x,y,z coordinate' Attributes
if you need help with this (and you want to do/use it), let me know
kostromama
12 Jan 2018, 16:33Nesting the rooms might be a good bet, but so far I'm getting error messages. Probably just my subpar scripting.
It all seems like a lot of reinvented wheels, though, for something that already happens when the player types "d". I'm finding it hard to believe that there's not a way to just force the player to take an exit if possible.
jmnevil54
13 Jan 2018, 01:05I don't think it's neccessay to "force" the player to exit. You can say "You feel scared. You should leave."
Or, you can move the player with "MoveObject (player)" (not sure if the format is right).