[Crossfire-wiki] [Crossfire DokuWiki] page added: client_side_scripting:scripts:perl:travel

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Tue Dec 19 19:50:08 CST 2006


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2006/12/19 19:50
User        : mhoram
Edit Summary: created

====== Travel Script ======

This is an initial quick hack of a travel script.  It is designed to walk a character from the sign in Euthville to the fountain in Scorn, while staying on the roads for safety and speed.  The timing isn't quite right on getting through the gates, so you may get stopped there, but it should get you to the gates of Scorn, at least, until you bump into someone.  There's no collision detection or recovery from that sort of thing yet, so anything that blocks your movement will throw off the rest of the directions and send you who-knows-where.

If this sort of thing turns out to be useful, I'd probably move the "steps" pairs into a separate text file, and have one script that could read multiple "steps" files for different voyages.

Here's the code, for anyone who would like to try it out.  Simply save it as a file, and execute the script with the command:  '''script perl /path/to/this/script''

<code perl>
#!/usr/bin/perl
use strict;
use warnings;
$| = 1;        # unbuffered stdout


# The following instructions will lead a player on the road from
#   the sign in Euthville to the fountain in Scorn

my @paces = (
	      northeast => 4 ,
	      east => 12,
	      southeast => 6 ,
	      south => 2 ,
	      southeast => 3 ,
	      east => 4 ,
	      southeast => 4 ,
	      south => 10,
	      southeast => 5 ,
	      south => 13,
	      southeast => 2 ,
	      south => 1 ,
	      southeast => 2 ,
	      east => 1 ,
	      southeast => 2 ,
	      south => 3 ,
	      southwest => 4 ,
	      south => 3 ,
	      southeast => 1 ,
	      south => 8 ,
	      southwest => 8 ,
	      south => 4 ,
	      southeast => 3 ,
	      south => 12,
	      southwest => 2 ,
	      south => 6 ,
	      southwest => 7 ,
	      south => 3 ,
	      southwest => 3 ,
	      south => 4 ,
	      southwest => 2 ,
	      west => 16,
	      stay => 6 ,
	      west => 14,
	      southwest => 1 ,
	      command => 'apply' ,
	      stay => 6 ,
	      northwest => 1 ,
	      west => 16,
	      northwest => 2 ,
);

while(1){
  my $key   = shift @paces;
  my $value = shift @paces;
  last unless ( defined $key and defined $value );
  if( $key eq 'command' ){
    print "issue 1 1 $value\n";
  } elsif( $key eq 'stay' ){
    sleep $value;
  } else {
    for my $steps (1..$value){
      print "issue 1 1 $key\n";
    }
  }
}
</code>


IP-Address  : 206.71.197.56
Old Revision: none
New Revision: http://wiki.metalforge.net/doku.php/client_side_scripting:scripts:perl:travel

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list