more smaller fixes
[supertux.git] / src / scripting / functions.cpp
index b46e6e2..30afc98 100644 (file)
@@ -2,17 +2,19 @@
 #include <string>
 #include <squirrel.h>
 #include <sqstdio.h>
-#include "textscroller.h"
-#include "functions.h"
-#include "script_interpreter.h"
-#include "tinygettext/tinygettext.h"
-#include "resources.h"
-#include "gettext.h"
+#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 set_wakeup_time(float seconds)
+void wait(float seconds)
 {
   ScriptInterpreter::current()->set_wakeup_time(seconds);
 }
@@ -25,8 +27,8 @@ std::string translate(const std::string& text)
 void display_text_file(const std::string& filename)
 {
   std::string file 
-    = ScriptInterpreter::current()->get_working_directory() + filename;
-  ::display_text_file(file);
+      = ScriptInterpreter::current()->get_working_directory() + filename;
+  main_loop->push_screen(new TextScroller(file));
 }
 
 void import(HSQUIRRELVM v, const std::string& filename)
@@ -34,18 +36,23 @@ 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";
+    msg_warning("couldn't load script '" << filename << "' ("
+      << file << ")");
     return;
   }
 
   sq_push(v, -2);
   if(sq_call(v, 1, false) < 0) {
-    std::cerr << "Couldn't execute script '" << filename << "' ("
-      << file << ").\n";
+    msg_warning("Couldn't execute script '" << filename << "' ("
+      << file << ")");
     return;
   }
 }
 
+void add_key(int new_key)
+{
+  player_status->set_keys(new_key);
+}
+
 }