[Orxonox-commit 5365] r10028 - code/branches/ScriptableController/src/orxonox/controllers
samuezu at orxonox.net
samuezu at orxonox.net
Thu Apr 10 15:40:57 CEST 2014
Author: samuezu
Date: 2014-04-10 15:40:57 +0200 (Thu, 10 Apr 2014)
New Revision: 10028
Modified:
code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc
code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h
Log:
compiles now
Modified: code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc
===================================================================
--- code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc 2014-04-10 13:39:32 UTC (rev 10027)
+++ code/branches/ScriptableController/src/orxonox/controllers/ScriptController.cc 2014-04-10 13:40:57 UTC (rev 10028)
@@ -28,42 +28,62 @@
#include "ScriptController.h"
#include "core/CoreIncludes.h"
+#include "worldentities/ControllableEntity.h"
namespace orxonox
{
RegisterClass(ScriptController);
- ScriptController::ScriptController(Context* context, ControllableEntity CE) : ArtificialController(context)
+ //ScriptController::ScriptController(Context* context, ControllableEntity* CE) : ArtificialController(context)
+ ScriptController::ScriptController(Context* context) : ArtificialController(context)
{
RegisterObject(ScriptController);
- set_controlled(CE);
+ //set_controlled(CE);
}
- void set_luasrc(std::string lsrc)
+ void ScriptController::set_luasrc(std::string lsrc)
{
this->luasrc=lsrc;
}
- void set_controlled(*ControllableEntity toControl)
+ void ScriptController::set_controlled(ControllableEntity* toControl)
{
this->controlled=toControl;
}
void ScriptController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
- XMLPort(ScriptController, BaseObject, "lsrc", set_luasrc, xmlelement, mode);
+ //XMLPortParam(ScriptController, BaseObject, "lsrc", set_luasrc, xmlelement, mode);
}
void ScriptController::moveToPosition(const Vector3& target)
{
+
+ /*this->controlled_->rotateYaw(-sgn(coord.x)*coord.x*coord.x);
+ this->controlled_->rotatePitch(sgn(coord.y)*coord.y*coord.y);*/
+ }
+ /*void WaypointController::tick(float dt) //copied from waypointcontroller
+ {
+ if (!this->isActive())
+ return;
- }
+ if (this->waypoints_.size() == 0 || !this->getControllableEntity())
+ return;
+
+ if (this->waypoints_[this->currentWaypoint_]->getWorldPosition().squaredDistance(this->getControllableEntity()->getPosition()) <= this->squaredaccuracy_)
+ this->currentWaypoint_ = (this->currentWaypoint_ + 1) % this->waypoints_.size();
+
+ this->moveToPosition(this->waypoints_[this->currentWaypoint_]->getWorldPosition());
+ }*/
+
/* TO DO
in the constuctor: make accessible functions such as moveToPosition.. in LUA
->tolua++ example: http://usefulgamedev.weebly.com/tolua-example.html*/
+
+
//function to execute the luafile
Modified: code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h
===================================================================
--- code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h 2014-04-10 13:39:32 UTC (rev 10027)
+++ code/branches/ScriptableController/src/orxonox/controllers/ScriptController.h 2014-04-10 13:40:57 UTC (rev 10028)
@@ -29,17 +29,20 @@
#ifndef _ScriptController_H__
#define _ScriptController_H__
-#include "OrxonoxPrereqs.h"
+#include "OrxonoxPrereqs.h" /* die ganzen tolua, kopiert aus Dock.h*/
#include "ArtificialController.h"
#include "core/EventIncludes.h"
-namespace orxonox
-{
- class _OrxonoxExport ScriptController : public ArtificialController
- {
+namespace orxonox // tolua_export
+{ // tolua_export
+ class _OrxonoxExport ScriptController // tolua_export
+ : public ArtificialController
+ { // tolua_export
public:
- ScriptController(Context* context, ControllableEntity CE);
+ //ScriptController(Context* context, ControllableEntity* CE);
+ ScriptController(Context* context);
+
virtual ~ScriptController() { }
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
@@ -47,18 +50,19 @@
void set_luasrc(std::string);
- void set_controlled(*ControllableEntity);
+ void set_controlled(ControllableEntity*);
+
+ // LUA interface
+ // tolua_begin
void moveToPosition(const Vector3& target);
- /* TO DO
- - in the constuctor: make accessible functions such as moveToPoint.. in LUA
- ->tolua++ example: http://usefulgamedev.weebly.com/tolua-example.html*/
+
-
+ /* virtual void tick(float dt);*/
- //function to execute the luafile
+ // tolua_end
private:
std::string luasrc; // name of the LUA-sourcefile that shall be executed->see XMLPort-function
@@ -66,7 +70,7 @@
ControllableEntity* controlled; //entity controlled by this SC
- };
-}
+ };// tolua_export
+} // tolua_export
#endif /* _ScriptController_H__ */
More information about the Orxonox-commit
mailing list