Noob question

hastur13
11 Sept 2012, 18:26
Hoping someone can point me in the right direction. How do you command an object to move on its own to a position relative to the player. I.e player tells object to move to the room on the players left. But the player remains in the centre room.

sgreig
11 Sept 2012, 23:18
Well, I believe in order to move an object you need to specify the room. So, in order to do this you would likely need to query the list of exits in the room, then find the correct exit and assign the adjoining room to a variable, and then move the object to that variable. This would all be called from a custom command. Right off the top of my head I can't think of the right syntax for the code for this, and I'm just heading out right now so I don't have time to look. Hopefully this points you in the right direction.

I'll take a look at it later when I have more time if someone else hasn't taken a crack at it by then.

The Pixie
12 Sept 2012, 11:41
The way I would do it is to get a list of exits for the current room ScopeAllExitsForRoom(player.parent), iterate through the list looking for the right direction, then set your object's parent as the to attribute for that exit.

Say the object is obj, the direction is a string, dir (code untested)

found_exit = null
foreach (exit, ScopeAllExitsForRoom(player.parent) {
if (exit.alias = dir) found_exit = exit
}
if (not found_exit = null) {
obj.parent = exit.to
msg ("The "+obj.name+" has gone "+dir+".")
}
else {
msg ("It cannot go that way.")

sgreig
13 Sept 2012, 04:40
That was essentially what my overtired, distracted brain was trying to say, lol. :)