X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fscripting%2Ffunctions.cpp;h=2e51cad6502e1d01a50af19c4a1959b1e2566c7e;hb=8f82a8e619346be81a3c1bf943baf68953f1f4e7;hp=fbff6d8a7dcd71bdf58cb60aa8339c1b05188bd3;hpb=864c93e01ec366f730b3ebad08d5c52d6a9363b6;p=supertux.git diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index fbff6d8a7..2e51cad65 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -1,13 +1,50 @@ #include -#include "functions.h" -#include "script_interpreter.h" +#include +#include +#include +#include "textscroller.hpp" +#include "functions.hpp" +#include "script_interpreter.hpp" +#include "tinygettext/tinygettext.hpp" +#include "resources.hpp" +#include "gettext.hpp" namespace Scripting { void wait(float seconds) { - ScriptInterpreter::current()->suspend(seconds); + ScriptInterpreter::current()->set_wakeup_time(seconds); +} + +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; + } } }