scripting stuff
authorMarek Moeckel <wansti@gmx.de>
Sun, 25 Sep 2005 17:59:50 +0000 (17:59 +0000)
committerMarek Moeckel <wansti@gmx.de>
Sun, 25 Sep 2005 17:59:50 +0000 (17:59 +0000)
SVN-Revision: 2785

data/levels/world2/level2.stl
data/script/default.nut [new file with mode: 0644]
src/scripting/script_interpreter.cpp

index 90132a3..6f920ae 100644 (file)
@@ -235,12 +235,7 @@ DisplayEffect.fade_in(1);
       )
       (powerup (x 8000) (y 352)
         (sprite "key-gold")
-        (script "add_key(KEY_GOLD);
-                 Sound.play_music(\"leveldone\");
-                 wait(6);
-                 DisplayEffect.fade_out(2);
-                 wait(2);
-                 Level.finish();")
+        (script "get_gold_key();")
       )
       (infoblock (x 2560) (y 320)
         (message (_ "-Oh no!
diff --git a/data/script/default.nut b/data/script/default.nut
new file mode 100644 (file)
index 0000000..5034bf3
--- /dev/null
@@ -0,0 +1,15 @@
+
+function get_gold_key()
+{
+  add_key(KEY_GOLD);
+  end_level();
+}
+
+function end_level()
+{
+  Sound.play_music("leveldone");
+  wait(6);
+  DisplayEffect.fade_out(2);
+  wait(2);
+  Level.finish();
+}
index eb53a0c..4844656 100644 (file)
@@ -183,7 +183,7 @@ ScriptInterpreter::add_script_object(Sector* sector, const std::string& name,
     // load global default.nut file if it exists
     //TODO: Load all .nut files from that directory
     try {
-      std::string filename = "data/script/default.nut";
+      std::string filename = "script/default.nut";
       IFileStream in(filename);
       interpreter->run_script(in, filename, false);
     } catch(std::exception& e) {