X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fscripting%2Ffunctions.cpp;h=5c1d6ff12c10a3dc77a519246cc761a8eba2ee40;hb=67690e081c28b818e94796be284206326bc8a6b9;hp=b0b9429a0ff19d327ecc59852c41fbaf8a5d1525;hpb=60908c905544776c376421b8d3e12eeb936c068f;p=supertux.git diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index b0b9429a0..5c1d6ff12 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -1,13 +1,55 @@ #include -#include "functions.h" +#include +#include +#include +#include "textscroller.hpp" +#include "functions.hpp" +#include "script_interpreter.hpp" +#include "tinygettext/tinygettext.hpp" +#include "resources.hpp" +#include "gettext.hpp" +#include "msg.hpp" +#include "mainloop.hpp" namespace Scripting { -void wait(float secs) +void wait(float seconds) { - (void) secs; - printf("Wait not implemented.\n"); + 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; + main_loop->push_screen(new TextScroller(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) { + msg_warning << "couldn't load script '" << filename << "' (" << file << ")" << std::endl; + return; + } + + sq_push(v, -2); + if(sq_call(v, 1, false) < 0) { + msg_warning << "Couldn't execute script '" << filename << "' (" << file << ")" << std::endl; + return; + } +} + +void add_key(int new_key) +{ + player_status->set_keys(new_key); } }