[Orxonox-commit 5396] r10059 - in code/branches/ScriptableController: data/levels src/orxonox/controllers

samuezu at orxonox.net samuezu at orxonox.net
Thu May 15 17:09:35 CEST 2014


Author: samuezu
Date: 2014-05-15 17:09:35 +0200 (Thu, 15 May 2014)
New Revision: 10059

Modified:
   code/branches/ScriptableController/data/levels/levelTry.oxw
   code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.cc
   code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc
   code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h
Log:
works more or less, but big trouble accessing the scriptableController-controlled entity

Modified: code/branches/ScriptableController/data/levels/levelTry.oxw
===================================================================
--- code/branches/ScriptableController/data/levels/levelTry.oxw	2014-05-15 13:53:11 UTC (rev 10058)
+++ code/branches/ScriptableController/data/levels/levelTry.oxw	2014-05-15 15:09:35 UTC (rev 10059)
@@ -71,8 +71,8 @@
     </StaticEntity>
 
 
-    <Billboard position="500,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=10 />
-    <DistanceTrigger position="0,0,0" distance="200" target="Pawn"
+    <Billboard position="3500,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=10 />
+    <DistanceTrigger position="3500,0,0" distance="200" target="Pawn"
       beaconMode="exclude" targetname="bcnDestroyer" name="takeControl"
     />
 

Modified: code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.cc
===================================================================
--- code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.cc	2014-05-15 13:53:11 UTC (rev 10058)
+++ code/branches/ScriptableController/src/orxonox/controllers/ControllerDirector.cc	2014-05-15 15:09:35 UTC (rev 10059)
@@ -90,7 +90,7 @@
        std::stringstream tmp;
        tmp << "newctrlid = " << ctrlid;
        std::string todo = tmp.str();
-
+       
        /* Run the string using the luastate created earlier */
        ls->doString(todo);
 

Modified: code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc
===================================================================
--- code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc	2014-05-15 13:53:11 UTC (rev 10058)
+++ code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc	2014-05-15 15:09:35 UTC (rev 10059)
@@ -124,6 +124,9 @@
 
     void ScriptController::tick(float dt)
     {
+
+        
+
         /* If this controller has no entity entry, do nothing */
         if( !(this->entity_) )
           return;
@@ -151,16 +154,30 @@
 
     void ScriptController::moveToPosition_beta(float x, float y, float z )
     {
+
+        orxout()<<"moveToPosition_beta executed"<<endl;
         //const Vector3 local = this->getPosition();
         const Vector3 target = Vector3(100*x,100*y,100*z);
         //Vector3 way = target-local;
         orxout() << "Moving This-pointer: " << this << endl;
        
         
-        this->entity_->lookAt(target);
-        this->entity_->moveFrontBack(-1000*target.length());      
+        //this->entity_->lookAt(target);
+        //this->entity_->moveFrontBack(-1000*target.length());      
 
-  
+        if(this->entity_!=NULL)
+            orxout()<<"not-NULL-entity"<<endl;
+
+        if(this->player_!=NULL)
+            orxout()<<"not-NULL-player"<<endl;
+
+        orxout() << this->player_->getClientID() << endl; // IMPOSSIBLE TO ACCESS this->player AND this->entity
+        
+        //this->entity_ = this->player_->getClientID();//getControllableEntity();
+
+            //if(this->entity_==this->player_->getControllableEntity())
+            //orxout()<<"same entity"<<endl;
+
         /* This works fine */
         orxout()<<x<<"  "<<y<<"  "<<z<<endl;
     }
@@ -168,6 +185,7 @@
     void ScriptController::eventScheduler(std::string instruction, float x, float y, float z, float executionTime)
     {
 
+
         /*put data (from LUA) into time-sorted eventList*/ 
         /*nimmt den befehl und die argumente aus luascript und ertellt einen struct pro event, diese structs werden sortiert nach eventTime*/
         struct event tmp;
@@ -177,26 +195,35 @@
         tmp.zCoord=z;
         tmp.eventTime=executionTime;
 
-        for(unsigned int i=0;i<eventList.size();i++)
+        orxout()<<tmp.fctName<<endl;
+
+        if(eventList.size()==0)
         {
-            if(tmp.eventTime<eventList[i].eventTime)
-            {
-                std::vector<event>::iterator it = eventList.begin();
+            orxout()<<"eventList empty (01)"<<endl;
+            eventList.insert(eventList.begin(), tmp);
+            orxout()<<"first event added"<<endl;
+        }
 
-                eventList.insert(it+(i+1),tmp);
-                break;
-            }
-            if(i==eventList.size()-1)
+
+       for (std::vector<event>::iterator it=eventList.begin(); it<eventList.end(); it++)
             {
-                std::vector<event>::iterator it = eventList.end();
 
-                eventList.insert(it,tmp);
+                if(tmp.eventTime<it->eventTime)
+                {
+                    eventList.insert(it,tmp);
+                    orxout()<<"new event added"<<endl;
+                }
 
             }
 
-        }
+       
+       if(eventList.size()==0)
+            orxout()<<"eventList empty"<<endl;
+
+        else
+            orxout()<<"eventList is not empty"<<endl;
+
         
-        
     }
 
 

Modified: code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h
===================================================================
--- code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h	2014-05-15 13:53:11 UTC (rev 10058)
+++ code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h	2014-05-15 15:09:35 UTC (rev 10059)
@@ -63,6 +63,8 @@
             void takeControl(int ctrlid);
             void setPlayer(PlayerInfo* player) { this->player_ = player; }
            
+           
+
             //void set_luasrc(std::string);
             //void set_controlled(ControllableEntity*);
 




More information about the Orxonox-commit mailing list