zmud to tinyfugue speedwalk translator

Other clients used. jmc/tinyfuge, ect.

zmud to tinyfugue speedwalk translator

Postby raincrab » Sat Nov 24, 2012 4:54 am

heres a perl script to translate zmud style speedwalks into tinyfugue commands

Code: Select all
#!/usr/bin/env perl

#convert zmud speedwalks into tinyfugue commands

# usage: z2tf.pl '3nes2we;open door;'

use strict;
use warnings;

my $zwalk = shift;
my @chars = split //, $zwalk;
my $count = 1;
my $iscmd = 0;
my $cmd = '';

foreach my $char (@chars) {
   if ($char =~ /\;/) {
      if ($iscmd) {
         print $cmd;
         print '%;';
         $cmd = '';
         $iscmd = 0;
      } else {
         $iscmd = 1;
      }
   } elsif ($iscmd) {
      $cmd = "${cmd}${char}";
   } elsif ($char =~ /[nsewud]/) {
      while ($count > 0) {
         print $char;
         print '%;';
         $count--;
      }
      $count = 1;
   } elsif ($char =~ /\d+/) {
      $count = $char;
   }
}


you can just use the output in a macro definition for your speedwalk
raincrab
 
Posts: 18
Joined: Thu Oct 18, 2012 5:46 pm
Status: Offline

Re: zmud to tinyfugue speedwalk translator

Postby raincrab » Thu Dec 13, 2012 7:52 am

this one fixes bugs where direction count > 10 and consecutive nondirectional commands

Code: Select all
#!/usr/bin/env perl

# z2tf.pl
#convert zmud speedwalks into tinyfugue commands

# usage: z2tf.pl '3nes2we;open door;'

use strict;
use warnings;

my $zwalk = shift;
my @walks = split ';', $zwalk;
my $count;

foreach my $walk (@walks) {
   while ($walk ne '') {
      if ($walk =~ /^([0-9nsewud]+)$/) {
         if ($walk =~ s/^(\d+)//) {
            $count = $1;
         } else {
            $count = 1;
         }
         $walk =~ s/^(.)//;
         my $char = $1;
         while ($count > 0) {
            print "${char}%;";
            $count--;
         }
      } else {
         print "${walk}%;";
         $walk = '';
      }
   }
}
print "\n";
raincrab
 
Posts: 18
Joined: Thu Oct 18, 2012 5:46 pm
Status: Offline

Re: zmud to tinyfugue speedwalk translator

Postby Tuck » Sat Dec 15, 2012 8:56 am

Good job!
Tuck
Triple 40 Poster
 
Posts: 323
Joined: Mon Jun 22, 2009 12:06 pm
Location: Planet Earth
Status: Offline


Return to Other Clients

Who is online

Users browsing this forum: No registered users and 2 guests

cron