Advertisement
Guest User

Dwarf Fortress Windows Worldgen Script

a guest
Nov 5th, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.76 KB | None | 0 0
  1. #!/usr/bin/perl -w
  2. ####
  3. # Generate a world and wait for it to finish.
  4.  
  5. #$wordlist = "C:\\Dwarf Fortress\\Word.lst";
  6. $path = "C:\\Dwarf Fortress\\DF.WorldGen\\";
  7. $worldgentitle = "PS1";
  8.  
  9. ####
  10.  
  11. use File::Glob qw(bsd_glob);
  12. $|=1;
  13.  
  14. ####
  15. # Get region ID
  16. if (defined($ARGV[0])) {
  17.     $region_id = $ARGV[0];
  18. } else {
  19.     # Find first available region ID
  20.     # First we look for the highest one in use
  21.     $region_id = 0;
  22.     foreach $file (bsd_glob("${path}data\\save\\region*")) {
  23.         if ($file =~ /(\d+)$/ && ($1 > $region_id)) {
  24.             $region_id = $1;
  25.         }
  26.     }
  27.     # Then we add one to get the next available region ID
  28.     $region_id += 1;
  29. }
  30.  
  31. ####
  32. # Now we choose the random seed to use
  33. # Setting $seed to "RANDOM" will cause DF itself to choose a random seed
  34. $seed = "RANDOM";
  35.  
  36. # I decided to use words to make it more interesting.
  37. # BUG: DF didn't use the seed given; Maybe it  needs to be a number
  38. #open INFILE, "<$wordlist";
  39. #@contents = <INFILE>;
  40. #close INFILE;
  41. #$seed = $contents[rand @contents];
  42. #chomp $seed;
  43.  
  44. # BUG: This seed was copied directly from a region1-world_gen_param.txt file
  45. #       The seed shown in the region1-world_gen_param.txt of the new region is "null"
  46. #$seed = "ea0QsKYM8yKmEkwccY4U";
  47.  
  48.  
  49. ####
  50. # Start world gen
  51. print("\"${path}Dwarf Fortress.exe\" -gen $region_id $seed $worldgentitle\n");
  52. # Had to copy "Dwarf Fortress.exe" to "df.exe" because start does not like spaces in the names of executables.
  53. system("start /low /min /D \"${path}\" df.exe -gen $region_id $seed $worldgentitle\n");
  54.  
  55. ####
  56. # Wait for it to complete
  57. $start = time();
  58. while (!-d "${path}data\\save\\region$region_id") {
  59.     $now = time();
  60.     printf("%d:%02d elapsed.\r", int(($now-$start)/60), (($now-$start)%60));
  61.     sleep(1);
  62. }
  63. print "\nWorld generation complete!\n";
  64. sleep(5);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement