Moving objects in a direction instead of to a location.

Is there a way to move an object in a direction (following an exit) instead of sending it to a location? Like, setting a script to auto send a player "south" when it enters a room?


There is a way, it takes a little bit of scripting, though.

Here's a function you could use:

<function name="MoveObjectInDirection" parameters="object, direction">
  current_room = object.parent
  exitname = GetExitByName (current_room, direction)
  if (not exitname = null) {
    exit = GetObject (exitname)
    MoveObject (object, exit.to)
  }
</function>

That basically looks at the room an object is currently in, finds an exit in the right direction, and moves the object to the place that exit points to.


to expound further, if you want more advanced control/functionality, the next step is to give all of your rooms and/or actors/characters (players/npcs/monsters/etc) coordinate Integer Attributes, which you can then use, along with arithmetic upon them, to do some really advanced stuff, like the pathfinding of AI/npcs/monsters, placement/movement beyond adjacency (beyond 1 'tile'/unit-of-distance/room), and etc.

and these coordinates/grid-effect can be combined nicely with mrangel's function/method, for really smooth and powerful control of advanced functionality


I'm using the in-browser version only, so I'm pretty limited. I'll try that function, thanks.


If the player types PUSH CRATE SOUTH, would he or she expect to end up in the room to the south with the crate, or for just the crate to go south, but the player stay in this room?


I've never used the browser version, but either way wouldn't it just be...

PUSH VERB: Push South.
MoveObject (crate, roomsouthname)

Then that leaves the player time to move whenever they want. If the player goes with it though, then you can modify it like this...

PUSH VERB: Push South.
MoveObject (crate, roomsouthname)
MoveObject (player, roomsouthname)

I'm probably not understanding the question though.

Anonynn.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums