more smaller fixes
[supertux.git] / src / scripting / script_interpreter.cpp
index 1047ed7..25f88e1 100644 (file)
@@ -13,6 +13,7 @@
 #include <sqstdmath.h>
 #include <sqstdstring.h>
 
+#include "msg.hpp"
 #include "wrapper.hpp"
 #include "wrapper_util.hpp"
 #include "sector.hpp"
@@ -40,7 +41,7 @@ static void printfunc(HSQUIRRELVM, const char* str, ...)
 ScriptInterpreter* ScriptInterpreter::_current = 0;
 
 ScriptInterpreter::ScriptInterpreter(const std::string& new_working_directory)
-  : working_directory(new_working_directory), sound(0), level(0)
+  : working_directory(new_working_directory), sound(0), level(0), camera(0)
 {
   v = sq_open(1024);
   if(v == 0)
@@ -101,6 +102,9 @@ ScriptInterpreter::register_sector(Sector* sector)
   Scripting::DisplayEffect* display_effect_api
     = static_cast<Scripting::DisplayEffect*> (display_effect);
   expose_object(display_effect_api, "DisplayEffect");
+
+  Scripting::Camera* camera = new Scripting::Camera(sector->camera);
+  expose_object(camera, "Camera");
 }
 
 ScriptInterpreter::~ScriptInterpreter()
@@ -108,6 +112,7 @@ ScriptInterpreter::~ScriptInterpreter()
   sq_close(v);
   delete sound;
   delete level;
+  delete camera;
 }
 
 static SQInteger squirrel_read_char(SQUserPointer file)
@@ -200,7 +205,7 @@ ScriptInterpreter::add_script_object(Sector* sector, const std::string& name,
     interpreter->run_script(in, name);
     sector->add_object(interpreter.release());
   } catch(std::exception& e) {
-    std::cerr << "Couldn't start '" << name << "' script: " << e.what() << "\n";
+    msg_warning("Couldn't start '" << name << "' script: " << e.what());
   }
 }