Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: SSH on Thu 15/01/2004 17:23:07

Title: Coverting dialog scripts to scripting scripts
Post by: SSH on Thu 15/01/2004 17:23:07
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
}
Title: Re:Coverting dialog scripts to scripting scripts
Post by: Scorpiorus on Thu 15/01/2004 20:49:47
Nice one SSH! Thanks for sharing it. :)

~Cheers
Title: Re:Coverting dialog scripts to scripting scripts
Post by: ratracer on Thu 15/01/2004 21:52:09
Do you have to know perl to use it?
Title: Re:Coverting dialog scripts to scripting scripts
Post by: SSH on Fri 16/01/2004 12:29:07
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
Title: Re:Coverting dialog scripts to scripting scripts
Post by: Pumaman on Sat 17/01/2004 12:28:41
Clever idea, nice one SSH.

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