X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fscripting%2Ffunctions.cpp;h=2e51cad6502e1d01a50af19c4a1959b1e2566c7e;hb=8f82a8e619346be81a3c1bf943baf68953f1f4e7;hp=99e2c9af3d1312c870eff7615ca874a8b623c085;hpb=f1e15f44f709d6b4fa45e858dc12d7d701ae8ddc;p=supertux.git diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index 99e2c9af3..2e51cad65 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -1,17 +1,20 @@ #include #include #include -#include "functions.h" -#include "script_interpreter.h" -#include "tinygettext/tinygettext.h" -#include "gettext.h" +#include +#include "textscroller.hpp" +#include "functions.hpp" +#include "script_interpreter.hpp" +#include "tinygettext/tinygettext.hpp" +#include "resources.hpp" +#include "gettext.hpp" namespace Scripting { -void set_wakeup_time(float seconds) +void wait(float seconds) { - ScriptInterpreter::current()->suspend(seconds); + ScriptInterpreter::current()->set_wakeup_time(seconds); } std::string translate(const std::string& text) @@ -19,5 +22,30 @@ std::string translate(const std::string& text) return dictionary_manager.get_dictionary().translate(text); } +void display_text_file(const std::string& filename) +{ + std::string file + = ScriptInterpreter::current()->get_working_directory() + filename; + ::display_text_file(file); +} + +void import(HSQUIRRELVM v, const std::string& filename) +{ + std::string file + = ScriptInterpreter::current()->get_working_directory() + filename; + if(sqstd_loadfile(v, file.c_str(), true) < 0) { + std::cerr << "Warning couldn't load script '" << filename << "' (" + << file << ").\n"; + return; + } + + sq_push(v, -2); + if(sq_call(v, 1, false) < 0) { + std::cerr << "Couldn't execute script '" << filename << "' (" + << file << ").\n"; + return; + } +} + }