Quake3World.com Forums
     Programming Discussion
        Quake 3 Map config Tool


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Quake 3 Map config Tool

Gibblet
Gibblet
Joined: 09 Jan 2012
Posts: 15
PostPosted: 01-09-2012 04:02 PM           Profile Send private message  E-mail  Edit post Reply with quote


Hello Everyone,

I'm going to be writing some scripts for quake 3, and Id like to post some of the code here, for Reference reasons, here is my first simple perl script for server map config generation:

Code:
#!/usr/bin/perl -w
# Reads maps from map directory creates config to paste into server config of map rotation
# Note I was to lazy to check for last file printing to config, so the last m# needs to be m1
# example  set m29 "map pasctf4_final;set nextmap vstr m1"  if m29 was your last line change the last m to m1

$d = "/usr/local/games/ioquake3/maps";

open FILE, ">maps.txt" or die $!;

print "Do you want to include base maps?:[y/n]";
$userinput = <STDIN>;
chomp ($userinput);

if($userinput =~ /y/) {

print FILE 'set m1 "map q3dm2;set nextmap vstr m2"'."\n" .
'set m2 "map q3dm4;set nextmap vstr m3"'."\n"  .
'set m3 "map q3dm6;set nextmap vstr m4"'."\n"  .
'set m4 "map q3dm7;set nextmap vstr m5"'."\n"  .
'set m5 "map q3dm8;set nextmap vstr m6"'."\n"  .
'set m6 "map q3dm9;set nextmap vstr m7"'."\n"  .
'set m7 "map q3tourney4;set nextmap vstr m8"'."\n"  .
'set m8 "map q3dm13;set nextmap vstr m9"'."\n" .
'set m9 "map q3dm14;set nextmap vstr m10"'."\n" .
'set m10 "map q3dm15;set nextmap vstr m11"'."\n" ;
$m=11;
$i=12;
}
else { $m=1; $i=2; } #start config at line 1

opendir(DIR, $d);

foreach my $file (readdir(DIR)) #for each file in directory read
    {
    $file =~ s{\.[^.]+$}{};  # remove extention
    if($file !~ /\./) {   # if file doesnt contain . .. print
$str = 'set m'.$m.' "map '.$file.';set nextmap vstr m'.$i.'"';
print FILE $str;
print FILE "\n";
    }
$m++;
$i++;
}

closedir(DIR);
close FILE;




Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.