adonthell-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[adonthell-wastesedge-commits] EXP_PYTHON 7d40ec2: Added the experimenta


From: Kai Sterker
Subject: [adonthell-wastesedge-commits] EXP_PYTHON 7d40ec2: Added the experimental scripts
Date: Mon, 25 Jul 2016 18:16:35 +0000 (UTC)

branch: EXP_PYTHON
commit 7d40ec2c7fc9e31de0da8c405d900d19e4f2b926
Author: adondev <adondev>
Commit: adondev <adondev>

    Added the experimental scripts
---
 scripts/events/1st_to_2nd.py           |   14 +--
 scripts/events/1st_to_fellnir.py       |   11 +-
 scripts/events/1st_to_frostbloom.py    |   13 +-
 scripts/events/1st_to_player.py        |   11 +-
 scripts/events/1st_to_silverhair.py    |   33 ++---
 scripts/events/2nd_to_illig.py         |   11 +-
 scripts/events/2nd_to_oliver.py        |   12 +-
 scripts/events/2nd_to_redwyne.py       |   12 +-
 scripts/events/action_alch_table.py    |    3 +-
 scripts/events/action_clock.py         |    3 +-
 scripts/events/barn_to_cellar.py       |   14 +--
 scripts/events/cellar_to_alek.py       |   12 +-
 scripts/events/cellar_to_bath.py       |   12 +-
 scripts/events/cellar_to_dwarfs.py     |   26 ++--
 scripts/events/cellar_to_storage.py    |   12 +-
 scripts/events/common_to_1st.py        |   14 +--
 scripts/events/common_to_cellar.py     |   14 +--
 scripts/events/common_to_kitchen.py    |   14 +--
 scripts/events/common_to_parlor.py     |   14 +--
 scripts/events/guards_ground_to_1st.py |   13 +-
 scripts/events/inn_to_yard.py          |   19 +--
 scripts/events/kitchen_to_cellar.py    |   14 +--
 scripts/events/open_inn_door.py        |    3 +-
 scripts/events/yard_to_guards.py       |   13 +-
 scripts/events/yard_to_kitchen.py      |   14 +--
 scripts/init.py                        |    2 +-
 scripts/schedules/action_talk.py       |   36 +++---
 scripts/schedules/alek.py              |   91 +++++++-------
 scripts/schedules/center_player.py     |    5 +-
 scripts/schedules/erek.py              |  173 +++++++++++++-------------
 scripts/schedules/frostbloom.py        |   96 ++++++++-------
 scripts/schedules/janesta.py           |   93 +++++++-------
 scripts/schedules/jelom.py             |   86 ++++++-------
 scripts/schedules/keyboard_control.py  |  210 ++++++++++++++++----------------
 scripts/schedules/oliver.py            |  181 +++++++++++++--------------
 scripts/schedules/orloth.py            |  188 ++++++++++++++--------------
 scripts/schedules/random_move.py       |   15 +--
 scripts/schedules/sarin.py             |  175 +++++++++++++-------------
 scripts/schedules/silverhair.py        |   88 ++++++-------
 scripts/schedules/talan.py             |   86 ++++++-------
 40 files changed, 944 insertions(+), 912 deletions(-)

diff --git a/scripts/events/1st_to_2nd.py b/scripts/events/1st_to_2nd.py
index 8252ea3..abd5cc6 100755
--- a/scripts/events/1st_to_2nd.py
+++ b/scripts/events/1st_to_2nd.py
@@ -1,8 +1,8 @@
-mychar = characters [name]
-
-# 1st floor to 2nd floor
-if mychar.submap() == 9:
-    events.switch_submap (mychar, 14, 4, 2, STAND_SOUTH)
-else:
-    events.switch_submap (mychar, 9, 6, 2, STAND_SOUTH)
+def run ():
+    mychar = characters [name]
 
+    # -- 1st floor to 2nd floor
+    if mychar.submap() == 9:
+        events.switch_submap (mychar, 14, 4, 2, STAND_SOUTH)
+    else:
+        events.switch_submap (mychar, 9, 6, 2, STAND_SOUTH)
diff --git a/scripts/events/1st_to_fellnir.py b/scripts/events/1st_to_fellnir.py
index 4a19fa8..03788a3 100755
--- a/scripts/events/1st_to_fellnir.py
+++ b/scripts/events/1st_to_fellnir.py
@@ -1,7 +1,8 @@
-p = characters [name]
+def run ():
+    p = characters [name]
 
-if p.submap () == 9:
-  events.switch_submap (p, 10, 1, 3, STAND_EAST)
-else:
-  events.switch_submap (p, 9, 8, 2, STAND_WEST)
+    if p.submap () == 9:
+        events.switch_submap (p, 10, 1, 3, STAND_EAST)
+    else:
+        events.switch_submap (p, 9, 8, 2, STAND_WEST)
 
diff --git a/scripts/events/1st_to_frostbloom.py 
b/scripts/events/1st_to_frostbloom.py
index 7292261..15e89b3 100755
--- a/scripts/events/1st_to_frostbloom.py
+++ b/scripts/events/1st_to_frostbloom.py
@@ -1,8 +1,7 @@
-p = characters [name]
-
-if p.submap () == 9:
-  events.switch_submap (p, 11, 4, 3, STAND_WEST)
-else:
-  events.switch_submap (p, 9, 1, 2, STAND_EAST)
-
+def run ():
+    p = characters [name]
 
+    if p.submap () == 9:
+      events.switch_submap (p, 11, 4, 3, STAND_WEST)
+    else:
+      events.switch_submap (p, 9, 1, 2, STAND_EAST)
diff --git a/scripts/events/1st_to_player.py b/scripts/events/1st_to_player.py
index 74885af..15d5ff3 100755
--- a/scripts/events/1st_to_player.py
+++ b/scripts/events/1st_to_player.py
@@ -1,7 +1,8 @@
-p = characters [name]
+def run():
+    p = characters [name]
 
-if p.submap () == 9:
-  events.switch_submap (p, 12, 5, 2, STAND_SOUTH)
-else:
-  events.switch_submap (p, 9, 7, 3, STAND_NORTH)
+    if p.submap () == 9:
+      events.switch_submap (p, 12, 5, 2, STAND_SOUTH)
+    else:
+      events.switch_submap (p, 9, 7, 3, STAND_NORTH)
 
diff --git a/scripts/events/1st_to_silverhair.py 
b/scripts/events/1st_to_silverhair.py
index d57200d..b5e1037 100755
--- a/scripts/events/1st_to_silverhair.py
+++ b/scripts/events/1st_to_silverhair.py
@@ -1,20 +1,21 @@
-p = characters [name]
+def run ():
+    p = characters [name]
 
-if p.submap () == 9:
-    # -- bjarn's door closed
-    free = quests["demo"].get_val("silverhair_free")
+    if p.submap () == 9:
+        # -- bjarn's door closed
+        free = quests["demo"].get_val("silverhair_free")
 
-    # -- Jelom not convinced of Silverhair's innocence
-    if not free and p == the_player:
-        # -- we only need that for the dialogue, ...
-        p.set_val ("at_silverhairs_door", 1)
-        p.stand ()
-        p.go_north ()
-        characters["Jelom Rasgar"].launch_action (p)
-        # -- ... so remove it again afterwards
-        p.set_val ("at_silverhairs_door", 0)
+        # -- Jelom not convinced of Silverhair's innocence
+        if not free and p == the_player:
+            # -- we only need that for the dialogue, ...
+            p.set_val ("at_silverhairs_door", 1)
+            p.stand ()
+            p.go_north ()
+            characters["Jelom Rasgar"].launch_action (p)
+            # -- ... so remove it again afterwards
+            p.set_val ("at_silverhairs_door", 0)
+        else:
+            events.switch_submap (p, 13, 5, 2, STAND_SOUTH)
     else:
-        events.switch_submap (p, 13, 5, 2, STAND_SOUTH)
-else:
-    events.switch_submap (p, 9, 1, 6, STAND_NORTH)
+        events.switch_submap (p, 9, 1, 6, STAND_NORTH)
 
diff --git a/scripts/events/2nd_to_illig.py b/scripts/events/2nd_to_illig.py
index e25486f..40691c2 100755
--- a/scripts/events/2nd_to_illig.py
+++ b/scripts/events/2nd_to_illig.py
@@ -1,7 +1,8 @@
-p = characters [name]
+def run ():
+    p = characters [name]
 
-if p.submap () == 14:
-  events.switch_submap (p, 17, 6, 2, STAND_SOUTH)
-else:
-  events.switch_submap (p, 14, 1, 7, STAND_NORTH)
+    if p.submap () == 14:
+      events.switch_submap (p, 17, 6, 2, STAND_SOUTH)
+    else:
+      events.switch_submap (p, 14, 1, 7, STAND_NORTH)
 
diff --git a/scripts/events/2nd_to_oliver.py b/scripts/events/2nd_to_oliver.py
index eb374bb..4863971 100755
--- a/scripts/events/2nd_to_oliver.py
+++ b/scripts/events/2nd_to_oliver.py
@@ -1,7 +1,7 @@
-p = characters [name]
-
-if p.submap () == 14:
-  events.switch_submap (p, 16, 6, 5, STAND_WEST)
-else:
-  events.switch_submap (p, 14, 1, 5, STAND_EAST)
+def run ():
+    p = characters [name]
 
+    if p.submap () == 14:
+      events.switch_submap (p, 16, 6, 5, STAND_WEST)
+    else:
+      events.switch_submap (p, 14, 1, 5, STAND_EAST)
diff --git a/scripts/events/2nd_to_redwyne.py b/scripts/events/2nd_to_redwyne.py
index 7bdf1bc..4a0d086 100755
--- a/scripts/events/2nd_to_redwyne.py
+++ b/scripts/events/2nd_to_redwyne.py
@@ -1,7 +1,7 @@
-p = characters [name]
-
-if p.submap () == 14:
-  events.switch_submap (p, 15, 1, 5, STAND_EAST)
-else:
-  events.switch_submap (p, 14, 2, 5, STAND_WEST)
+def run ():
+    p = characters [name]
 
+    if p.submap () == 14:
+      events.switch_submap (p, 15, 1, 5, STAND_EAST)
+    else:
+      events.switch_submap (p, 14, 2, 5, STAND_WEST)
diff --git a/scripts/events/action_alch_table.py 
b/scripts/events/action_alch_table.py
index 8468e03..5cef48a 100644
--- a/scripts/events/action_alch_table.py
+++ b/scripts/events/action_alch_table.py
@@ -1 +1,2 @@
-the_player.speak ("I'd better not touch this... What if it explodes??")
+def run ():
+    the_player.speak ("I'd better not touch this... What if it explodes??")
diff --git a/scripts/events/action_clock.py b/scripts/events/action_clock.py
index 9e5169b..f632e69 100644
--- a/scripts/events/action_clock.py
+++ b/scripts/events/action_clock.py
@@ -1 +1,2 @@
-the_player.speak ("That clock seems to be late!")
+def run ():
+    the_player.speak ("That clock seems to be late!")
diff --git a/scripts/events/barn_to_cellar.py b/scripts/events/barn_to_cellar.py
index 71fd454..64068d9 100755
--- a/scripts/events/barn_to_cellar.py
+++ b/scripts/events/barn_to_cellar.py
@@ -1,8 +1,8 @@
-mychar = characters [name]
-
-# Barn to cellar
-if mychar.submap() == 0:
-    events.switch_submap (mychar, 4, 12, 2, STAND_SOUTH)
-else:
-    events.switch_submap (mychar, 0, 24, 11, STAND_SOUTH)
+def run ():
+    mychar = characters [name]
 
+    # Barn to cellar
+    if mychar.submap() == 0:
+        events.switch_submap (mychar, 4, 12, 2, STAND_SOUTH)
+    else:
+        events.switch_submap (mychar, 0, 24, 11, STAND_SOUTH)
diff --git a/scripts/events/cellar_to_alek.py b/scripts/events/cellar_to_alek.py
index 10e3408..0354f21 100755
--- a/scripts/events/cellar_to_alek.py
+++ b/scripts/events/cellar_to_alek.py
@@ -1,7 +1,7 @@
-p = characters [name]
-
-if p.submap () == 4:
-  events.switch_submap (p, 6, 5, 6 + (p.posy () - 6), STAND_WEST)
-else:
-  events.switch_submap (p, 4, 1, 6 + (p.posy () - 6), STAND_EAST)
+def run ():
+    p = characters [name]
 
+    if p.submap () == 4:
+      events.switch_submap (p, 6, 5, 6 + (p.posy () - 6), STAND_WEST)
+    else:
+      events.switch_submap (p, 4, 1, 6 + (p.posy () - 6), STAND_EAST)
diff --git a/scripts/events/cellar_to_bath.py b/scripts/events/cellar_to_bath.py
index e77f371..4aa13b7 100755
--- a/scripts/events/cellar_to_bath.py
+++ b/scripts/events/cellar_to_bath.py
@@ -1,7 +1,7 @@
-p = characters [name]
-
-if p.submap () == 4:
-  events.switch_submap (p, 5, 4, 6, STAND_NORTH)
-else:
-  events.switch_submap (p, 4, 3, 6, STAND_SOUTH)
+def run ():
+    p = characters [name]
 
+    if p.submap () == 4:
+        events.switch_submap (p, 5, 4, 6, STAND_NORTH)
+    else:
+        events.switch_submap (p, 4, 3, 6, STAND_SOUTH)
diff --git a/scripts/events/cellar_to_dwarfs.py 
b/scripts/events/cellar_to_dwarfs.py
index 2c180af..1c9e653 100755
--- a/scripts/events/cellar_to_dwarfs.py
+++ b/scripts/events/cellar_to_dwarfs.py
@@ -1,15 +1,15 @@
-p = characters [name]
+def run ():
+    p = characters [name]
 
-if p.submap () == 4:
-    # -- bjarn's door closed
-    open = quests["demo"].get_val("bjarn_door_open")
-    if open == 0 or open == 1:
-        if p == the_player:
-            characters["Bjarn Fingolson"].launch_action (p)
-            p.stand ()
-            p.go_west ()
+    if p.submap () == 4:
+        # -- bjarn's door closed
+        open = quests["demo"].get_val("bjarn_door_open")
+        if open == 0 or open == 1:
+            if p == the_player:
+                characters["Bjarn Fingolson"].launch_action (p)
+                p.stand ()
+                p.go_west ()
+        else:
+            events.switch_submap (p, 7, 1, 6 + (p.posy () - 6), STAND_EAST)
     else:
-        events.switch_submap (p, 7, 1, 6 + (p.posy () - 6), STAND_EAST)
-else:
-    events.switch_submap (p, 4, 9, 6 + (p.posy () - 6), STAND_WEST)
-
+        events.switch_submap (p, 4, 9, 6 + (p.posy () - 6), STAND_WEST)
diff --git a/scripts/events/cellar_to_storage.py 
b/scripts/events/cellar_to_storage.py
index 6b9c7ad..af24e4e 100755
--- a/scripts/events/cellar_to_storage.py
+++ b/scripts/events/cellar_to_storage.py
@@ -1,7 +1,7 @@
-p = characters [name]
-
-if p.submap () == 4:
-  events.switch_submap (p, 8, 6, 3 + (p.posy () - 9), STAND_WEST)
-else:
-  events.switch_submap (p, 4, 1, 9 + (p.posy () - 3), STAND_EAST)
+def run ():
+    p = characters [name]
 
+    if p.submap () == 4:
+      events.switch_submap (p, 8, 6, 3 + (p.posy () - 9), STAND_WEST)
+    else:
+      events.switch_submap (p, 4, 1, 9 + (p.posy () - 3), STAND_EAST)
diff --git a/scripts/events/common_to_1st.py b/scripts/events/common_to_1st.py
index d02449c..a403d81 100755
--- a/scripts/events/common_to_1st.py
+++ b/scripts/events/common_to_1st.py
@@ -1,8 +1,8 @@
-mychar = characters [name]
-
-# Common room to 1st floor
-if mychar.submap() == 1:
-    events.switch_submap (mychar, 9, 8, 2, STAND_SOUTH)
-else:
-    events.switch_submap (mychar, 1, 12, 2, STAND_SOUTH)
+def run ():
+    mychar = characters [name]
 
+    # Common room to 1st floor
+    if mychar.submap() == 1:
+        events.switch_submap (mychar, 9, 8, 2, STAND_SOUTH)
+    else:
+        events.switch_submap (mychar, 1, 12, 2, STAND_SOUTH)
diff --git a/scripts/events/common_to_cellar.py 
b/scripts/events/common_to_cellar.py
index 822d313..74bddb9 100755
--- a/scripts/events/common_to_cellar.py
+++ b/scripts/events/common_to_cellar.py
@@ -1,8 +1,8 @@
-mychar = characters [name]
-
-# Common room to cellar
-if mychar.submap() == 1:
-    events.switch_submap (mychar, 4, 6, 2, STAND_SOUTH)
-else:
-    events.switch_submap (mychar, 1, 9, 2, STAND_SOUTH)
+def run ():
+    mychar = characters [name]
 
+    # Common room to cellar
+    if mychar.submap() == 1:
+        events.switch_submap (mychar, 4, 6, 2, STAND_SOUTH)
+    else:
+        events.switch_submap (mychar, 1, 9, 2, STAND_SOUTH)
diff --git a/scripts/events/common_to_kitchen.py 
b/scripts/events/common_to_kitchen.py
index 139e1bb..5ba3352 100755
--- a/scripts/events/common_to_kitchen.py
+++ b/scripts/events/common_to_kitchen.py
@@ -1,8 +1,8 @@
-mychar = characters [name]
-
-# Common room to Kitchen
-if mychar.submap() == 1:
-    events.switch_submap (mychar, 3, 1, 2, STAND_SOUTH)
-else:
-    events.switch_submap (mychar, 1, 1, 7, STAND_NORTH)
+def run ():
+    mychar = characters [name]
 
+    # Common room to Kitchen
+    if mychar.submap() == 1:
+        events.switch_submap (mychar, 3, 1, 2, STAND_SOUTH)
+    else:
+        events.switch_submap (mychar, 1, 1, 7, STAND_NORTH)
diff --git a/scripts/events/common_to_parlor.py 
b/scripts/events/common_to_parlor.py
index b2b32a1..b5219d3 100755
--- a/scripts/events/common_to_parlor.py
+++ b/scripts/events/common_to_parlor.py
@@ -1,8 +1,8 @@
-mychar = characters [name]
-
-# -- From Common Room to Parlour
-if mychar.submap () == 1:
-    events.switch_submap (mychar, 2, 1, 4, STAND_EAST)
-else:
-    events.switch_submap (mychar, 1, 13, 4, STAND_WEST)
+def run ():
+    mychar = characters [name]
 
+    # -- From Common Room to Parlour
+    if mychar.submap () == 1:
+        events.switch_submap (mychar, 2, 1, 4, STAND_EAST)
+    else:
+        events.switch_submap (mychar, 1, 13, 4, STAND_WEST)
diff --git a/scripts/events/guards_ground_to_1st.py 
b/scripts/events/guards_ground_to_1st.py
index 62e04c8..38079c8 100644
--- a/scripts/events/guards_ground_to_1st.py
+++ b/scripts/events/guards_ground_to_1st.py
@@ -1,7 +1,8 @@
-mychar = characters [name]
+def run ():
+    mychar = characters [name]
 
-# -- From Guards ground to 1st floor
-if mychar.submap () == 18:
-    events.switch_submap (mychar, 19, 2, 8, STAND_EAST)
-else:
-    events.switch_submap (mychar, 18, 2, 8, STAND_EAST)
+    # -- From Guards ground to 1st floor
+    if mychar.submap () == 18:
+        events.switch_submap (mychar, 19, 2, 8, STAND_EAST)
+    else:
+        events.switch_submap (mychar, 18, 2, 8, STAND_EAST)
diff --git a/scripts/events/inn_to_yard.py b/scripts/events/inn_to_yard.py
index 287a465..839de2d 100755
--- a/scripts/events/inn_to_yard.py
+++ b/scripts/events/inn_to_yard.py
@@ -1,11 +1,12 @@
-mychar = characters [name]
+def run ():
+    mychar = characters [name]
 
-# Close the inn door.
-if mychar.submap () == 0:
-    map_engine.get_landmap ().get_mapobject (0).get_animation (0).next_frame ()
+    # -- Close the inn door.
+    if mychar.submap () == 0:
+        map_engine.get_landmap ().get_mapobject (0).get_animation 
(0).next_frame ()
 
-# -- From Common Room to Yard
-if mychar.submap () == 1:
-    events.switch_submap (mychar, 0, 18, 14, STAND_SOUTH)
-else:
-    events.switch_submap (mychar, 1, 13, 7, STAND_NORTH)
+    # -- From Common Room to Yard
+    if mychar.submap () == 1:
+        events.switch_submap (mychar, 0, 18, 14, STAND_SOUTH)
+    else:
+        events.switch_submap (mychar, 1, 13, 7, STAND_NORTH)
diff --git a/scripts/events/kitchen_to_cellar.py 
b/scripts/events/kitchen_to_cellar.py
index a6e276d..649731f 100755
--- a/scripts/events/kitchen_to_cellar.py
+++ b/scripts/events/kitchen_to_cellar.py
@@ -1,8 +1,8 @@
-mychar = characters [name]
-
-# Kitchen to cellar
-if mychar.submap() == 3:
-    events.switch_submap (mychar, 4, 3, 12, STAND_NORTH)
-else:
-    events.switch_submap (mychar, 3, 6, 5, STAND_NORTH)
+def run ():
+    mychar = characters [name]
 
+    # Kitchen to cellar
+    if mychar.submap() == 3:
+        events.switch_submap (mychar, 4, 3, 12, STAND_NORTH)
+    else:
+        events.switch_submap (mychar, 3, 6, 5, STAND_NORTH)
diff --git a/scripts/events/open_inn_door.py b/scripts/events/open_inn_door.py
index c3533b9..62af06b 100755
--- a/scripts/events/open_inn_door.py
+++ b/scripts/events/open_inn_door.py
@@ -1 +1,2 @@
-map_engine.get_landmap ().get_mapobject (0).get_animation (0).next_frame ()
+def run ():
+    map_engine.get_landmap ().get_mapobject (0).get_animation (0).next_frame ()
diff --git a/scripts/events/yard_to_guards.py b/scripts/events/yard_to_guards.py
index 4f1ac1e..f7b62d3 100644
--- a/scripts/events/yard_to_guards.py
+++ b/scripts/events/yard_to_guards.py
@@ -1,7 +1,8 @@
-mychar = characters [name]
+def run ():
+    mychar = characters [name]
 
-# -- From Yard to Guards house
-if mychar.submap () == 0:
-    events.switch_submap (mychar, 18, 7, 3, STAND_WEST)
-else:
-    events.switch_submap (mychar, 0, 13, 23, STAND_EAST)
+    # -- From Yard to Guards house
+    if mychar.submap () == 0:
+        events.switch_submap (mychar, 18, 7, 3, STAND_WEST)
+    else:
+        events.switch_submap (mychar, 0, 13, 23, STAND_EAST)
diff --git a/scripts/events/yard_to_kitchen.py 
b/scripts/events/yard_to_kitchen.py
index 63caaa5..0986e51 100755
--- a/scripts/events/yard_to_kitchen.py
+++ b/scripts/events/yard_to_kitchen.py
@@ -1,8 +1,8 @@
-mychar = characters [name]
-
-# -- From Yard to Kitchen
-if mychar.submap () == 0:
-    events.switch_submap (mychar, 3, 6, 3, STAND_WEST)
-else:
-    events.switch_submap (mychar, 0, 12, 14, STAND_EAST)
+def run ():
+    mychar = characters [name]
 
+    # -- From Yard to Kitchen
+    if mychar.submap () == 0:
+        events.switch_submap (mychar, 3, 6, 3, STAND_WEST)
+    else:
+        events.switch_submap (mychar, 0, 12, 14, STAND_EAST)
diff --git a/scripts/init.py b/scripts/init.py
index 66a1be9..290cb2b 100755
--- a/scripts/init.py
+++ b/scripts/init.py
@@ -766,4 +766,4 @@ if retval < 5:
 
     audio_play_background (1)
     gametime_update ()
-    map_engine.run()
+    map_engine.run ()
diff --git a/scripts/schedules/action_talk.py b/scripts/schedules/action_talk.py
index beea28d..e322c5c 100755
--- a/scripts/schedules/action_talk.py
+++ b/scripts/schedules/action_talk.py
@@ -3,27 +3,27 @@ def restore_schedule (retval, args):
     args[0].set_schedule_active (1)
     args[1].set_schedule_active (1)
 
-if requester.get_name()==the_player.get_name():
-    # -- deactivate the schedule of the characters involved
-    myself.set_schedule_active (0)
-    requester.set_schedule_active (0)
+def run ():
+    if requester.get_name()==the_player.get_name():
+        # -- deactivate the schedule of the characters involved
+        myself.set_schedule_active (0)
+        requester.set_schedule_active (0)
 
-    # -- look into the player's face
-    myself.look_invert(requester.currentmove())
+        # -- look into the player's face
+        myself.look_invert(requester.currentmove())
 
-    # -- init the dialogue engine
-    dlg = dialog_engine (myself, myself.get_dialogue (), 0)
-    
-    # -- make sure the engine isn't deleted when we leave the script
-    dlg.thisown = 0
+        # -- init the dialogue engine
+        dlg = dialog_engine (myself, myself.get_dialogue (), 0)
 
-    # -- attach the callback
-    dlg.py_signal_connect (restore_schedule, win_event_CLOSE, (requester, 
myself))
+        # -- make sure the engine isn't deleted when we leave the script
+        dlg.thisown = 0
 
-    # -- add the dialogue window to the win_manager
-    win_manager_add (dlg)
-    win_manager_set_focus (dlg)
+        # -- attach the callback
+        dlg.py_signal_connect (restore_schedule, win_event_CLOSE, (requester, 
myself))
 
-    # -- start the dialogue
-    dlg.run ()
+        # -- add the dialogue window to the win_manager
+        win_manager_add (dlg)
+        win_manager_set_focus (dlg)
 
+        # -- start the dialogue
+        dlg.run ()
diff --git a/scripts/schedules/alek.py b/scripts/schedules/alek.py
index 7389ecc..a0a7aa8 100755
--- a/scripts/schedules/alek.py
+++ b/scripts/schedules/alek.py
@@ -15,46 +15,51 @@
 #    He'll walk between his table and the bar
 
 
-speech = ["More Ale!", \
-          "I'll cut 'em open like ripe fruits.", \
-          "They should sort out this business like real men!"]
-
-todo = myself.get_val ("todo")
-
-# -- waiting
-if todo == 0:
-    delay = myself.get_val ("delay")
-    # If standing delay expired, move around next time
-    if delay == 0:
-        myself.set_val ("todo", 1)
-    else:
-        myself.set_val ("delay", delay - 1)
-
-# -- engage a new movement
-elif todo == 1:
-    # -- walk to table
-    if myself.posx () == 1:
-        myself.set_goal (12, 5, STAND_NORTH)
-    # -- walk to bar
-    else:
-        myself.set_goal (1, 3, STAND_SOUTH)
-
-    myself.set_val ("todo", 2)
-
-# -- moving
-elif todo == 2:
-    if myself.follow_path () == 1:
-        # -- the time we stay at the same place
-        delay = randint (60, 150) * 20
-
-        myself.set_val ("delay", delay)
-        myself.set_val ("todo", 0)
-
-
-# -- utter a random remark
-tmp = myself.get_val ("say_something")
-myself.set_val ("say_something", tmp - 1)
-if tmp == 0:
-    myself.speak (speech[randint (0, 2)])
-    delay = randint (40, 80) * 25
-    myself.set_val ("say_something", delay)
+def init ():
+    speech = ["More Ale!", \
+              "I'll cut 'em open like ripe fruits.", \
+              "They should sort out this business like real men!"]
+    print "*** locals after init:", locals (), "\n"
+
+def run ():
+    print "*** locals:", locals (), "\n"
+
+    todo = myself.get_val ("todo")
+
+    # -- waiting
+    if todo == 0:
+        delay = myself.get_val ("delay")
+        # If standing delay expired, move around next time
+        if delay == 0:
+            myself.set_val ("todo", 1)
+        else:
+            myself.set_val ("delay", delay - 1)
+
+    # -- engage a new movement
+    elif todo == 1:
+        # -- walk to table
+        if myself.posx () == 1:
+            myself.set_goal (12, 5, STAND_NORTH)
+        # -- walk to bar
+        else:
+            myself.set_goal (1, 3, STAND_SOUTH)
+
+        myself.set_val ("todo", 2)
+
+    # -- moving
+    elif todo == 2:
+        if myself.follow_path () == 1:
+            # -- the time we stay at the same place
+            delay = randint (60, 150) * 20
+
+            myself.set_val ("delay", delay)
+            myself.set_val ("todo", 0)
+
+
+    # -- utter a random remark
+    tmp = myself.get_val ("say_something")
+    myself.set_val ("say_something", tmp - 1)
+    if tmp == 0:
+        myself.speak (speech[randint (0, 2)])
+        delay = randint (40, 80) * 25
+        myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/center_player.py 
b/scripts/schedules/center_player.py
index 9caf386..3fe1222 100755
--- a/scripts/schedules/center_player.py
+++ b/scripts/schedules/center_player.py
@@ -1,2 +1,3 @@
-p=the_player
-myself.center_on(p.submap(),p.posx(),p.posy(),p.offx(),p.offy())
+def run ():
+    p=the_player
+    myself.center_on(p.submap(),p.posx(),p.posy(),p.offx(),p.offy())
diff --git a/scripts/schedules/erek.py b/scripts/schedules/erek.py
index 17e45ce..129dc7e 100755
--- a/scripts/schedules/erek.py
+++ b/scripts/schedules/erek.py
@@ -15,106 +15,107 @@
 #    Erek will either be in the parlour or the common room.
 #    He'll also help the player to get into Bjarn's room.
 
+def init ():
+    speech = ["How could they do that to the Master?", \
+              "This place is so much different from home.", \
+              "Who could have taken the gems?"]
+
+    coords = [(5, 5, STAND_NORTH), \
+              (10, 6, STAND_WEST), \
+              (5, 3, STAND_NORTH), \
+              (4, 5, STAND_SOUTH)]
+
+
+def run ():
+    # -- lead the player into bjarn's room
+    if quests["demo"].get_val ("bjarn_door_open") == 2:
+        myself.set_schedule_active (0)
+        # -- start Bjanr's conversation with the player and Erek
+        characters["Bjarn Fingolson"].launch_action (the_player)
+
+    # -- leave cellar again
+    elif myself.get_val ("leave_bjarn") == 1:
+        submap = myself.submap ()
+
+        # -- in Bjarn's room
+        if submap == 7:
+            myself.set_goal (0, 7, STAND_WEST)
+            myself.set_val ("leave_bjarn", 2)
+
+        # -- in the Cellar
+        elif submap == 4:
+            myself.set_goal (6, 1, STAND_NORTH)
+            myself.set_val ("leave_bjarn", 2)
+
+        # -- hopefully in the common room
+        else:
+            myself.set_val ("leave_bjarn", 0)
+            x, y, dir = coords[randint (0, 1)]
+            myself.set_goal (x, y, dir)
 
-speech = ["How could they do that to the Master?", \
-          "This place is so much different from home.", \
-          "Who could have taken the gems?"]
-
-coords = [(5, 5, STAND_NORTH), \
-          (10, 6, STAND_WEST), \
-          (5, 3, STAND_NORTH), \
-          (4, 5, STAND_SOUTH)]
-
-
-# -- lead the player into bjarn's room
-if quests["demo"].get_val ("bjarn_door_open") == 2:
-    myself.set_schedule_active (0)
-    # -- start Bjanr's conversation with the player and Erek
-    characters["Bjarn Fingolson"].launch_action (the_player)
-
-# -- leave cellar again
-elif myself.get_val ("leave_bjarn") == 1:
-    submap = myself.submap ()
-
-    # -- in Bjarn's room
-    if submap == 7:
-        myself.set_goal (0, 7, STAND_WEST)
-        myself.set_val ("leave_bjarn", 2)
-
-    # -- in the Cellar
-    elif submap == 4:
-        myself.set_goal (6, 1, STAND_NORTH)
-        myself.set_val ("leave_bjarn", 2)
-
-    # -- hopefully in the common room
-    else:
-        myself.set_val ("leave_bjarn", 0)
-        x, y, dir = coords[randint (0, 1)]
-        myself.set_goal (x, y, dir)
-
-    myself.set_val ("todo", 2)
-
+        myself.set_val ("todo", 2)
 
-# -- "normal" schedule
-todo = myself.get_val ("todo")
 
-# -- waiting
-if todo == 0:
-    delay = myself.get_val ("delay")
+    # -- "normal" schedule
+    todo = myself.get_val ("todo")
 
-    # If standing delay expired, move around next time
-    if delay == 0:
-        myself.set_val ("todo", 1)
-    else:
-        myself.set_val ("delay", delay - 1)
+    # -- waiting
+    if todo == 0:
+        delay = myself.get_val ("delay")
 
-# -- get movement target
-elif todo == 1:
-    # -- on our way back from bjarn's room
-    if myself.get_val ("leave_bjarn") == 2:
-        myself.set_val ("leave_bjarn", 1)
+        # If standing delay expired, move around next time
+        if delay == 0:
+            myself.set_val ("todo", 1)
+        else:
+            myself.set_val ("delay", delay - 1)
 
-    # -- switch places
-    else:
-        # -- in common room -> goto parlour
-        if myself.submap () == 1:
-            myself.set_goal (14, 4, STAND_EAST)
+    # -- get movement target
+    elif todo == 1:
+        # -- on our way back from bjarn's room
+        if myself.get_val ("leave_bjarn") == 2:
+            myself.set_val ("leave_bjarn", 1)
 
-        # -- in parlour -> goto common room
+        # -- switch places
         else:
-            myself.set_goal (0, 4, STAND_WEST)
+            # -- in common room -> goto parlour
+            if myself.submap () == 1:
+                myself.set_goal (14, 4, STAND_EAST)
 
-    myself.set_val ("todo", 2)
+            # -- in parlour -> goto common room
+            else:
+                myself.set_goal (0, 4, STAND_WEST)
 
-# -- move
-elif todo == 2:
-    if myself.follow_path () == 1:
-        # -- reached common room
-        if myself.submap () == 1 and myself.posx () == 13:
-            x, y, dir = coords[randint (0, 1)]
-            myself.set_goal (x, y, dir)
+        myself.set_val ("todo", 2)
 
-            delay = randint (50, 150) * 20
-            myself.set_val ("delay", delay)
+    # -- move
+    elif todo == 2:
+        if myself.follow_path () == 1:
+            # -- reached common room
+            if myself.submap () == 1 and myself.posx () == 13:
+                x, y, dir = coords[randint (0, 1)]
+                myself.set_goal (x, y, dir)
 
-        # -- reached parlour
-        elif myself.submap () == 2 and myself.posx () == 1:
-            x, y, dir = coords[randint (2, 3)]
-            myself.set_goal (x, y, dir)
+                delay = randint (50, 150) * 20
+                myself.set_val ("delay", delay)
 
-            delay = randint (60, 180) * 30
-            myself.set_val ("delay", delay)
+            # -- reached parlour
+            elif myself.submap () == 2 and myself.posx () == 1:
+                x, y, dir = coords[randint (2, 3)]
+                myself.set_goal (x, y, dir)
 
-        # -- reached our final destination
-        else:
-            myself.set_val ("todo", 0)
+                delay = randint (60, 180) * 30
+                myself.set_val ("delay", delay)
+
+            # -- reached our final destination
+            else:
+                myself.set_val ("todo", 0)
 
 
-# -- do some random babbling
-tmp = myself.get_val ("say_something")
-myself.set_val ("say_something", tmp - 1)
+    # -- do some random babbling
+    tmp = myself.get_val ("say_something")
+    myself.set_val ("say_something", tmp - 1)
 
-if tmp == 0:
-    myself.speak (speech[randint (0, 2)])
-    delay = randint (60, 180) * 15
-    myself.set_val ("say_something", delay)
+    if tmp == 0:
+        myself.speak (speech[randint (0, 2)])
+        delay = randint (60, 180) * 15
+        myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/frostbloom.py b/scripts/schedules/frostbloom.py
index af9099d..cec9a73 100755
--- a/scripts/schedules/frostbloom.py
+++ b/scripts/schedules/frostbloom.py
@@ -14,50 +14,52 @@
 #
 #    She just walks around the tree in the yard
 
-# -- Borders of the area she will stay in
-min_x = 16
-max_x = 24
-min_y = 21
-max_y = 28
-
-speech = ["This tree is so inspiring.", \
-          "I wonder why everybody seems so excited.", \
-          "Do you know a creature more lovely than the yeti?"]
-
-todo = myself.get_val ("todo")
-
-# -- waiting
-if todo == 0:
-    delay = myself.get_val ("delay")
-
-    # If standing delay expired, move around next time
-    if delay == 0:
-        myself.set_val ("todo", 1)
-    else:
-        myself.set_val ("delay", delay - 1)
-
-# -- get movement target
-elif todo == 1:
-    # -- the position we want to reach
-    x = randint (min_x, max_x)
-    y = randint (min_y, max_y)
-
-    myself.set_goal (x, y, NO_MOVE)
-
-    delay = randint (30, 90) * 30
-    myself.set_val ("delay", delay)
-    myself.set_val ("todo", 2)
-
-# -- walk to the new position
-elif todo == 2:
-    if myself.follow_path () == 1:
-        myself.set_val ("todo", 0)
-
-
-# -- utter a random remark
-tmp = myself.get_val ("say_something")
-myself.set_val ("say_something", tmp - 1)
-if tmp == 0:
-    myself.speak (speech[randint (0, 2)])
-    delay = randint (50, 150) * 20
-    myself.set_val ("say_something", delay)
+def init ():
+    # -- Borders of the area she will stay in
+    min_x = 16
+    max_x = 24
+    min_y = 21
+    max_y = 28
+
+    speech = ["This tree is so inspiring.", \
+              "I wonder why everybody seems so excited.", \
+              "Do you know a creature more lovely than the yeti?"]
+
+def run ():
+    todo = myself.get_val ("todo")
+
+    # -- waiting
+    if todo == 0:
+        delay = myself.get_val ("delay")
+
+        # If standing delay expired, move around next time
+        if delay == 0:
+            myself.set_val ("todo", 1)
+        else:
+            myself.set_val ("delay", delay - 1)
+
+    # -- get movement target
+    elif todo == 1:
+        # -- the position we want to reach
+        x = randint (min_x, max_x)
+        y = randint (min_y, max_y)
+
+        myself.set_goal (x, y, NO_MOVE)
+
+        delay = randint (30, 90) * 30
+        myself.set_val ("delay", delay)
+        myself.set_val ("todo", 2)
+
+    # -- walk to the new position
+    elif todo == 2:
+        if myself.follow_path () == 1:
+            myself.set_val ("todo", 0)
+
+
+    # -- utter a random remark
+    tmp = myself.get_val ("say_something")
+    myself.set_val ("say_something", tmp - 1)
+    if tmp == 0:
+        myself.speak (speech[randint (0, 2)])
+        delay = randint (50, 150) * 20
+        myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/janesta.py b/scripts/schedules/janesta.py
index 3cbfa91..bc58598 100644
--- a/scripts/schedules/janesta.py
+++ b/scripts/schedules/janesta.py
@@ -14,49 +14,50 @@
 #
 #    She'll busy herself in Silverhair's room
 
-
-speech = ["Oh, dear. Oh, dear.", \
-          "What will happen to us if they take the Mistress?", \
-          "I must do something about this awful room.", \
-          "Oh, how do they expect us to live decently in a place like this?"]
-
-coords = [(1, 3, STAND_NORTH), \
-          (6, 3, STAND_NORTH), \
-          (1, 5, STAND_SOUTH), \
-          (4, 2, STAND_WEST)]
-
-todo = myself.get_val ("todo")
-
-# -- waiting
-if todo == 0:
-    delay = myself.get_val ("delay")
-    # If standing delay expired, move around next time
-    if delay == 0:
-        myself.set_val ("todo", 1)
-    else:
-        myself.set_val ("delay", delay - 1)
-
-# -- engage a new movement
-elif todo == 1:
-    x, y, dir = coords[randint (0, 3)]
-
-    myself.set_goal (x, y, dir)
-    myself.set_val ("todo", 2)
-
-# -- moving
-elif todo == 2:
-    if myself.follow_path () == 1:
-        # -- the time we stay at the same place
-        delay = randint (20, 60) * 10
-
-        myself.set_val ("delay", delay)
-        myself.set_val ("todo", 0)
-
-
-# -- utter a random remark
-tmp = myself.get_val ("say_something")
-myself.set_val ("say_something", tmp - 1)
-if tmp == 0:
-    myself.speak (speech[randint (0, 3)])
-    delay = randint (50, 75) * 35
-    myself.set_val ("say_something", delay)
+def init ():
+    speech = ["Oh, dear. Oh, dear.", \
+              "What will happen to us if they take the Mistress?", \
+              "I must do something about this awful room.", \
+              "Oh, how do they expect us to live decently in a place like 
this?"]
+
+    coords = [(1, 3, STAND_NORTH), \
+              (6, 3, STAND_NORTH), \
+              (1, 5, STAND_SOUTH), \
+              (4, 2, STAND_WEST)]
+
+def run ():
+    todo = myself.get_val ("todo")
+
+    # -- waiting
+    if todo == 0:
+        delay = myself.get_val ("delay")
+        # If standing delay expired, move around next time
+        if delay == 0:
+            myself.set_val ("todo", 1)
+        else:
+            myself.set_val ("delay", delay - 1)
+
+    # -- engage a new movement
+    elif todo == 1:
+        x, y, dir = coords[randint (0, 3)]
+
+        myself.set_goal (x, y, dir)
+        myself.set_val ("todo", 2)
+
+    # -- moving
+    elif todo == 2:
+        if myself.follow_path () == 1:
+            # -- the time we stay at the same place
+            delay = randint (20, 60) * 10
+
+            myself.set_val ("delay", delay)
+            myself.set_val ("todo", 0)
+
+
+    # -- utter a random remark
+    tmp = myself.get_val ("say_something")
+    myself.set_val ("say_something", tmp - 1)
+    if tmp == 0:
+        myself.speak (speech[randint (0, 3)])
+        delay = randint (50, 75) * 35
+        myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/jelom.py b/scripts/schedules/jelom.py
index 2581f1d..be797db 100644
--- a/scripts/schedules/jelom.py
+++ b/scripts/schedules/jelom.py
@@ -14,45 +14,47 @@
 #
 #    He guards the door to Lady Silverhair's room
 
-speech = ["Someone fetch me a drink!", \
-          "That'll teach them fancy Elves a lesson!", \
-          "Send them to the cursed island, I say!"]
-
-todo = myself.get_val ("todo")
-
-# If standing
-if todo == 0:
-    delay = myself.get_val ("delay")
-    # If standing delay expired, move around next time
-    if delay == 0:
-        myself.set_val ("todo", 1)
-    else:
-        myself.set_val ("delay", delay - 1)
-
-# Engage a new movement
-elif todo == 1:
-    # Choose where to move, if destination is already occupied we'll
-    # fall into the wait state (0) again automatically next time
-    if myself.posy () == 3:
-        myself.set_goal (2, 6, STAND_NORTH)
-    else:
-        myself.set_goal (2, 3, STAND_SOUTH)
-        
-    # Next time we'll actually move!
-    myself.set_val ("todo", 2)
-
-# Moving, follow the path until it is reached.
-elif todo == 2:
-    # Reached the goal? Wait a while then...
-    if myself.follow_path ():
-        myself.set_val ("delay", randint (30, 60) * 20)
-        myself.set_val ("todo", 0)
-
-
-# -- utter a random remark
-tmp = myself.get_val ("say_something")
-myself.set_val ("say_something", tmp - 1)
-if tmp <= 0:
-    myself.speak (speech[randint (0, 2)])
-    delay = randint (75, 150) * 20
-    myself.set_val ("say_something", delay)
+def init ():
+    speech = ["Someone fetch me a drink!", \
+              "That'll teach them fancy Elves a lesson!", \
+              "Send them to the cursed island, I say!"]
+
+def run ():
+    todo = myself.get_val ("todo")
+
+    # If standing
+    if todo == 0:
+        delay = myself.get_val ("delay")
+        # If standing delay expired, move around next time
+        if delay == 0:
+            myself.set_val ("todo", 1)
+        else:
+            myself.set_val ("delay", delay - 1)
+
+    # Engage a new movement
+    elif todo == 1:
+        # Choose where to move, if destination is already occupied we'll
+        # fall into the wait state (0) again automatically next time
+        if myself.posy () == 3:
+            myself.set_goal (2, 6, STAND_NORTH)
+        else:
+            myself.set_goal (2, 3, STAND_SOUTH)
+
+        # Next time we'll actually move!
+        myself.set_val ("todo", 2)
+
+    # Moving, follow the path until it is reached.
+    elif todo == 2:
+        # Reached the goal? Wait a while then...
+        if myself.follow_path ():
+            myself.set_val ("delay", randint (30, 60) * 20)
+            myself.set_val ("todo", 0)
+
+
+    # -- utter a random remark
+    tmp = myself.get_val ("say_something")
+    myself.set_val ("say_something", tmp - 1)
+    if tmp <= 0:
+        myself.speak (speech[randint (0, 2)])
+        delay = randint (75, 150) * 20
+        myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/keyboard_control.py 
b/scripts/schedules/keyboard_control.py
index d74e6f8..82600db 100755
--- a/scripts/schedules/keyboard_control.py
+++ b/scripts/schedules/keyboard_control.py
@@ -51,108 +51,108 @@ def close_gate ():
         sm.get_square (6, 19).set_walkable_west (0)
         sm.get_square (6, 20).set_walkable_west (0)
 
-#print "%d %d %d" % (myself.submap (), myself.posx (), myself.posy ())
-
-if input_has_been_pushed (SDLK_o):
-    open_gate ()
-
-if input_has_been_pushed (SDLK_c):
-    close_gate ()
-
-# -- react to the action key
-if input_has_been_pushed (SDLK_SPACE):
-    # -- see whether a character(/object) is next to the player
-    p = myself.whosnext ()
-
-    # - Yes :)
-    if p != None and p.currentmove() < WALK_NORTH:
-        # -- launch the other guy's (object's) action script 
-        p.launch_action (myself)
-
-        # -- Cleanup
-        p = None
-    elif p == None:
-        evt = action_event ()
-        evt.submap = myself.submap ()
-        evt.x = myself.posx ()
-        evt.y = myself.posy ()
-        evt.dir = myself.currentmove ()
-        evt.c = myself
-        event_handler_raise_event (evt)
-
-# -- bring up the main menu
-elif input_has_been_pushed (SDLK_ESCAPE):
-    import main_menu
-
-    # -- open main menu without animation, with saving and background enabled
-    menu = main_menu.main_menu (1, 1, 1)
-    menu.thisown = C
-    
-    # Stop updating the map
-    map_engine.set_should_update_map (0)
-
-    # -- this tells us when the main menu is closed
-    menu.py_signal_connect (on_menu_close, win_event_CLOSE, (myself))
-
-    # -- add stuff to the win_manager
-    win_manager_add (menu)
-    win_manager_set_focus (menu)
-    menu = None
-
-# -- move the player around
-elif input_is_pushed (SDLK_UP): myself.go_north ()
-elif input_is_pushed (SDLK_DOWN): myself.go_south ()
-elif input_is_pushed (SDLK_RIGHT): myself.go_east ()
-elif input_is_pushed (SDLK_LEFT): myself.go_west ()
-
-# Special tip! :)
-elif input_has_been_pushed (SDLK_n):
-    if myself.submap () < map_engine.get_landmap ().nbr_of_submaps () - 1:
-        myself.jump_to (myself.submap () + 1, 5, 3)
-    else:
-        myself.jump_to (0, 7, 18)
-
-elif input_has_been_pushed (SDLK_p):
-    if myself.submap () > 1:
-        myself.jump_to (myself.submap () - 1, 5, 3)
-    elif myself.submap () == 1:
-        myself.jump_to (0, 7, 18)        
-    else:
-        myself.jump_to (map_engine.get_landmap ().nbr_of_submaps () - 1, 5, 3)
-
-# -- shortcut to the load screen
-elif input_has_been_pushed (SDLK_l):
-    s = data_screen (LOAD_SCREEN)
-    s.thisown = C
-    s.py_signal_connect (on_data_screen_close, win_event_CLOSE)
-    # Stop updating the map
-    map_engine.set_should_update_map (0)
-    s.set_activate (1) 
-    win_manager_add (s)
-    win_manager_set_focus (s)
-
-
-# -- and to the save screen
-elif input_has_been_pushed (SDLK_s):
-    s = data_screen (SAVE_SCREEN)
-    s.thisown = C
-    s.py_signal_connect (on_data_screen_close, win_event_CLOSE)
-    # Stop updating the map
-    map_engine.set_should_update_map (0)
-    s.set_activate (1) 
-    win_manager_add (s)
-    win_manager_set_focus (s)
-
-
-# -- python console
-elif input_has_been_pushed (SDLK_TAB):
-    import console
-    c = console.console (globals ())
-    c.thisown = C
-    c.py_signal_connect (on_data_screen_close, win_event_CLOSE)
-    # Stop updating the map
-    map_engine.set_should_update_map (0)
-    c.set_activate (1)
-    win_manager_add (c)
-    win_manager_set_focus (c)
-    c = None
+
+def run ():
+    if input_has_been_pushed (SDLK_o):
+        open_gate ()
+
+    if input_has_been_pushed (SDLK_c):
+        close_gate ()
+
+    # -- react to the action key
+    if input_has_been_pushed (SDLK_SPACE):
+        # -- see whether a character(/object) is next to the player
+        p = myself.whosnext ()
+
+        # - Yes :)
+        if p != None and p.currentmove() < WALK_NORTH:
+            # -- launch the other guy's (object's) action script
+            p.launch_action (myself)
+
+            # -- Cleanup
+            p = None
+        elif p == None:
+            evt = action_event ()
+            evt.submap = myself.submap ()
+            evt.x = myself.posx ()
+            evt.y = myself.posy ()
+            evt.dir = myself.currentmove ()
+            evt.c = myself
+            event_handler_raise_event (evt)
+
+    # -- bring up the main menu
+    elif input_has_been_pushed (SDLK_ESCAPE):
+        import main_menu
+
+        # -- open main menu without animation, with saving and background 
enabled
+        menu = main_menu.main_menu (1, 1, 1)
+        menu.thisown = C
+
+        # Stop updating the map
+        map_engine.set_should_update_map (0)
+
+        # -- this tells us when the main menu is closed
+        menu.py_signal_connect (on_menu_close, win_event_CLOSE, (myself))
+
+        # -- add stuff to the win_manager
+        win_manager_add (menu)
+        win_manager_set_focus (menu)
+        menu = None
+
+    # -- move the player around
+    elif input_is_pushed (SDLK_UP): myself.go_north ()
+    elif input_is_pushed (SDLK_DOWN): myself.go_south ()
+    elif input_is_pushed (SDLK_RIGHT): myself.go_east ()
+    elif input_is_pushed (SDLK_LEFT): myself.go_west ()
+
+    # Special tip! :)
+    elif input_has_been_pushed (SDLK_n):
+        if myself.submap () < map_engine.get_landmap ().nbr_of_submaps () - 1:
+            myself.jump_to (myself.submap () + 1, 5, 3)
+        else:
+            myself.jump_to (0, 7, 18)
+
+    elif input_has_been_pushed (SDLK_p):
+        if myself.submap () > 1:
+            myself.jump_to (myself.submap () - 1, 5, 3)
+        elif myself.submap () == 1:
+            myself.jump_to (0, 7, 18)
+        else:
+            myself.jump_to (map_engine.get_landmap ().nbr_of_submaps () - 1, 
5, 3)
+
+    # -- shortcut to the load screen
+    elif input_has_been_pushed (SDLK_l):
+        s = data_screen (LOAD_SCREEN)
+        s.thisown = C
+        s.py_signal_connect (on_data_screen_close, win_event_CLOSE)
+        # Stop updating the map
+        map_engine.set_should_update_map (0)
+        s.set_activate (1)     
+        win_manager_add (s)
+        win_manager_set_focus (s)
+
+
+    # -- and to the save screen
+    elif input_has_been_pushed (SDLK_s):
+        s = data_screen (SAVE_SCREEN)
+        s.thisown = C
+        s.py_signal_connect (on_data_screen_close, win_event_CLOSE)
+        # Stop updating the map
+        map_engine.set_should_update_map (0)
+        s.set_activate (1)     
+        win_manager_add (s)
+        win_manager_set_focus (s)
+
+
+    # -- python console
+    elif input_has_been_pushed (SDLK_TAB):
+        import console
+        c = console.console (globals ())
+        c.thisown = C
+        c.py_signal_connect (on_data_screen_close, win_event_CLOSE)
+        # Stop updating the map
+        map_engine.set_should_update_map (0)
+        c.set_activate (1)
+        win_manager_add (c)
+        win_manager_set_focus (c)
+        c = None
diff --git a/scripts/schedules/oliver.py b/scripts/schedules/oliver.py
index 351e55d..65c6a68 100755
--- a/scripts/schedules/oliver.py
+++ b/scripts/schedules/oliver.py
@@ -16,96 +16,99 @@
 #    When summoned by Orloth, he'll show the player to his room
 
 
-speech = ["It's so exciting. An Elven Lady, here at Waste's Edge!", \
-          "I gotta hurry before mother complains again.", \
-          "Why can't I have a little dog!?"]
-
-# -- Oliver summoned to common room
-if myself.get_val ("goto_players_room") == 1:
-    # -- beam him directly there, as it is faster that way
-    if myself.submap () != 1:
-        myself.jump_to (1, 13, 7, STAND_NORTH)
+def init ():
+    speech = ["It's so exciting. An Elven Lady, here at Waste's Edge!", \
+              "I gotta hurry before mother complains again.", \
+              "Why can't I have a little dog!?"]
 
     # -- the tiles around Orloth
     offsets = [(1,1),(1,-1),(-1,1),(-1,-1),(1,0),(0,1),(-1,0),(0,-1)]
 
-    # -- find a free spot near Orloth and the player
-    i = 0
-    orloth = characters["Orloth Redwyne"]
-    while i < 7:
-        x, y = offsets[i][:2]
-        x = x + orloth.posx ()
-        y = y + orloth.posy ()
-        if myself.set_goal (x, y, NO_MOVE): break
-        i = i + 1
-
-    myself.set_val ("goto_players_room", 2)
-    myself.set_val ("todo", 2)
-
-# -- in the player's room
-elif myself.get_val ("goto_players_room") == 3:
-    # -- start talking to the player
-    myself.launch_action (the_player)
-    
-# -- leave the player's room and goto the barn
-elif myself.get_val ("goto_barn") == 1:
-    location = myself.submap ()
-    myself.set_val ("goto_barn", 2)
-
-    # -- Player's room
-    if location == 12:
-        myself.set_goal (5, 1, NO_MOVE)
-
-    # -- First floor
-    elif location == 9:
-        myself.set_goal (8, 1, NO_MOVE)
-
-    # -- Second floor (this shouldn't happen, but it once did ...)
-    elif location == 14:
-        myself.set_goal (4, 1, NO_MOVE)
-
-    # -- Common Room
-    elif location == 1:
-        myself.set_goal (13, 8, NO_MOVE)
-
-    # -- Yard, our final goal (for now)
-    elif location == 0:
-        myself.set_goal (25, 15, NO_MOVE)
-        myself.set_val ("goto_barn", 0)
-
-    myself.set_val ("todo", 2)
-
-
-# -- "normal" schedule
-todo = myself.get_val ("todo")
-
-# -- waiting
-if todo == 0:
-    delay = myself.get_val ("delay")
-
-    # If standing delay expired, move around next time
-    if delay == 0:
-        myself.set_val ("todo", 1)
-    else:
-        myself.set_val ("delay", delay - 1)
-
-# -- get movement target
-elif todo == 1:
-    # -- on our way back from bjarn's room
-    if myself.get_val ("goto_barn") == 2:
-        myself.set_val ("goto_barn", 1)
-
-# -- move
-elif todo == 2:
-    if myself.follow_path () == 1:
-        myself.set_val ("todo", 0)
-
-
-# -- do some random babbling
-tmp = myself.get_val ("say_something")
-myself.set_val ("say_something", tmp - 1)
-
-if tmp == 0:
-    myself.speak (speech[randint (0, 2)])
-    delay = randint (80, 160) * 10
-    myself.set_val ("say_something", delay)
+
+def run ():
+    # -- Oliver summoned to common room
+    if myself.get_val ("goto_players_room") == 1:
+        # -- beam him directly there, as it is faster that way
+        if myself.submap () != 1:
+            myself.jump_to (1, 13, 7, STAND_NORTH)
+
+        # -- find a free spot near Orloth and the player
+        i = 0
+        orloth = characters["Orloth Redwyne"]
+        while i < 7:
+            x, y = offsets[i][:2]
+            x = x + orloth.posx ()
+            y = y + orloth.posy ()
+            if myself.set_goal (x, y, NO_MOVE): break
+            i = i + 1
+
+        myself.set_val ("goto_players_room", 2)
+        myself.set_val ("todo", 2)
+
+    # -- in the player's room
+    elif myself.get_val ("goto_players_room") == 3:
+        # -- start talking to the player
+        myself.launch_action (the_player)
+
+    # -- leave the player's room and goto the barn
+    elif myself.get_val ("goto_barn") == 1:
+        location = myself.submap ()
+        myself.set_val ("goto_barn", 2)
+
+        # -- Player's room
+        if location == 12:
+            myself.set_goal (5, 1, NO_MOVE)
+
+        # -- First floor
+        elif location == 9:
+            myself.set_goal (8, 1, NO_MOVE)
+
+        # -- Second floor (this shouldn't happen, but it once did ...)
+        elif location == 14:
+            myself.set_goal (4, 1, NO_MOVE)
+
+        # -- Common Room
+        elif location == 1:
+            myself.set_goal (13, 8, NO_MOVE)
+
+        # -- Yard, our final goal (for now)
+        elif location == 0:
+            myself.set_goal (25, 15, NO_MOVE)
+            myself.set_val ("goto_barn", 0)
+
+        myself.set_val ("todo", 2)
+
+
+    # -- "normal" schedule
+    todo = myself.get_val ("todo")
+
+    # -- waiting
+    if todo == 0:
+        delay = myself.get_val ("delay")
+
+        # If standing delay expired, move around next time
+        if delay == 0:
+            myself.set_val ("todo", 1)
+        else:
+            myself.set_val ("delay", delay - 1)
+
+    # -- get movement target
+    elif todo == 1:
+        # -- on our way back from bjarn's room
+        if myself.get_val ("goto_barn") == 2:
+            myself.set_val ("goto_barn", 1)
+
+    # -- move
+    elif todo == 2:
+        if myself.follow_path () == 1:
+            myself.set_val ("todo", 0)
+
+
+    # -- do some random babbling
+    tmp = myself.get_val ("say_something")
+    myself.set_val ("say_something", tmp - 1)
+
+    if tmp == 0:
+        myself.speak (speech[randint (0, 2)])
+        delay = randint (80, 160) * 10
+        myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/orloth.py b/scripts/schedules/orloth.py
index 4499c49..0d3da36 100755
--- a/scripts/schedules/orloth.py
+++ b/scripts/schedules/orloth.py
@@ -15,96 +15,98 @@
 #    He'll walk up to a table occasionally and either set or clean it
 #    From time to time he'll complain about the grandfather clock
 
-speech = ["I gotta clean this mug!", \
-          "That barrel is leaking.", \
-          "I hope they'll find the thief!"]
-
-coords = [(10, 3, STAND_NORTH), \
-          (3, 5, STAND_SOUTH), \
-          (7, 6, STAND_EAST), \
-          (12, 3, STAND_SOUTH), \
-          (7, 4, STAND_WEST), \
-          (3, 7, 0), \
-          (9, 7, 0), \
-          (12, 5, 0), \
-          (6, 5, 0)]
-
-todo = myself.get_val ("todo")
-
-# -- waiting
-if todo == 0:
-    delay = myself.get_val ("delay")
-
-    # -- If standing delay expired, move around next time
-    if delay == 0:
-        myself.set_val ("todo", 1)
-    else:
-        myself.set_val ("delay", delay - 1)
-
-        # -- put/take the first mug
-        if delay == 100:
-            index = myself.get_val ("table_num")
-            if index > 0:
-                key = "table%i_set" % index
-                val = myself.get_val (key)
-
-                x, y = coords[index+4][:2]
-                if val == 0:
-                    map_engine.get_landmap ().put_mapobject (1,x,y,106)
-                else:
-                    map_engine.get_landmap ().remove_mapobject (1,x,y,106)
-
-        # -- put/take the second mug
-        elif delay == 50:
-            index = myself.get_val ("table_num")
-            if index > 0:
-                key = "table%i_set" % index
-                val = myself.get_val (key)
-                myself.set_val (key, ~val)
-
-                x, y = coords[index+4][:2]
-                if val == 0:
-                    map_engine.get_landmap ().put_mapobject (1,x,y,107)
-                else:
-                    map_engine.get_landmap ().remove_mapobject (1,x,y,107)
-
-# -- engage a new movement
-elif todo == 1:
-    # -- when we are at the bar, then wait a while before
-    #    moving again
-    if myself.posx () != 2:
-        delay = randint (40, 120) * 20
-        myself.set_val ("delay", delay)
-        myself.set_goal (2, 2, STAND_SOUTH)
-        myself.set_val ("table_num", 0)
-
-    # -- otherwise only wait a little
-    else:
-        index = randint (0, 4)
-        x, y, dir = coords[index]
-        myself.set_goal (x, y, dir)
-        myself.set_val ("delay", 150)
-        myself.set_val ("table_num", index)
-
-    myself.set_val ("todo", 2)
-
-# -- moving
-elif todo == 2:
-    if myself.follow_path () == 1:
-        # -- standing in front of the clock
-        if myself.posx () == 10:
-            myself.speak ("That clock is late again!")
-
-            tmp = myself.get_val ("say_something")
-            myself.set_val ("say_something", tmp + 75)
-
-        myself.set_val ("todo", 0)
-
-
-# -- utter a random remark
-tmp = myself.get_val ("say_something")
-myself.set_val ("say_something", tmp - 1)
-if tmp == 0:
-    myself.speak (speech[randint (0, 2)])
-    delay = randint (50, 150) * 20
-    myself.set_val ("say_something", delay)
+def init ():
+    speech = ["I gotta clean this mug!", \
+              "That barrel is leaking.", \
+              "I hope they'll find the thief!"]
+
+    coords = [(10, 3, STAND_NORTH), \
+              (3, 5, STAND_SOUTH), \
+              (7, 6, STAND_EAST), \
+              (12, 3, STAND_SOUTH), \
+              (7, 4, STAND_WEST), \
+              (3, 7, 0), \
+              (9, 7, 0), \
+              (12, 5, 0), \
+              (6, 5, 0)]
+
+def run ():
+    todo = myself.get_val ("todo")
+
+    # -- waiting
+    if todo == 0:
+        delay = myself.get_val ("delay")
+
+        # -- If standing delay expired, move around next time
+        if delay == 0:
+            myself.set_val ("todo", 1)
+        else:
+            myself.set_val ("delay", delay - 1)
+
+            # -- put/take the first mug
+            if delay == 100:
+                index = myself.get_val ("table_num")
+                if index > 0:
+                    key = "table%i_set" % index
+                    val = myself.get_val (key)
+
+                    x, y = coords[index+4][:2]
+                    if val == 0:
+                        map_engine.get_landmap ().put_mapobject (1,x,y,106)
+                    else:
+                        map_engine.get_landmap ().remove_mapobject (1,x,y,106)
+
+            # -- put/take the second mug
+            elif delay == 50:
+                index = myself.get_val ("table_num")
+                if index > 0:
+                    key = "table%i_set" % index
+                    val = myself.get_val (key)
+                    myself.set_val (key, ~val)
+
+                    x, y = coords[index+4][:2]
+                    if val == 0:
+                        map_engine.get_landmap ().put_mapobject (1,x,y,107)
+                    else:
+                        map_engine.get_landmap ().remove_mapobject (1,x,y,107)
+
+    # -- engage a new movement
+    elif todo == 1:
+        # -- when we are at the bar, then wait a while before
+        #    moving again
+        if myself.posx () != 2:
+            delay = randint (40, 120) * 20
+            myself.set_val ("delay", delay)
+            myself.set_goal (2, 2, STAND_SOUTH)
+            myself.set_val ("table_num", 0)
+
+        # -- otherwise only wait a little
+        else:
+            index = randint (0, 4)
+            x, y, dir = coords[index]
+            myself.set_goal (x, y, dir)
+            myself.set_val ("delay", 150)
+            myself.set_val ("table_num", index)
+
+        myself.set_val ("todo", 2)
+
+    # -- moving
+    elif todo == 2:
+        if myself.follow_path () == 1:
+            # -- standing in front of the clock
+            if myself.posx () == 10:
+                myself.speak ("That clock is late again!")
+
+                tmp = myself.get_val ("say_something")
+                myself.set_val ("say_something", tmp + 75)
+
+            myself.set_val ("todo", 0)
+
+
+    # -- utter a random remark
+    tmp = myself.get_val ("say_something")
+    myself.set_val ("say_something", tmp - 1)
+    if tmp == 0:
+        myself.speak (speech[randint (0, 2)])
+        delay = randint (50, 150) * 20
+        myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/random_move.py b/scripts/schedules/random_move.py
index ddbd787..a308bf2 100755
--- a/scripts/schedules/random_move.py
+++ b/scripts/schedules/random_move.py
@@ -1,8 +1,9 @@
-move=randint(10,30)
-if move>=10:
-  dir=randint(0,3)
+def run ():
+    move=randint(10,30)
+    if move>=10:
+        dir=randint(0,3)
 
-  if dir==0: myself.go_north();
-  if dir==1: myself.go_south();
-  if dir==2: myself.go_west();
-  if dir==3: myself.go_east();
+        if dir==0: myself.go_north();
+        if dir==1: myself.go_south();
+        if dir==2: myself.go_west();
+        if dir==3: myself.go_east();
diff --git a/scripts/schedules/sarin.py b/scripts/schedules/sarin.py
index 71cb176..70e4649 100755
--- a/scripts/schedules/sarin.py
+++ b/scripts/schedules/sarin.py
@@ -16,93 +16,94 @@
 #    to time he'll stop and chose another direction
 
 
-# -- Borders of the area he should stay in
-min_x = 1
-max_x = 6
-min_y = 2
-max_y = 6
-
-speech = ["Ruffinans, the lot of them!", \
-          "How dare they imprison one better than they?", \
-          "This is an insult to all of the High Born.", \
-          "I cannot believe such disrespect. Barbarians!"]
-
-
-# -- delay for orientation change
-delay = myself.get_val ("delay")
-
-# -- switch orientation
-if delay == 0:
-    # -- get the current direction ...
-    dir = myself.get_val ("direction")
-
-    # -- ... and set the new one accordingly
-    if dir == WALK_EAST or dir == WALK_WEST:
-        dir = randint (WALK_NORTH, WALK_SOUTH)
-    else:
-        dir = randint (WALK_WEST, WALK_EAST)
-
-    # -- time until the next orientation change
-    delay = randint (100, 200) * 15
-    myself.set_val ("direction", dir)
-    myself.set_val ("delay", delay)
-    myself.set_val ("todo", 1)
-
-else:
-    myself.set_val ("delay", delay - 1)
-
-
-todo = myself.get_val ("todo")
-
-# -- waiting
-if todo == 0:
-    # -- delay for direction change
-    delay = myself.get_val ("switch_direction")
-
+def init ():
+    # -- Borders of the area he should stay in
+    min_x = 1
+    max_x = 6
+    min_y = 2
+    max_y = 6
+
+    speech = ["Ruffinans, the lot of them!", \
+              "How dare they imprison one better than they?", \
+              "This is an insult to all of the High Born.", \
+              "I cannot believe such disrespect. Barbarians!"]
+
+def run ():
+    # -- delay for orientation change
+    delay = myself.get_val ("delay")
+
+    # -- switch orientation
     if delay == 0:
+        # -- get the current direction ...
+        dir = myself.get_val ("direction")
+
+        # -- ... and set the new one accordingly
+        if dir == WALK_EAST or dir == WALK_WEST:
+            dir = randint (WALK_NORTH, WALK_SOUTH)
+        else:
+            dir = randint (WALK_WEST, WALK_EAST)
+
+        # -- time until the next orientation change
+        delay = randint (100, 200) * 15
+        myself.set_val ("direction", dir)
+        myself.set_val ("delay", delay)
         myself.set_val ("todo", 1)
-    else:
-        myself.set_val ("switch_direction", delay - 1)
-
-# -- get movement target
-elif todo == 1:
-    # -- get the current direction ...
-    dir = myself.get_val ("direction")
-
-    # -- switch direction
-    if dir == WALK_NORTH:
-        goal = (myself.posx (), min_y, STAND_SOUTH, 0, 1)
-    elif dir == WALK_SOUTH:
-        goal = (myself.posx (), max_y, STAND_NORTH, 0, -1)
-    elif dir == WALK_EAST:
-        goal = (max_x, myself.posy(), STAND_WEST, -1, 0)
-    else:
-        goal = (min_x, myself.posy (), STAND_EAST, 1, 0)
-
-    x, y, d = goal[:3]
-    myself.set_val ("direction", d + 4)
-
-    while not myself.set_goal (x, y, d):
-        offx, offy = goal [-2:]
-        x = x + offx
-        y = y + offy
 
-    myself.set_val ("todo", 2)
-
-# -- move
-elif todo == 2:
-    if myself.follow_path () == 1:
-        # -- wait a little on the current tile
-        delay = randint (15, 30) * 10
-        myself.set_val ("switch_direction", delay)
-
-        myself.set_val ("todo", 0)
-
-
-# -- utter a random remark
-tmp = myself.get_val ("say_something")
-myself.set_val ("say_something", tmp - 1)
-if tmp == 0:
-    myself.speak (speech[randint (0, 3)])
-    delay = randint (50, 150) * 15
-    myself.set_val ("say_something", delay)
+    else:
+        myself.set_val ("delay", delay - 1)
+
+
+    todo = myself.get_val ("todo")
+
+    # -- waiting
+    if todo == 0:
+        # -- delay for direction change
+        delay = myself.get_val ("switch_direction")
+
+        if delay == 0:
+            myself.set_val ("todo", 1)
+        else:
+            myself.set_val ("switch_direction", delay - 1)
+
+    # -- get movement target
+    elif todo == 1:
+        # -- get the current direction ...
+        dir = myself.get_val ("direction")
+
+        # -- switch direction
+        if dir == WALK_NORTH:
+            goal = (myself.posx (), min_y, STAND_SOUTH, 0, 1)
+        elif dir == WALK_SOUTH:
+            goal = (myself.posx (), max_y, STAND_NORTH, 0, -1)
+        elif dir == WALK_EAST:
+            goal = (max_x, myself.posy(), STAND_WEST, -1, 0)
+        else:
+            goal = (min_x, myself.posy (), STAND_EAST, 1, 0)
+
+        x, y, d = goal[:3]
+        myself.set_val ("direction", d + 4)
+
+        while not myself.set_goal (x, y, d):
+            offx, offy = goal [-2:]
+            x = x + offx
+            y = y + offy
+
+        myself.set_val ("todo", 2)
+
+    # -- move
+    elif todo == 2:
+        if myself.follow_path () == 1:
+            # -- wait a little on the current tile
+            delay = randint (15, 30) * 10
+            myself.set_val ("switch_direction", delay)
+
+            myself.set_val ("todo", 0)
+
+
+    # -- utter a random remark
+    tmp = myself.get_val ("say_something")
+    myself.set_val ("say_something", tmp - 1)
+    if tmp == 0:
+        myself.speak (speech[randint (0, 3)])
+        delay = randint (50, 150) * 15
+        myself.set_val ("say_something", delay)
diff --git a/scripts/schedules/silverhair.py b/scripts/schedules/silverhair.py
index 4deebee..ed43f89 100755
--- a/scripts/schedules/silverhair.py
+++ b/scripts/schedules/silverhair.py
@@ -15,55 +15,57 @@
 #    She will mainly stand still, but occasionally walk up to the
 #    window and make a remark about the weather.
 
-speech = ["In truth, Sarin, it is no bother. I am not offended.", \
-          "Janesta, dear, worry not. I am content here.", \
-          "Janesta, please bring my figurine. I wish to see it more closely.", 
\
-          "It truly is a lovely day. I expect we will have time yet to enjoy 
it."]
+def init ():
+    speech = ["In truth, Sarin, it is no bother. I am not offended.", \
+              "Janesta, dear, worry not. I am content here.", \
+              "Janesta, please bring my figurine. I wish to see it more 
closely.", \
+              "It truly is a lovely day. I expect we will have time yet to 
enjoy it."]
 
-todo = myself.get_val ("todo")
+def run ():
+    todo = myself.get_val ("todo")
 
-# -- waiting
-if todo == 0:
-    delay = myself.get_val ("delay")
+    # -- waiting
+    if todo == 0:
+        delay = myself.get_val ("delay")
 
-    # If standing delay expired, move around next time
-    if delay == 0:
-        myself.set_val ("todo", 1)
-    else:
-        myself.set_val ("delay", delay - 1)
+        # If standing delay expired, move around next time
+        if delay == 0:
+            myself.set_val ("todo", 1)
+        else:
+            myself.set_val ("delay", delay - 1)
 
-# -- get movement target
-elif todo == 1:
-    # -- goto the window
-    if myself.posx () == 4:
-        # ... and speak about the weather
-        say = randint (33, 66) * 10
-        delay = randint (50, 75) * 15
-        myself.set_val ("say_something", say)
-        myself.set_goal (6, 4, STAND_EAST)
+    # -- get movement target
+    elif todo == 1:
+        # -- goto the window
+        if myself.posx () == 4:
+            # ... and speak about the weather
+            say = randint (33, 66) * 10
+            delay = randint (50, 75) * 15
+            myself.set_val ("say_something", say)
+            myself.set_goal (6, 4, STAND_EAST)
 
-    # -- go back to our normal position
-    else:
-        delay = randint (100, 200) * 35
-        myself.set_goal (4, 4, STAND_SOUTH)
+        # -- go back to our normal position
+        else:
+            delay = randint (100, 200) * 35
+            myself.set_goal (4, 4, STAND_SOUTH)
 
-    myself.set_val ("say_something", say)
-    myself.set_val ("delay", delay)
-    myself.set_val ("todo", 2)
+        myself.set_val ("say_something", say)
+        myself.set_val ("delay", delay)
+        myself.set_val ("todo", 2)
 
-# -- move
-elif todo == 2:
-    if myself.follow_path () == 1:
-        myself.set_val ("todo", 0)
+    # -- move
+    elif todo == 2:
+        if myself.follow_path () == 1:
+            myself.set_val ("todo", 0)
 
-# -- speak
-say = myself.get_val ("say_something")
-myself.set_val ("say_something", say - 1)
-if say == 0:
-    if myself.posx () == 6:
-        myself.speak (speech[3])
-    else:
-        myself.speak (speech[randint (0, 2)])
+    # -- speak
+    say = myself.get_val ("say_something")
+    myself.set_val ("say_something", say - 1)
+    if say == 0:
+        if myself.posx () == 6:
+            myself.speak (speech[3])
+        else:
+            myself.speak (speech[randint (0, 2)])
 
-    say = randint (60, 180) * 20
-    myself.set_val ("say_something", say)
+        say = randint (60, 180) * 20
+        myself.set_val ("say_something", say)
diff --git a/scripts/schedules/talan.py b/scripts/schedules/talan.py
index 3abed94..e7ce97e 100755
--- a/scripts/schedules/talan.py
+++ b/scripts/schedules/talan.py
@@ -14,45 +14,47 @@
 #
 #    He guards the gate
 
-speech = ["Halt! Who goes there?", \
-          "\"Ai! laurie lantar lassi surinen ...\"", \
-          "Nobody may pass through the gate!"]
-
-todo = myself.get_val ("todo")
-
-# If standing
-if todo == 0:
-    delay = myself.get_val ("delay")
-    # If standing delay expired, move around next time
-    if delay == 0:
-        myself.set_val ("todo", 1)
-    else:
-        myself.set_val ("delay", delay - 1)
-
-# Engage a new movement
-elif todo == 1:
-    # Choose where to move, if destination is already occupied we'll
-    # fall into the wait state (0) again automatically next time
-    if myself.posy () == 17:
-        myself.set_goal (11, 19, STAND_NORTH)
-    else:
-        myself.set_goal (11, 17, STAND_SOUTH)
-        
-    # Next time we'll actually move!
-    myself.set_val ("todo", 2)
-
-# Moving, follow the path until it is reached.
-elif todo == 2:
-    # Reached the goal? Wait a while then...
-    if myself.follow_path ():
-        myself.set_val ("delay", randint (25, 50) * 20)
-        myself.set_val ("todo", 0)
-
-
-# -- utter a random remark
-tmp = myself.get_val ("say_something")
-myself.set_val ("say_something", tmp - 1)
-if tmp <= 0:
-    myself.speak (speech[randint (0, 2)])
-    delay = randint (50, 150) * 20
-    myself.set_val ("say_something", delay)
+def init ():
+    speech = ["Halt! Who goes there?", \
+              "\"Ai! laurie lantar lassi surinen ...\"", \
+              "Nobody may pass through the gate!"]
+
+def run ():
+    todo = myself.get_val ("todo")
+
+    # If standing
+    if todo == 0:
+        delay = myself.get_val ("delay")
+        # If standing delay expired, move around next time
+        if delay == 0:
+            myself.set_val ("todo", 1)
+        else:
+            myself.set_val ("delay", delay - 1)
+
+    # Engage a new movement
+    elif todo == 1:
+        # Choose where to move, if destination is already occupied we'll
+        # fall into the wait state (0) again automatically next time
+        if myself.posy () == 17:
+            myself.set_goal (11, 19, STAND_NORTH)
+        else:
+            myself.set_goal (11, 17, STAND_SOUTH)
+
+        # Next time we'll actually move!
+        myself.set_val ("todo", 2)
+
+    # Moving, follow the path until it is reached.
+    elif todo == 2:
+        # Reached the goal? Wait a while then...
+        if myself.follow_path ():
+            myself.set_val ("delay", randint (25, 50) * 20)
+            myself.set_val ("todo", 0)
+
+
+    # -- utter a random remark
+    tmp = myself.get_val ("say_something")
+    myself.set_val ("say_something", tmp - 1)
+    if tmp <= 0:
+        myself.speak (speech[randint (0, 2)])
+        delay = randint (50, 150) * 20
+        myself.set_val ("say_something", delay)



reply via email to

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