Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] (PR#7245) Wish List: Freeciv Tutorial
Home

[Freeciv-Dev] (PR#7245) Wish List: Freeciv Tutorial

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: gang65@xxxxxxxxxxxxxx
Subject: [Freeciv-Dev] (PR#7245) Wish List: Freeciv Tutorial
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 9 May 2005 18:47:26 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=7245 >

Attached is the beginning of a whisper of a tutorial scenario.  It
should probably be committed so that we can get better testing.

Problems I have run into:

1.  There is no error message for most script errors.

2.  Running xgettext is problematic because of the double-escaping of
strings in the .sav file.  To get a newline you have to add a \\n, since
the \\ is unescaped by the registry code so a \n is passed into lua. 
xgettext scans this with the \\ in place.  However (I think), the \\
needs to be unescaped into a \ by xgettext so that the msgid and msgstr
both contain just \n.  gettext itself (the _() function) is called after
the unescaping is done so the unescaped string "\n" is what's actually
passed in.

3.  Additionally there are problems in that xgettext doesn't know Lua
syntax.  It doesn't understand using single-quotes (') instead of
double-quotes (") unless you pass in --language=python.  Even after that
it doesn't understand string concatenation (the ... operator) so you
have to use a single mega-string (as in the .sav file).  This could also
be solved (along with #2) by running sed on the .lua files before
running xgettext on them.  However this will be tricky in our current
arcane intl setup.

4.  The city-spot message is shown only when a unit is moved.  This is
wrong inasmuch as we want it to be shown when the unit activates. 
However the latter is quite problematic.  Not only do we not have a
signal for it, but making a signal will be tricky or impossible because
focusing is generally done entirely by the client.  However I worked
around this just by taking it into account in the message.

5.  Note that the check for good-city-spot is rather inferior.  It
should check for other tile combinations, and (even more importantly)
not show for tiles right next to other cities or those that aren't valid
city spots, and (even more importantly) use a global variable to limit
the number of times it is shown (probably to 3 *per player* or so).

-jason

? diff
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.129
diff -u -r1.129 options.c
--- client/options.c    5 May 2005 18:32:46 -0000       1.129
+++ client/options.c    10 May 2005 01:37:54 -0000
@@ -332,6 +332,7 @@
   GEN_EV(N_("Enemy Diplomat: Poison"),              E_ENEMY_DIPLOMAT_POISON),
   GEN_EV(N_("Enemy Diplomat: Sabotage"),            E_ENEMY_DIPLOMAT_SABOTAGE),
   GEN_EV(N_("Enemy Diplomat: Theft"),               E_ENEMY_DIPLOMAT_THEFT),
+  GEN_EV(N_("Tutorial message"), E_TUTORIAL),
   GEN_EV(N_("Broadcast Report"),                E_BROADCAST_REPORT),
   GEN_EV(N_("Game Ended"),                      E_GAME_END),
   GEN_EV(N_("Game Started"),                    E_GAME_START),
@@ -439,7 +440,7 @@
                     E_NATION_SELECTED, E_CITY_BUILD, E_NEXT_YEAR,
                     E_CITY_PRODUCTION_CHANGED,
                     E_CITY_MAY_SOON_GROW, E_WORKLIST};
-  int all[] = { E_MESSAGE_WALL };
+  int all[] = { E_MESSAGE_WALL, E_TUTORIAL };
   int i;
 
   for(i=0; i<E_LAST; i++) {
Index: common/events.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/events.h,v
retrieving revision 1.27
diff -u -r1.27 events.h
--- common/events.h     6 Mar 2004 11:13:05 -0000       1.27
+++ common/events.h     10 May 2005 01:37:55 -0000
@@ -58,6 +58,7 @@
   E_ENEMY_DIPLOMAT_POISON,
   E_ENEMY_DIPLOMAT_SABOTAGE,
   E_ENEMY_DIPLOMAT_THEFT,
+  E_TUTORIAL,
   E_BROADCAST_REPORT,
   E_GAME_END,
   E_GAME_START,
Index: data/scenario/Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/data/scenario/Makefile.am,v
retrieving revision 1.6
diff -u -r1.6 Makefile.am
--- data/scenario/Makefile.am   2 Feb 2005 02:40:16 -0000       1.6
+++ data/scenario/Makefile.am   10 May 2005 01:37:55 -0000
@@ -6,7 +6,8 @@
        earth-80x50-v2.sav.gz                   \
        europe-200x100-v2.sav.gz                \
        hagworld-120x60-v1.2.sav.gz             \
-       iberian-peninsula-136x100-v1.0.sav.gz
+       iberian-peninsula-136x100-v1.0.sav.gz   \
+       tutorial.sav.gz
 
 unzipped_files =                               \
        british-isles-85x80-v2.80.sav           \
@@ -14,7 +15,8 @@
        earth-80x50-v2.sav                      \
        europe-200x100-v2.sav                   \
        hagworld-120x60-v1.2.sav                \
-       iberian-peninsula-136x100-v1.0.sav
+       iberian-peninsula-136x100-v1.0.sav      \
+       tutorial.sav
 
 
 ## Override automake so that "make install" puts these in proper place:
Index: data/scenario/tutorial.sav
===================================================================
RCS file: data/scenario/tutorial.sav
diff -N data/scenario/tutorial.sav
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ data/scenario/tutorial.sav  10 May 2005 01:37:55 -0000
@@ -0,0 +1,140 @@
+[script]
+code="
+function turn_callback(turn, year)
+  if turn == 0 then
+    notify.event(nil, nil, E.TUTORIAL,
+_('Welcome to Freeciv.  You lead a civilization.  Your\\n\
+task is to conquer the world!  You should start by\\n\
+exploring the land around you with your explorers,\\n\
+and using your settlers to find a good place to build\\n\
+a city.'))
+  end
+end
+signal.connect('turn_started', 'turn_callback')
+
+function unit_moved_callback(unit, src_tile, dst_tile)
+  if unit:type().name == 'Settlers'
+    and (dst_tile:terrain().name == 'Grassland'
+         or dst_tile:terrain().name == 'Plains') then  
+    notify.event(unit:owner(), dst_tile, E.TUTORIAL,
+_('This looks like a good place to build a city.  The next time this\\n\
+unit gets a chance to move, press (b) to found a city.'))
+  end
+end
+signal.connect('unit_moved', 'unit_moved_callback')
+
+print 'Loading scenario events.'
+"
+
+[game]
+version=20099
+server_state=0
+metapatches=""
+metatopic=""
+metamessage=""
+metaserver="http://meta.freeciv.org/metaserver.phtml";
+gold=50
+tech=0
+skill_level=3
+timeout=0
+timeoutint=0
+timeoutintinc=0
+timeoutinc=0
+timeoutincmult=1
+timeoutcounter=1
+info.timeoutaddenemymove=0
+end_year=2000
+year=-4000
+turn=0
+simultaneous_phases_now=0
+simultaneous_phases_stored=1
+researchcost=20
+min_players=1
+max_players=30
+nplayers=0
+heating=0
+globalwarming=0
+warminglevel=0
+nuclearwinter=0
+cooling=0
+coolinglevel=0
+notradesize=0
+fulltradesize=1
+unhappysize=4
+angrycitizen=1
+cityfactor=14
+citymindist=0
+civilwarsize=10
+contactturns=20
+rapturedelay=1
+diplcost=0
+freecost=0
+conquercost=0
+foodbox=10
+techpenalty=100
+razechance=20
+civstyle=2
+save_nturns=10
+save_name="civgame"
+aifill=3
+; Should set "novice" as well.
+scorelog=0
+id=""
+fogofwar=1
+spacerace=1
+auto_ai_toggle=0
+diplchance=80
+aqueductloss=0
+killcitizen=1
+turnblock=1
+savepalace=1
+fixedlength=0
+barbarians=2
+onsetbarbs=-2000
+revolen=0
+occupychance=0
+autoattack=0
+demography="NASRLPEMOqrb"
+borders=7
+happyborders=1
+diplomacy=0
+watchtower_vision=0
+watchtower_extra_vision=2
+allowed_city_names=1
+settlers=2
+explorer=1
+start_units="cx"
+dispersion=0
+randseed=0
+save_random=0
+rulesetdir="default"
+
+[savefile]
+options="startoptions spacerace2 rulesets diplchance_percent worklists2 
map_editor known32fix turn attributes watchtower rulesetdir client_worklists 
orders startunits turn_last_built improvement_order technology_order embassies"
+reason="User request"
+improvement_order="Airport", "Aqueduct", "Bank", "Barracks", "Barracks II", 
"Barracks III", "Cathedral", "City Walls", "Coastal Defense", "Colosseum", 
"Courthouse", "Factory", "Granary", "Harbour", "Hydro Plant", "Library", 
"Marketplace", "Mass Transit", "Mfg. Plant", "Nuclear Plant", "Offshore 
Platform", "Palace", "Police Station", "Port Facility", "Power Plant", 
"Recycling Center", "Research Lab", "SAM Battery", "SDI Defense", "Sewer 
System", "Space Component", "Space Module", "Space Structural", "Stock 
Exchange", "Super Highways", "Supermarket", "Temple", "University", "Apollo 
Program", "A.Smith's Trading Co.", "Colossus", "Copernicus' Observatory", "Cure 
For Cancer", "Darwin's Voyage", "Eiffel Tower", "Great Library", "Great Wall", 
"Hanging Gardens", "Hoover Dam", "Isaac Newton's College", "J.S. Bach's 
Cathedral", "King Richard's Crusade", "Leonardo's Workshop", "Lighthouse", 
"Magellan's Expedition", "Manhattan Project", "Marco Polo's Embassy", 
"Michelangelo's Chapel", "Oracle", "Pyramids", "SETI Program", "Shakespeare's 
Theatre", "Statue of Liberty", "Sun Tzu's War Academy", "United Nations", 
"Women's Suffrage", "Coinage"
+technology_order="A_NONE", "Advanced Flight", "Alphabet", "Amphibious 
Warfare", "Astronomy", "Atomic Theory", "Automobile", "Banking", "Bridge 
Building", "Bronze Working", "Ceremonial Burial", "Chemistry", "Chivalry", 
"Code of Laws", "Combined Arms", "Combustion", "Communism", "Computers", 
"Conscription", "Construction", "Currency", "Democracy", "Economics", 
"Electricity", "Electronics", "Engineering", "Environmentalism", "Espionage", 
"Explosives", "Feudalism", "Flight", "Fundamentalism", "Fusion Power", "Genetic 
Engineering", "Guerilla Warfare", "Gunpowder", "Horseback Riding", 
"Industrialization", "Invention", "Iron Working", "Labor Union", "Laser", 
"Leadership", "Literacy", "Machine Tools", "Magnetism", "Map Making", 
"Masonry", "Mass Production", "Mathematics", "Medicine", "Metallurgy", 
"Miniaturization", "Mobile Warfare", "Monarchy", "Monotheism", "Mysticism", 
"Navigation", "Nuclear Fission", "Nuclear Power", "Philosophy", "Physics", 
"Plastics", "Polytheism", "Pottery", "Radio", "Railroad", "Recycling", 
"Refining", "Refrigeration", "Robotics", "Rocketry", "Sanitation", "Seafaring", 
"Space Flight", "Stealth", "Steam Engine", "Steel", "Superconductors", 
"Tactics", "The Corporation", "The Republic", "The Wheel", "Theology", "Theory 
of Gravity", "Trade", "University", "Warrior Code", "Writing"
+
+[map]
+mountains=30
+grass=35
+swampsize=5
+deserts=5
+riverlength=5
+forestsize=20
+topology_id=1
+size=4
+width=8
+height=8
+seed=0
+landpercent=30
+riches=250
+wetness=50
+steepness=30
+huts=50
+generator=1
+have_huts=0
+temperature=50
+alltemperate=0
+tinyisles=0
+separatepoles=1
Index: po/POTFILES.in
===================================================================
RCS file: /home/freeciv/CVS/freeciv/po/POTFILES.in,v
retrieving revision 1.90
diff -u -r1.90 POTFILES.in
--- po/POTFILES.in      9 May 2005 16:48:10 -0000       1.90
+++ po/POTFILES.in      10 May 2005 01:37:55 -0000
@@ -283,3 +283,4 @@
 data/nation/viking.ruleset
 data/nation/welsh.ruleset
 data/nation/zulu.ruleset
+data/scenario/tutorial.sav
Index: server/scripting/api.pkg
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/scripting/api.pkg,v
retrieving revision 1.4
diff -u -r1.4 api.pkg
--- server/scripting/api.pkg    10 May 2005 00:35:15 -0000      1.4
+++ server/scripting/api.pkg    10 May 2005 01:37:55 -0000
@@ -245,6 +245,7 @@
     E_ENEMY_DIPLOMAT_POISON @ ENEMY_DIPLOMAT_POISON,
     E_ENEMY_DIPLOMAT_SABOTAGE @ ENEMY_DIPLOMAT_SABOTAGE,
     E_ENEMY_DIPLOMAT_THEFT @ ENEMY_DIPLOMAT_THEFT,
+    E_TUTORIAL @ TUTORIAL,
     E_BROADCAST_REPORT @ BROADCAST_REPORT,
     E_GAME_END @ GAME_END,
     E_GAME_START @ GAME_START,

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