[Orxonox-commit 7285] r11902 - code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller

adamc at orxonox.net adamc at orxonox.net
Tue Apr 24 17:56:18 CEST 2018


Author: adamc
Date: 2018-04-24 17:56:18 +0200 (Tue, 24 Apr 2018)
New Revision: 11902

Modified:
   code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.cc
   code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.h
Log:
scriptablecontroller trying to move player with lua

Modified: code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.cc
===================================================================
--- code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.cc	2018-04-24 11:36:15 UTC (rev 11901)
+++ code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.cc	2018-04-24 15:56:18 UTC (rev 11902)
@@ -39,6 +39,7 @@
 
 
         LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::myTestFunction)>::registerFunction<&ScriptableControllerAPI::myTestFunction>(this, lua, "mytestfunction");
+        LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::moveControllableEntity)>::registerFunction<&ScriptableControllerAPI::moveControllableEntity>(this, lua, "moveControllableEntity");
 
 
 
@@ -361,6 +362,32 @@
         return z;
     }
 
-    //void ScriptableControllerAPI::moveEntity(std::string id, double x, double y, double z)
+    void ScriptableControllerAPI::moveControllableEntity(std::string id, double x, double y, double z)
+    {
+        MobileEntity *entity = this->controller_->getMobileEntityByID(id);
+        if(entity == nullptr)
+        {
+            orxout(user_warning) << "Trying to set velocity of an unknown object" << std::endl;
+            return;
+        }
 
+
+
+
+        Identifier *identifier = ClassByString("ControllableEntity");
+       
+        ControllableEntity *controllable_entity;
+        
+        if(identifier->isA(ClassIdentifier<ControllableEntity>::getIdentifier()))
+        {
+            controllable_entity = orxonox_cast<ControllableEntity*>(entity);
+
+            controllable_entity->moveFrontBack(x);
+            controllable_entity->moveRightLeft(y);
+            controllable_entity->moveUpDown(z);
+        }
+
+        return;
+        
+    }
 }

Modified: code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.h
===================================================================
--- code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.h	2018-04-24 11:36:15 UTC (rev 11901)
+++ code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.h	2018-04-24 15:56:18 UTC (rev 11902)
@@ -205,6 +205,8 @@
      */
     double myTestFunction(double x, double y);
 
+    void moveControllableEntity(std::string id, double x, double y, double z);
+
 // ### API END ################################################################
 
 private:



More information about the Orxonox-commit mailing list