#! /usr/bin/tclsh ### ### Describe a particular world ### ### (c) 2003 Mark Wooding ### ###----- Licensing notice --------------------------------------------------- ### ### This program is free software; you can redistribute it and/or modify ### it under the terms of the GNU General Public License as published by ### the Free Software Foundation; either version 2 of the License, or ### (at your option) any later version. ### ### This program is distributed in the hope that it will be useful, ### but WITHOUT ANY WARRANTY; without even the implied warranty of ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ### GNU General Public License for more details. ### ### You should have received a copy of the GNU General Public License ### along with this program; if not, write to the Free Software Foundation, ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package require "elite" "1.0.1" ###-------------------------------------------------------------------------- ### Support functions. proc describe n { ## Describe the world with seed N. global economy government ## Fetch the necessary information. elite-worldinfo p $n ## Format most of the data. puts "Name: $p(name)" puts "Seed: $p(seed)" puts "Position: $p(x), $p(y) LY" puts "Economy: $economy($p(economy))" puts "Government: $government($p(government))" puts "Tech. level: $p(techlevel)" puts [format "Population: %s billion (%s)" \ [expr {$p(population)/10.0}] $p(inhabitants)] puts "Gross productivity: $p(productivity) M Cr" puts "Radius: $p(radius) km" ## Format the world description, word-wrapping as necessary. puts "" set ll {} set l 0 foreach w $p(description) { incr l incr l [string length $w] if {$l > 72} { puts $ll; set ll {}; set l 0 } lappend ll $w } puts $ll } ###-------------------------------------------------------------------------- ### Main program. ## Parse the command line and describe the planets indicated. if {[llength $argv] < 1} { puts stderr "usage: $argv0 \[-g GALAXY\] PLANET ..." exit 1 } set g $galaxy1 for {set i 0} {$i < [llength $argv]} {incr i} { set a [lindex $argv $i] switch -- $a { "-g" { incr i set a [lindex $argv $i] set g [parse-galaxy-spec $a] if {[string equal $g ""]} { puts stderr "$argv0: bad galaxy string `$a'" exit 1 } destructure {. g} $g } default { set n [parse-planet-spec $g $a] if {[string equal $n ""]} { puts stderr "$argv0: unknown planet `$a'" continue } describe $n puts "" } } } ###----- That's all, folks --------------------------------------------------