Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl -w
- ####
- # Generate a world and wait for it to finish.
- #$wordlist = "C:\\Dwarf Fortress\\Word.lst";
- $path = "C:\\Dwarf Fortress\\DF.WorldGen\\";
- $worldgentitle = "PS1";
- ####
- use File::Glob qw(bsd_glob);
- $|=1;
- ####
- # Get region ID
- if (defined($ARGV[0])) {
- $region_id = $ARGV[0];
- } else {
- # Find first available region ID
- # First we look for the highest one in use
- $region_id = 0;
- foreach $file (bsd_glob("${path}data\\save\\region*")) {
- if ($file =~ /(\d+)$/ && ($1 > $region_id)) {
- $region_id = $1;
- }
- }
- # Then we add one to get the next available region ID
- $region_id += 1;
- }
- ####
- # Now we choose the random seed to use
- # Setting $seed to "RANDOM" will cause DF itself to choose a random seed
- $seed = "RANDOM";
- # I decided to use words to make it more interesting.
- # BUG: DF didn't use the seed given; Maybe it needs to be a number
- #open INFILE, "<$wordlist";
- #@contents = <INFILE>;
- #close INFILE;
- #$seed = $contents[rand @contents];
- #chomp $seed;
- # BUG: This seed was copied directly from a region1-world_gen_param.txt file
- # The seed shown in the region1-world_gen_param.txt of the new region is "null"
- #$seed = "ea0QsKYM8yKmEkwccY4U";
- ####
- # Start world gen
- print("\"${path}Dwarf Fortress.exe\" -gen $region_id $seed $worldgentitle\n");
- # Had to copy "Dwarf Fortress.exe" to "df.exe" because start does not like spaces in the names of executables.
- system("start /low /min /D \"${path}\" df.exe -gen $region_id $seed $worldgentitle\n");
- ####
- # Wait for it to complete
- $start = time();
- while (!-d "${path}data\\save\\region$region_id") {
- $now = time();
- printf("%d:%02d elapsed.\r", int(($now-$start)/60), (($now-$start)%60));
- sleep(1);
- }
- print "\nWorld generation complete!\n";
- sleep(5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement