So you want to move players and other objects around.. well here is the simple way.
The new cowscript statement 'relocate' takes care of all ofthe mess work for you.
syntax:
relocate {object} to|into|through|via {object} print "message~trigger" then "message~trigger";
If you use 'to' or 'into' you teleport the first object into the second object.
If you use 'through' or 'via' you move the first object through the second objects as if they had use the GO command.
You can use variables instead of iether object or the messages.
The first message is shown in the location they left, the second where they arrive.
The ~trigger is optional, and will be 'leaves' and 'arrives' by default. This alows you to control the trigger word each message generates.
Due to the timing of things, a player being relocated will only see the arrive message so you might want to send a private message to them read the info about sayto
Here is an example. Lets assume a player has pushed an object and we want to move the player out a random doorway:
if target of push then finddoor;
##finddoor:
find $loc,random doorway;
if $found_id > 0 then shuntthem;
##shuntthem:
sayto $init_obj,"[$actor] shunts [$init_obj] away";
relocate $init_obj through $found_id print "[$actor] is shunted out~shunts" then "[$actor] arrives via";
Notice how we dont specify the doorway objects in the print statements, this is because they are auto-calculated and added on by the 'relocate' statement.
This gives you the freedom to have something like 'A whiff of smoke from [$actor] pushes [$init_obj] out via'. The print statements will always end in the doorway object.
We send out the trigger keyword 'shunts' so that any obejct that reacts to shunts can do its thing when the object leaves.. any object that reacts to 'leaves' wont have anything to react to as the trigger word was repalced with 'shunts'. The'arrive' trigger word will be sent out to the destination location as normal, we did not override that.
Relocate takes care of changing the location, sending messages, causing relooks, finding what the doorways are and even making sure all hosted objects follow the relocated one (use refresh $target to do this last bit manually).
If you use a blank string for iether message they will be converyed into sensible '{object} leaves via {object}' and '{object} arrives via {object}'. If you want to supress messages, then you have to do the whole thing manually.
Here is an example of telepotation as I know some of you will want to do this:
if target of push then teleportthem;
##teleporthem:
$newloc = 7007; # the art gallery in the old town;
print "[$init_obj] feels all giddy and wants to visit [$newloc]";
sayto $init_obj,"[$init_obj] feels all giddy and wants to visit [$newloc]";
relocate $init_obj to $newloc print "[$actor] vanishes~teleportout" then "[$actor] magically appears~teleportin";
Notice how we use a simple vanish and appear, this is because there are not doorway objects when teleporting.
Also notice how we print a message to the room the player was in, then whisper that exact same message to the player so they see it too. ithout this the player has no idea how or why they 'magically apeared in the art gallery'.
See how we made the trigger words 'teleportin' and 'teleportout' so any object reacting to iether of these will do so (not the standard arrives or leaves).