From: Marek Moeckel Date: Sun, 25 Sep 2005 17:59:50 +0000 (+0000) Subject: scripting stuff X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=45ecab3e0289e360312509a7ea43df4d47c67157;p=supertux.git scripting stuff SVN-Revision: 2785 --- diff --git a/data/levels/world2/level2.stl b/data/levels/world2/level2.stl index 90132a322..6f920ae10 100644 --- a/data/levels/world2/level2.stl +++ b/data/levels/world2/level2.stl @@ -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 index 000000000..5034bf3b1 --- /dev/null +++ b/data/script/default.nut @@ -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(); +} diff --git a/src/scripting/script_interpreter.cpp b/src/scripting/script_interpreter.cpp index eb53a0c54..484465682 100644 --- a/src/scripting/script_interpreter.cpp +++ b/src/scripting/script_interpreter.cpp @@ -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) {