Orxonox  0.0.5 Codename: Arcturus
scriptable_controller.h
Go to the documentation of this file.
1 #ifndef SCRIPTABLE_CONTROLLER_H
2 #define SCRIPTABLE_CONTROLLER_H
3 
4 #include <lua.hpp>
5 #include <string>
6 #include <list>
7 #include <map>
8 #include <memory>
10 #include "core/CoreIncludes.h"
13 #include "tools/Timer.h"
14 
15 
16 struct lua_State;
17 
18 namespace orxonox
19 {
20 
32 {
33 public:
41  int runScript(const std::string &file_path);
42 
49  void setPlayer(PlayerInfo *player);
50 
60 
70 
79  void registerPawn(std::string id, Pawn *pawn);
80 
87  void pawnKilled(Pawn *pawn);
88 
98  void pawnHit(Pawn *target, Pawn *source, double new_health, double new_shield);
99 
106 
113 
119  Pawn *getPawnByID(std::string id) const;
120 
121 private:
122  std::list<std::unique_ptr<ScriptableControllerAPI> > apis_;
124  std::map<std::string, WorldEntity*> worldEntities_;
125  std::map<std::string, MobileEntity*> mobileEntities_;
126  std::map<std::string, Pawn*> pawns_;
127  std::map<Pawn*, std::string> pawnsReverse_;
128  std::map<std::string, ControllableEntity*> controllabelEntities_;
129 
134  void printLuaError(lua_State *lua);
135 };
136 
137 }
138 
139 #endif // SCRIPTABLE_CONTROLLER_H
Everything in Orxonox that has a health attribute is a Pawn.
Definition: Pawn.h:56
Runs a scripts on a per-level basis and handles the connection to orxonox.
Definition: scriptable_controller.h:31
void source(const std::string &filename)
Reads the content of a file and executes the commands in it line by line.
Definition: ConsoleCommandCompilation.cc:167
void pawnKilled(Pawn *pawn)
Called when a Pawn is killed.
Definition: scriptable_controller.cc:81
void setPlayer(PlayerInfo *player)
Set the player object of the current game.
Definition: scriptable_controller.cc:60
void printLuaError(lua_State *lua)
Prints a human readable error message if a lua error occurs.
Definition: scriptable_controller.cc:150
::std::string string
Definition: gtest-port.h:756
MobileEntity * getMobileEntityByID(std::string id) const
Convert an ID to a MobileEntity pointer.
Definition: scriptable_controller.cc:124
std::list< std::unique_ptr< ScriptableControllerAPI > > apis_
Definition: scriptable_controller.h:122
std::map< std::string, MobileEntity * > mobileEntities_
Definition: scriptable_controller.h:125
std::map< std::string, Pawn * > pawns_
Definition: scriptable_controller.h:126
WorldEntity * getWorldEntityByID(std::string id) const
Convert an ID to a WorldEntity pointer.
Definition: scriptable_controller.cc:115
void registerWorldEntity(std::string id, WorldEntity *entity)
Register a WorldEntity to the ScriptableController.
Definition: scriptable_controller.cc:65
The WorldEntity represents everything that can be put in a Scene at a certain location.
Definition: WorldEntity.h:72
int runScript(const std::string &file_path)
Run a lua script.
Definition: scriptable_controller.cc:12
std::map< std::string, ControllableEntity * > controllabelEntities_
Definition: scriptable_controller.h:128
The MobileEntity is a derived class from orxonox::WorldEntity and orxonox::Tickable.
Definition: MobileEntity.h:53
Declaration of the Timer class, used to call functions after a given time-interval.
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
void registerPawn(std::string id, Pawn *pawn)
Register a Pawn to the ScriptableController.
Definition: scriptable_controller.cc:75
Pawn * getPawnByID(std::string id) const
Convert an ID to a Pawt pointer.
Definition: scriptable_controller.cc:133
Defines several very important macros used to register objects, register classes, and to work with id...
void pawnHit(Pawn *target, Pawn *source, double new_health, double new_shield)
Called when a Pawn is hit.
Definition: scriptable_controller.cc:99
void registerMobileEntity(std::string id, MobileEntity *entity)
Register a MobileEntity to the ScriptableController.
Definition: scriptable_controller.cc:70
std::map< Pawn *, std::string > pawnsReverse_
Definition: scriptable_controller.h:127
The Scripts&#39; code is executed through lua.
Definition: PlayerInfo.h:39
PlayerInfo * player_
Definition: scriptable_controller.h:123
std::map< std::string, WorldEntity * > worldEntities_
Definition: scriptable_controller.h:124