Complete.Org: Mailing Lists: Archives: freeciv-dev: May 1999:
Re: [Freeciv-Dev] Start script for newbies.
Home

Re: [Freeciv-Dev] Start script for newbies.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Paul Zastoupil <paulz@xxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: Re: [Freeciv-Dev] Start script for newbies.
From: Nicolas Brunel <brunel@xxxxxxxxxxxxxxxxxxxx>
Date: Wed, 19 May 1999 22:33:50 +0000 (GMT)

Hello Paul,

    One of my friend ( Brunus ) has written a tcl/tk script which launch
a game and launch a client so that the user will only have to click
the connect button to start the game.

> There should be a simple script in the dist, that contains something
> like the following:
> ser -r autostart & #The autostart script should contain create ai, set
> maxplayers 2
> civ #maybe at some point we could force the client to connect from the
> commandline
> 
> Then they could start the game with one command.  Its a little effort to
> cut down on the "How do I start the game" questions.  Also for people
> who don't understand the whole client/server model.
> 
> Is this too basic?
We can call it auto-launch-freeciv or easy-to-launch-freeciv or 
freeciv ?

Best regards,
#!/bin/sh
# the next line restarts using wish \
exec wish "$0" "$@"#!/usr/bin/wish
# freeciv.tcl -- Sample tcl/tk application to start freeciv

label   .title  -text "Simple FreeCiv Game Starter"     -relief raised
label   .info   -text "See http://www.freeciv.org for more options"

pack    .title  -fill x
pack    .info   -fill x

frame   .single

# Choice of the type of battleground

frame   .single.terrain

label   .single.terrain.title   -text "World Map"
scale   .single.terrain.xsize   -from 40 -to 200 -label "width" -orient 
horizontal
scale   .single.terrain.ysize   -from 25 -to 100 -label "height" -orient 
horizontal
scale   .single.terrain.land    -from 15 -to 85 -label "landmass %" -orient 
horizontal

.single.terrain.xsize   set 80
.single.terrain.ysize   set 50
.single.terrain.land    set 30

pack    .single.terrain.title   -fill x
pack    .single.terrain.xsize
pack    .single.terrain.ysize
pack    .single.terrain.land

pack    .single.terrain -side left

# Size of playfield varies in function of the number of players

proc setsize {a} {
        .single.terrain.xsize set [expr "40 + 10 * ([.single.human.playfill 
get] + [.single.computer.aifill get])"]
        .single.terrain.ysize set [expr "30 + 5 * ([.single.human.playfill get] 
+ [.single.computer.aifill get])"]
}

# Up to 7 human players can play

frame   .single.human

label           .single.human.title     -text "Human players"
scale           .single.human.playfill  -from 1 -to 7 -label "Number" -orient 
horizontal -command setsize

.single.human.playfill  set 1

pack    .single.human.title     -fill x
pack    .single.human.playfill

pack    .single.human

# Up to 7 computer players can play

frame   .single.computer

label           .single.computer.title  -text "Computer players"
scale           .single.computer.aifill -to 7 -label "Number" -orient 
horizontal -command setsize
radiobutton     .single.computer.easy   -text "easy"    -variable computer 
-value "easy" -command {.single.terrain.land set 20}
radiobutton     .single.computer.normal -text "normal"  -variable computer 
-value "normal" -command {.single.terrain.land set 30}
radiobutton     .single.computer.hard   -text "hard"    -variable computer 
-value "hard" -command {.single.terrain.land set 50}

.single.computer.normal invoke
.single.computer.aifill set 1

pack    .single.computer.title  -fill x
pack    .single.computer.aifill
pack    .single.computer.easy
pack    .single.computer.normal
pack    .single.computer.hard

pack    .single.computer

pack .single    -fill x

# 3 buttons :
# 'Quit' : quit the game
# 'Connect' : connect to a server
# 'Start' : start a server, a game and wait for other human players (if any) to 
connect


button  .quit           -text "Quit" -command exit
button  .connect        -text "Connect to a game" -command {
        exec civclient
}
button  .start          -text "Start a new game" -command {
        set f [open "/tmp/freeciv.start" "w"]
        puts $f "set landmass [.single.terrain.land get]"
        puts $f "set xsize [.single.terrain.xsize get]"
        puts $f "set ysize [.single.terrain.ysize get]"
        puts $f "set maxplayers [expr [.single.human.playfill get] + 
[.single.computer.aifill get]]"
        puts $f "$computer"
        for {set i 1} {$i <= [.single.computer.aifill get]} {incr i 1} {
                puts $f "create computer$i"
        }
        close $f
        exec chmod 666 /tmp/freeciv.start
        exec civserver --read /tmp/freeciv.start &
        exec civclient
        exec rm /tmp/freeciv.start
}

pack    .start          -side right
pack    .connect        -side right
pack    .quit           -side left



[Prev in Thread] Current Thread [Next in Thread]