Index: code/branches/ScriptableController_HS17/src/orxonox/infos/GametypeInfo.cc
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/infos/GametypeInfo.cc	(revision 11661)
+++ code/branches/ScriptableController_HS17/src/orxonox/infos/GametypeInfo.cc	(revision 11662)
@@ -318,6 +318,9 @@
         {
             this->getLevel()->getScriptableController()->setPlayer(player);
-            // TODO Fix for relative paths
-            this->getLevel()->getScriptableController()->runScript(this->getLevel()->getFilename() + "/" + this->getLevel()->getScript());
+
+            std::string script = this->getLevel()->getScript();
+            if(script.at(0) != '/')
+                script = "../levels/" + script; // Not very dynamic
+            this->getLevel()->getScriptableController()->runScript(script);
         }
     }
Index: code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller.cc
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller.cc	(revision 11661)
+++ code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller.cc	(revision 11662)
@@ -35,4 +35,5 @@
     if((ret = luaL_loadfile(lua, file_path.c_str())) != 0)
     {
+        orxout(user_error) << "Failed to load level script " + file_path << std::endl;
         this->printLuaError(lua);
         delete api;
@@ -43,4 +44,5 @@
     if((ret = lua_pcall(lua, 0, LUA_MULTRET, 0)) != 0)
     {
+        orxout(user_error) << "Level script returned an error" << std::endl;
         this->printLuaError(lua);
         delete api;
@@ -86,5 +88,5 @@
 
     for(auto &api : this->apis_)
-        api->pawnKilled(pawn_id_iter->second);
+        api->pawnKilled(pawn_id_iter->second, pawn);
 
     this->pawns_.erase(pawn_id_iter->second);
@@ -110,6 +112,6 @@
 void ScriptableController::killPawn(std::string id)
 {
-    auto pawn = this->pawns_.find(id);
-    if(pawn == this->pawns_.end())
+    auto pawn = this->getPawnByID(id);
+    if(pawn == nullptr)
     {
         orxout(user_warning) << "Tried to destroy unknown pawn " << id << std::endl;
@@ -117,5 +119,5 @@
     }
 
-    pawn->second->kill();
+    pawn->kill();
 }
 
@@ -141,4 +143,7 @@
 Pawn *ScriptableController::getPawnByID(std::string id) const
 {
+    if(id == "player" || id == "Player" || id == "PLAYER")
+        return orxonox_cast<Pawn*>(this->player_->getControllableEntity());
+
     auto pawn = this->pawns_.find(id);
     return pawn != this->pawns_.end() ? pawn->second : nullptr;
@@ -151,5 +156,5 @@
     // Yes, this is 'const char*' and not 'std::string' because that's what lua gives us.
     const char* message = lua_tostring(lua, -1);
-    std::cout << message << std::endl;
+    orxout(user_error) << message << std::endl;
     lua_pop(lua, 1);
 }
Index: code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller_api.cc
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller_api.cc	(revision 11661)
+++ code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller_api.cc	(revision 11662)
@@ -4,4 +4,7 @@
 #include "scriptable_controller.h"
 #include "tools/Timer.h"
+#include "worldentities/pawns/Pawn.h"
+#include "infos/Bot.h"
+#include "worldentities/pawns/ModularSpaceShip.h"
 
 namespace orxonox
@@ -32,4 +35,5 @@
 
     LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::killPawn)>::registerFunction<&ScriptableControllerAPI::killPawn>(this, lua, "killPawn");
+    LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::spawn)>::registerFunction<&ScriptableControllerAPI::spawn>(this, lua, "spawn");
 
     this->periodicTimer.setTimer(ScriptableControllerAPI::periodic_interval, true, createExecutor(createFunctor(&ScriptableControllerAPI::periodic, this)), false);
@@ -103,4 +107,54 @@
 }
 
+void ScriptableControllerAPI::spawn(std::string type, std::string id)
+{
+    if(this->controller_->getWorldEntityByID(id) != nullptr)
+    {
+        orxout(user_warning) << "Script tried to spawn an object, but an object with the given ID exists already" << std::endl;
+        return;
+    }
+
+    Identifier *identifier = ClassByString(type);
+    if(!identifier)
+    {
+        orxout(user_error) << "Script tried to spawn unknown object" << std::endl;
+        return;
+    }
+
+    if(!identifier->isLoadable())
+    {
+        orxout(user_error) << "Script tried to spawn unloadable object" << std::endl;
+        return;
+    }
+
+    WorldEntity *entity;
+    Identifiable *obj = identifier->fabricate(this->controller_->getWorldEntityByID("Player")->getContext());
+
+    if(obj->isA(ClassIdentifier<WorldEntity>::getIdentifier()))
+    {
+        entity = orxonox_cast<WorldEntity*>(obj);
+    }
+    else if(obj->isA(ClassIdentifier<PlayerInfo>::getIdentifier()))
+    {
+        // TODO This does not work yet because somehow the controllable entity is not set
+        // yet at this stage.
+//        entity = orxonox_cast<PlayerInfo*>(obj)->getControllableEntity();
+        return;
+    }
+    else
+    {
+        orxout(user_warning) << "Script tried to spawn an object that is neither a WorldEntity, nor a PlayerInfo" << std::endl;
+        return;
+    }
+
+    if(entity->isA(ClassIdentifier<MobileEntity>::getIdentifier()))
+        this->controller_->registerMobileEntity(id, orxonox_cast<MobileEntity*>(entity));
+
+    if(entity->isA(ClassIdentifier<Pawn>::getIdentifier()))
+        this->controller_->registerPawn(id, orxonox_cast<Pawn*>(entity));
+
+    this->controller_->registerWorldEntity(id, orxonox_cast<WorldEntity*>(entity));
+}
+
 void ScriptableControllerAPI::setPosition(std::string id, double x, double y, double z)
 {
@@ -179,5 +233,5 @@
 }
 
-void ScriptableControllerAPI::pawnKilled(std::string id)
+void ScriptableControllerAPI::pawnKilled(std::string id, Pawn *pawn)
 {
     for(auto callback : this->pawnDestroyedHandlers_[id])
@@ -185,4 +239,14 @@
 
     this->pawnDestroyedHandlers_.erase(id);
+
+    // We need to delete those handlers as well, they're no longer valid
+    auto near_obj_handler = this->nearObjectHandlers_.begin();
+    while(near_obj_handler != this->nearObjectHandlers_.end())
+    {
+        if(near_obj_handler->entity1_ == pawn || near_obj_handler->entity2_ == pawn)
+            near_obj_handler = this->nearObjectHandlers_.erase(near_obj_handler);
+        else
+            near_obj_handler++;
+    }
 }
 
@@ -257,4 +321,6 @@
 
     // Pawns to kill
+    // TODO Possible race condidtion when the player destroys the pawn
+    // between the callback and the next periodic call.
     for(auto &pawn : this->pawnsToKill_)
         this->controller_->killPawn(pawn);
Index: code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller_api.h
===================================================================
--- code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller_api.h	(revision 11661)
+++ code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller_api.h	(revision 11662)
@@ -14,4 +14,5 @@
 class ScriptableController;
 class WorldEntity;
+class Pawn;
 
 /**
@@ -24,4 +25,6 @@
 class ScriptableControllerAPI
 {
+friend class ScriptableController;
+
 public:
     /**
@@ -140,4 +143,11 @@
 
     /**
+     * @brief Spawn an object
+     * @param type Name of the class of the object you want to spawn
+     * @param id The newly created ID that can be used to access this object
+     */
+    void spawn(std::string type, std::string id);
+
+    /**
      * @brief Set the position of an object
      * @param id The ID of the object
@@ -185,4 +195,5 @@
 // ### API END ################################################################
 
+private:
     /**
      * @brief Called by ScriptableController when a pawn is killed
@@ -191,5 +202,5 @@
      * Calls the lua callbacks associated with this event.
      */
-    void pawnKilled(std::string id);
+    void pawnKilled(std::string id, Pawn *pawn);
 
     /**
@@ -202,5 +213,4 @@
     void pawnHit(std::string target_id, std::string source_id, double new_health, double new_shield);
 
-private:
     /**
      * @brief Groups everything together that is needed to handle a near-object event
