[Orxonox-commit 7319] r11936 - in code/branches/ScriptableController_FS18: data/levels data/levels/scripts src/orxonox/scriptablecontroller

adamc at orxonox.net adamc at orxonox.net
Thu May 3 16:01:24 CEST 2018


Author: adamc
Date: 2018-05-03 16:01:23 +0200 (Thu, 03 May 2018)
New Revision: 11936

Modified:
   code/branches/ScriptableController_FS18/data/levels/AAAScriptableControllerTest.oxw
   code/branches/ScriptableController_FS18/data/levels/scripts/AAAScriptableControllerTest.lua
   code/branches/ScriptableController_FS18/data/levels/scripts/BBBScriptableControllerTest.lua
   code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.cc
Log:
Trying to spawn entity (2nd attempt)

Modified: code/branches/ScriptableController_FS18/data/levels/AAAScriptableControllerTest.oxw
===================================================================
--- code/branches/ScriptableController_FS18/data/levels/AAAScriptableControllerTest.oxw	2018-05-03 13:57:08 UTC (rev 11935)
+++ code/branches/ScriptableController_FS18/data/levels/AAAScriptableControllerTest.oxw	2018-05-03 14:01:23 UTC (rev 11936)
@@ -1,6 +1,6 @@
 <LevelInfo
  name = "AAAScriptableControllerTest"
- description = "A level with absolutely nothing in it."
+ description = "Demonstrates moving and killing a drone by use of a script."
  tags = "test"
  screenshot = "emptylevel.png"
 />
@@ -29,14 +29,20 @@
   >
 
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
-    <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
+    <SpawnPoint team=0 position="100,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
 
 
-    <ModularSpaceShip id="Station" velocity= "0,0,0" position="50000000,0,0" lookat= "0,0,0" health="500" maxhealth="500" initialhealth="500">
-      <templates>
-        <Template link=endurance />
-      </templates>
-    </ModularSpaceShip>
+  <AAAAutonomousDrone id="dummy" position="0,0,0">
+    <attached>
+      <Model scale="10" mesh="drone.mesh"/>
+    </attached>
+    <collisionShapes>
+      <BoxCollisionShape position="0,0,0" halfExtents="10, 10, 10" />
+    </collisionShapes>
+  </AAAAutonomousDrone>
     
+  
+
+
   </Scene>
 </Level>

Modified: code/branches/ScriptableController_FS18/data/levels/scripts/AAAScriptableControllerTest.lua
===================================================================
--- code/branches/ScriptableController_FS18/data/levels/scripts/AAAScriptableControllerTest.lua	2018-05-03 13:57:08 UTC (rev 11935)
+++ code/branches/ScriptableController_FS18/data/levels/scripts/AAAScriptableControllerTest.lua	2018-05-03 14:01:23 UTC (rev 11936)
@@ -1,8 +1,11 @@
 
-rotate_factor = 0
-station_loc = 200
-station_speed = 0
+rotate_factor = 0.0
+station_loc = 200.0
+station_speed = 0.0
 
+id = "dummy"
+
+
 function spawn_station(obj)
 	orxPrint("Spawning station")
 	setPosition("Station", 500, 0, 0)
@@ -9,6 +12,7 @@
 	setOrientation("Station", 0, -1, 0, 0)
 end
 
+
 function rotate_faster(obj1, obj2, health, shield)
 	orxPrint("Rotating station faster")
 
@@ -22,6 +26,7 @@
 	killPawn("Player")
 end
 
+
 function kill_player_after_timeout(pawn)
 	orxPrint("Killing player after 5s")
 
@@ -28,6 +33,7 @@
 	registerAfterTimeout(kill_player, 5)
 end
 
+
 function next_station_loc(obj1, obj2)
 	orxPrint("Moving station")
 
@@ -41,10 +47,53 @@
 end
 
 
+function kill_player()
+	orxPrint("Killing player")
+	killPawn("Player")
+end
 
 
+function kill_dummy()
+	orxPrint("Killing dummy!")
+	killPawn(id)
+end
 
+
+function kill_player_after_timeout(pawn)
+	orxPrint("Killing player after 5s")
+
+	registerAfterTimeout(kill_player, 5)
+end
+
+
+function kill_dummy_after_timeout(seconds)
+	orxPrint("Killing dummy after " .. tostring(seconds))
+	registerAfterTimeout(kill_dummy, seconds)
+end
+
+
+function move_dummy()
+	orxPrint("Moving dummy!")
+	moveControllableEntity(id, 1.0, 0.0, 0.0)
+end
+
+
+function move_dummy_after_timeout(seconds)
+	orxPrint("Moving dummy after " .. tostring(seconds))
+
+	registerAfterTimeout(move_dummy, seconds)
+end
+
+
+
+
+move_dummy_after_timeout(5)
+kill_dummy_after_timeout(10)
+
+
 orxPrint("Script started! OMG ROFL LOL WTF")
 mytestfunction(3.0, 4.0)
-spawn("ModularSpaceShip","Station2")
 
+
+spawn("ModularSpaceShip", "sepp")
+setPosition("sepp", 500, 0, 0)

Modified: code/branches/ScriptableController_FS18/data/levels/scripts/BBBScriptableControllerTest.lua
===================================================================
--- code/branches/ScriptableController_FS18/data/levels/scripts/BBBScriptableControllerTest.lua	2018-05-03 13:57:08 UTC (rev 11935)
+++ code/branches/ScriptableController_FS18/data/levels/scripts/BBBScriptableControllerTest.lua	2018-05-03 14:01:23 UTC (rev 11936)
@@ -2,7 +2,6 @@
 id = "dummy"
 
 
-
 function kill_player()
 	orxPrint("Killing player")
 	killPawn("Player")
@@ -21,6 +20,7 @@
 	registerAfterTimeout(kill_player, 5)
 end
 
+
 function kill_dummy_after_timeout(seconds)
 	orxPrint("Killing dummy after " .. tostring(seconds))
 	registerAfterTimeout(kill_dummy, seconds)
@@ -32,9 +32,9 @@
 	moveControllableEntity(id, 1.0, 0.0, 0.0)
 end
 
+
 function move_dummy_after_timeout(seconds)
 	orxPrint("Moving dummy after " .. tostring(seconds))
-
 	registerAfterTimeout(move_dummy, seconds)
 end
 

Modified: code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.cc
===================================================================
--- code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.cc	2018-05-03 13:57:08 UTC (rev 11935)
+++ code/branches/ScriptableController_FS18/src/orxonox/scriptablecontroller/scriptable_controller_api.cc	2018-05-03 14:01:23 UTC (rev 11936)
@@ -393,7 +393,7 @@
         MobileEntity *entity = this->controller_->getMobileEntityByID(id);
         if(entity == nullptr)
         {
-            orxout(user_warning) << "Trying to set velocity of an unknown object" << std::endl;
+            orxout(user_warning) << "Trying to move an unknown object" << std::endl;
             return;
         }
 
@@ -406,7 +406,7 @@
         if(identifier->isA(ClassIdentifier<ControllableEntity>::getIdentifier()))
         {
             controllable_entity = orxonox_cast<ControllableEntity*>(entity);
-
+            //ATTACHED COLLISION SHAPE is MANDATORY in order to move the entity
             controllable_entity->moveFrontBack(x);
             controllable_entity->moveRightLeft(y);
             controllable_entity->moveUpDown(z);



More information about the Orxonox-commit mailing list