X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fscripting%2Ffunctions.cpp;h=f62ef92277d5e89965ea5453caa7099e38f7c8b3;hb=071c31e7fcf8bfbd00ec8d7d19313d7f6e433885;hp=a3c211a12a9db6cf5ff120c0f92132da0c781de0;hpb=8f21eeeae4a09dc90aada92fc5afdc9297bfd0f0;p=supertux.git diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index a3c211a12..f62ef9227 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -1,17 +1,18 @@ #include #include #include -#include "textscroller.h" -#include "functions.h" -#include "script_interpreter.h" -#include "tinygettext/tinygettext.h" -#include "resources.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()->set_wakeup_time(seconds); } @@ -28,5 +29,28 @@ void display_text_file(const std::string& 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; + } +} + +void add_key(int new_key) +{ + player_status->set_keys(new_key); +} + }