Coverting dialog scripts to scripting scripts

Started by SSH, Thu 15/01/2004 17:23:07

Previous topic - Next topic

SSH

Here's the basis of a perl program to convert dialogs to scripts. Its not comprehensive, but someone may find it useful (I did!)

#!/usr/local/bin/perl

my $who = "";
my $what = "";
my $comment = "";

while (<>) {
 if (/^\@/) {
   print "//$_";
 } elsif (/^([A-Za-z0-9_]+)\: (.*).$/) {
   $who=$1; $what=$2; $comment="";
   if ($what =~ m|(\s*//.*).$|) {
     $comment=$1; $what =~ s|(\s*//.*)$||;
   }
   printf 'DisplaySpeech(%s, "%s");%s%s', $who, $what, $comment, "\r\n";
 } elsif (/run-script\s+([0-9]+)/) {
   print "dialog_request($1);\r\n";
 }
 # More translations of script commands can go here
}
12

Scorpiorus

Nice one SSH! Thanks for sharing it. :)

~Cheers

ratracer

...

SSH

SHouldn't think so. I've never really tried to use Windows Perl, but if you've got any unix/linux flavour, it should just runitself if you stick it in a file and chmod +x
12

Pumaman

Clever idea, nice one SSH.

I won't pretend that I can read perl, but it looks reasonable enough :)

SMF spam blocked by CleanTalk