[Orxonox-commit 5839] r10499 - in code/branches/presentationFS15: data/gui/scripts data/levels data/levels/templates src/orxonox/controllers
maxima at orxonox.net
maxima at orxonox.net
Wed May 27 14:36:08 CEST 2015
Author: maxima
Date: 2015-05-27 14:36:07 +0200 (Wed, 27 May 2015)
New Revision: 10499
Added:
code/branches/presentationFS15/data/gui/scripts/presentation.lua
Modified:
code/branches/presentationFS15/data/gui/scripts/testscript.lua
code/branches/presentationFS15/data/levels/scriptController.oxw
code/branches/presentationFS15/data/levels/templates/spaceshipRing.oxt
code/branches/presentationFS15/src/orxonox/controllers/ControllerDirector.cc
code/branches/presentationFS15/src/orxonox/controllers/ControllerDirector.h
Log:
New XMLPort for ControllerDirector. The name of the script can now be set via XMLPort. Level scriptController plays the new Script 'presentation.lua'
Added: code/branches/presentationFS15/data/gui/scripts/presentation.lua
===================================================================
--- code/branches/presentationFS15/data/gui/scripts/presentation.lua (rev 0)
+++ code/branches/presentationFS15/data/gui/scripts/presentation.lua 2015-05-27 12:36:07 UTC (rev 10499)
@@ -0,0 +1,40 @@
+-- Set some test variables
+xm = 1000
+ym = 0
+zm = 0
+
+xl = -1000
+yl = 3000
+zl = -1000
+
+xr = 2000
+yr = 500
+zr = 2000
+
+d = 5
+Tabs = 0
+
+pi = 3.1415
+
+-- Get a local pointer to a scriptcontroller
+local ctrl = orxonox.ScriptController:getScriptController()
+
+-- If it worked, call its "movetoposition" function
+if ctrl ~= nil then
+
+ ctrl:eventScheduler("mal", xl,yl,zl, xl,yl,zl, 2)
+ ctrl:eventScheduler("idle", 1)
+ ctrl:eventScheduler("ral", xl, yl, zl, 3, 0, 0, math.pi)
+ ctrl:eventScheduler("idle", 1)
+ ctrl:eventScheduler("mal", 0,0,1000, xl,yl,zl, 3)
+ ctrl:eventScheduler("idle", 1)
+ ctrl:eventScheduler("chl", xl, yl, zl, xr, yr, zr, 2)
+ ctrl:eventScheduler("idle", 1)
+ ctrl:eventScheduler("mal", xr + 600,yr,zr, xr,yr,zr, 4)
+ ctrl:eventScheduler("idle", 1)
+ ctrl:eventScheduler("chl", xr, yr, zr, xl, yl, zl, 3)
+ ctrl:eventScheduler("idle", 1)
+ ctrl:eventScheduler("spi", xm,ym,zm, 0,0,0, 4)
+ ctrl:eventScheduler("idle", 1)
+
+end
\ No newline at end of file
Modified: code/branches/presentationFS15/data/gui/scripts/testscript.lua
===================================================================
--- code/branches/presentationFS15/data/gui/scripts/testscript.lua 2015-05-27 11:11:01 UTC (rev 10498)
+++ code/branches/presentationFS15/data/gui/scripts/testscript.lua 2015-05-27 12:36:07 UTC (rev 10499)
@@ -37,11 +37,4 @@
ctrl:eventScheduler("spi", xm,ym,zm, 0,0,0, 4)
ctrl:eventScheduler("idle", 1)
-end
-
--- Output the newctrlid variable we set from the C++ code
-if newctrlid ~= nil then
- orxonox.execute("orxout message test " .. newctrlid)
-end
-
---orxonox.execute("setPause 1")
\ No newline at end of file
+end
\ No newline at end of file
Modified: code/branches/presentationFS15/data/levels/scriptController.oxw
===================================================================
--- code/branches/presentationFS15/data/levels/scriptController.oxw 2015-05-27 11:11:01 UTC (rev 10498)
+++ code/branches/presentationFS15/data/levels/scriptController.oxw 2015-05-27 12:36:07 UTC (rev 10499)
@@ -1,7 +1,7 @@
<!-- First levelFile of mkronig and samuezu. It was copied from dockingToASpaceStation.oxw and modified a little bit -->
<LevelInfo
- name = "Fancy orxout tests"
- description = "Docking into a spacestation."
+ name = "Scriptable Controller"
+ description = "Showcase for Scriptable Controller"
tags = "showcase"
screenshot = "emptylevel.png"
/>
@@ -10,17 +10,10 @@
include("stats.oxo")
include("HUDTemplates3.oxo")
include("templates/lodInformation.oxt")
- include("templates/pickupRepresentationTemplates.oxt")
?>
<?lua
- include("templates/spaceshipAssff.oxt")
- include("templates/spaceshipPirate.oxt")
include("templates/spaceshipEscort.oxt")
- include("templates/bigship.oxt")
- include("templates/spaceshipTurret.oxt")
- include("templates/spaceshipCollateralDamage.oxt")
- include("templates/FPS.oxt")
?>
<Level
@@ -39,160 +32,36 @@
hasPhysics = true
>
- <?lua
- include("includes/pickups.oxi")
- ?>
-
<Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0,1.0,1.0,0.5" specular="1.0, 0.9, 0.9, 1.0"/>
+
<SpawnPoint team=0 position="3200,0,0" lookat="2800,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort />
- <StaticEntity position = "2800,0,0" mass=10000 collisionType=static >
- <attached>
- <Model mesh="HydroHarvester.mesh" mass=10 position="0,0,0" scale=50 />
- </attached>
- <collisionShapes>
- <BoxCollisionShape position="-560,0,0" halfExtents="115,100,245" /><!-- Three lower boxes -->
- <BoxCollisionShape position="290,0,-480" halfExtents="115,100,245" yaw=-120 />
- <BoxCollisionShape position="290,0,480" halfExtents="115,100,245" yaw=-240 />
- <BoxCollisionShape position="-280,0,0" halfExtents="163,50,50" /><!-- Three lower connections -->
- <BoxCollisionShape position="140,0,-240" halfExtents="163,50,50" yaw=-120 />
- <BoxCollisionShape position="140,0,240" halfExtents="163,50,50" yaw=-240 />
- <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" /><!-- Upper Tower -->
- <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" yaw=-120 />
- <BoxCollisionShape position="0,530,0" halfExtents="172,52,298" yaw=-240 />
- <BoxCollisionShape position="0,400,0" halfExtents="43,110,26" yaw=-30 /><!-- Middle one-->
- <BoxCollisionShape position="-200,100,0" halfExtents="26,50,43" /><!--Three lower legs -->
- <BoxCollisionShape position="100,100,-173" halfExtents="43,50,26" yaw=-30 />
- <BoxCollisionShape position="100,100,-173" halfExtents="43,50,26" yaw=30 />
- <BoxCollisionShape position="-100,264,0" halfExtents="26,105,43" roll=-49 /><!--Three upper legs -->
- <BoxCollisionShape position="50,264,-87" halfExtents="26,105,43" roll=-49 yaw=-120 />
- <BoxCollisionShape position="50,264,87" halfExtents="26,105,43" roll=-49 yaw=-240 />
- </collisionShapes>
- </StaticEntity>
-
-<!-- Docking -->
- <Dock position="2830,20,50" roll=0 yaw=0 >
- <animations>
- <MoveToDockingTarget target="destroyer" />
- </animations>
- <effects>
- <DockToShip target="spaceShip" />
- </effects>
- <events>
- <execute>
- <EventListener event="dockMe" />
- </execute>
-
- <undocking>
- <EventListener event="undockMe" />
- </undocking>
-
- <activity>
- <EventListener event=notGameEnd />
- </activity>
- </events>
- <attached>
- <!-- Trigger for docking with billboard -->
-
- <!-- removed -->
-
- <!-- Trigger for undocking with billboard -->
- <!-- <Billboard position="-2630,-19970,150" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=1 /> -->
- <DistanceTrigger position="-2630,-19970,150" distance="50" target="Pawn"
- beaconMode="identify" targetname="bcnDestroyer" name="undockMe"
- />
- </attached>
- </Dock>
-
- <Billboard position="0,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=100 />
- <DistanceTrigger position="0,0,0" distance="200" target="Pawn"
- beaconMode="exclude" targetname="bcnDestroyer" name="dockMe"
+ <Billboard position="2500,0,0" material="Flares/ringflare2" colour="0.2,0.4,0.8" scale=10 />
+ <DistanceTrigger position="2500,0,0" distance="200" target="Pawn"
+ beaconMode="exclude" targetname="bcnDestroyer" name="takeControl"
/>
-
-<!-- Object, which orxouts the message "hello Universe!". EVENT NOT WORKING -->
- <ScriptController position="0,0,0">
- <events>
- <party>
- <EventListener event="dockMe" />
- </party>
-
- </events>
-
- </ScriptController>
-
-
-<!-- FPS Player as destination of the dock -->
-<FpsPlayer template = "fps" radarname = "First Person Player" position = "0,-19900,0" >
+ <StaticEntity position = "2000,500,2000" mass=10000 collisionType=static >
<attached>
- <DockingTarget name="spaceShip" />
- <DistanceTriggerBeacon name="bcnDestroyer" />
- <DockingTarget name="destroyer" />
+ <Model mesh="HydroHarvester.mesh" mass=10 position="0,0,0" scale=10 />
</attached>
-</FpsPlayer>
+ </StaticEntity>
-
-<!-- Cube as test SpaceStation
-
-The station can either be hidden outside of the skybox, within the hull of the space station if it is big enough or within a planet.
-Complex spacestations can be placed very far away from the spaceship so it is rendered at low resolution while the player uses the space ship.
-
--->
- <StaticEntity position="0,-20000,0" direction="0,-1,0" collisionType=static mass=100000 friction=0.01 >
+ <StaticEntity position = "-1000,3000,-1000" mass=10000 collisionType=static >
<attached>
- <Model position="0,0,0" mesh="crate.mesh" scale3D="80,80,5" />
+ <Model mesh="HydroHarvester.mesh" mass=10 position="0,0,0" scale=80 />
</attached>
- <collisionShapes>
- <BoxCollisionShape position="0,0,0" halfExtents="400,400,25" />
- </collisionShapes>
- </StaticEntity>
+ </StaticEntity>
-<!-- Homogenous gravitationfield to simulate local gravity (activating the normal gravity will affect the spaceship terribly) -->
-<ForceField position="0,-20000,0" mode="homogen" diameter="2000" forcedirection = "0,-500,0" />
+<!-- ControllerDirector waits for the event takeControl to attach a new Controller -->
+ <ControllerDirector position="0,0,0" scriptname="presentation">
+ <events>
+ <takeControl>
+ <EventListener event="takeControl" />
+ </takeControl>
+ </events>
+ </ControllerDirector>
-
-<!-- Some more stuff -->
-
- <!-- triple large belt around the planet -->
- <?lua
- dofile("includes/asteroidField.lua")
- asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 7190, 7800, 250, 1)
- ?>
- <?lua
- dofile("includes/asteroidField.lua")
- asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 10000, 11000, 300, 1)
- ?>
- <?lua
- dofile("includes/asteroidField.lua")
- asteroidBelt(15000, 0, 0, 30, 0, 30, 30, 50, 14000, 15000, 350, 1)
- ?>
-
- <Planet
- position="15000,0,-1000"
- scale="5000"
- collisionType="dynamic"
- linearDamping="0.8"
- angularDamping="0"
- mass="10000000"
- pitch="0"
- mesh="planets/ganymede.mesh"
- atmosphere="atmosphere1"
- rotationaxis="1,0,0"
- rotationrate="1.0"
- atmospheresize="80.0f"
- imagesize="1024.0f"
- collisiondamage = 2
- enablecollisiondamage = true
- >
- <attached>
- <ForceField position="5000,0,0" mode="sphere" diameter="10000" velocity="-50" />
- </attached>
- <collisionShapes>
- <SphereCollisionShape radius="5000" position="0,0,0" />
- </collisionShapes>
- </Planet>
-
</Scene>
-
</Level>
Modified: code/branches/presentationFS15/data/levels/templates/spaceshipRing.oxt
===================================================================
--- code/branches/presentationFS15/data/levels/templates/spaceshipRing.oxt 2015-05-27 11:11:01 UTC (rev 10498)
+++ code/branches/presentationFS15/data/levels/templates/spaceshipRing.oxt 2015-05-27 12:36:07 UTC (rev 10499)
@@ -45,10 +45,6 @@
<Model position="0,0,0" yaw=90 pitch=0 roll=0 scale=4 mesh="ship.mesh" />
<Model position="11,1,-9" yaw=-90 pitch=0 roll=90 scale=0.15 mesh="ringWeapon.mesh" />
<Model position="-11,1,-9" yaw=-90 pitch=0 roll=90 scale=0.15 mesh="ringWeapon.mesh" />
-<!--Model mesh="cube.mesh" mass=10 position="0,0,3" scale3D="10,4,8" />
-<Model mesh="cube.mesh" mass=10 position="12.6,-2,3" scale3D="2.8,2.8,11" />
-<Model mesh="cube.mesh" mass=10 position="-12.6,-2,3" scale3D="2.8,2.8,11" />
-<Model mesh="cube.mesh" mass=10 position="0,0,-12" scale3D="4,4,7" /-->
</attached>
<collisionShapes>
<BoxCollisionShape position="0 ,0 , 3" halfExtents="10, 4,8" />
Modified: code/branches/presentationFS15/src/orxonox/controllers/ControllerDirector.cc
===================================================================
--- code/branches/presentationFS15/src/orxonox/controllers/ControllerDirector.cc 2015-05-27 11:11:01 UTC (rev 10498)
+++ code/branches/presentationFS15/src/orxonox/controllers/ControllerDirector.cc 2015-05-27 12:36:07 UTC (rev 10499)
@@ -40,6 +40,7 @@
void ControllerDirector::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(ControllerDirector, XMLPort, xmlelement, mode);
+ XMLPortParam(ControllerDirector, "scriptname", setScriptName, getScriptName, xmlelement, mode).defaultValues("testscript");
orxout(verbose)<< "ControllerDirector::XMLPort "
<< "An instance of ControllerDirector has been created." << endl;
@@ -82,7 +83,7 @@
}
else
return;
-
+
/* Set up a luastate to use for running the scripts */
LuaState * ls = new LuaState();
@@ -97,9 +98,9 @@
/* Now run the script on this controller. This will still have the above
* variable "newctrlid" defined, which means it can make use of it.
*/
+ std::string scr = this->scriptname_ + ".lua";
+ ls->doFile(scr);
- ls->doFile("testscript.lua");
-
/* Increase the controller ID so we have a different one for
* the next time it is triggered */
ctrlid += 1;
Modified: code/branches/presentationFS15/src/orxonox/controllers/ControllerDirector.h
===================================================================
--- code/branches/presentationFS15/src/orxonox/controllers/ControllerDirector.h 2015-05-27 11:11:01 UTC (rev 10498)
+++ code/branches/presentationFS15/src/orxonox/controllers/ControllerDirector.h 2015-05-27 12:36:07 UTC (rev 10499)
@@ -46,7 +46,10 @@
bool party(bool bTriggered, BaseObject* trigger);
virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
+ inline void setScriptName(const std::string& name) { this->scriptname_ = name; }
+ inline const std::string& getScriptName() const { return this->scriptname_; }
+
/* Take over control of a given object */
void takeControl(Controller * controller, BaseObject * trigger);
bool preparationToTakeControl(BaseObject * trigger);
@@ -54,7 +57,8 @@
// currently unused
//void setNewController(Controller * controller);
- private:
+ protected:
+ std::string scriptname_;
PlayerInfo* player_;
ControllableEntity* entity_;
PlayerTrigger * pTrigger_;
More information about the Orxonox-commit
mailing list