Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ScriptableController_HS17/src/orxonox/scriptablecontroller/scriptable_controller_api.cc @ 11562

Last change on this file since 11562 was 11562, checked in by kohlia, 7 years ago

Figuring out when the different things are ready in orxonox

File size: 2.7 KB
Line 
1
2#include "scriptable_controller_api.h"
3#include "luatb.h"
4#include "scriptable_controller.h"
5#include "tools/Timer.h"
6
7namespace orxonox
8{
9
10ScriptableControllerAPI::ScriptableControllerAPI(lua_State *lua, ScriptableController *controller)
11{
12    this->lua_ = lua;
13    this->controller_ = controller;
14
15    // Haven't found a shorter way yet to write that...
16    LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::orxPrint)>::registerFunction<&ScriptableControllerAPI::orxPrint>(this, lua, "orxPrint");
17    LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAfterTimeout)>::registerFunction<&ScriptableControllerAPI::registerAfterTimeout>(this, lua, "registerAfterTimeout");
18    LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAtNearObject)>::registerFunction<&ScriptableControllerAPI::registerAtNearObject>(this, lua, "registerAtNearObject");
19    LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAtAreaEnter)>::registerFunction<&ScriptableControllerAPI::registerAtAreaEnter>(this, lua, "registerAtAreaEnter");
20    LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAtAreaLeave)>::registerFunction<&ScriptableControllerAPI::registerAtAreaLeave>(this, lua, "registerAtAreaLeave");
21    LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAtObjectDestroyed)>::registerFunction<&ScriptableControllerAPI::registerAtObjectDestroyed>(this, lua, "registerAtObjectDestroyed");
22    LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAtPickup)>::registerFunction<&ScriptableControllerAPI::registerAtPickup>(this, lua, "registerAtPickup");
23}
24
25ScriptableControllerAPI::~ScriptableControllerAPI()
26{
27    lua_close(this->lua_);
28}
29
30void ScriptableControllerAPI::orxPrint(std::string msg)
31{
32    orxout(user_info) << msg << std::endl;
33}
34
35void ScriptableControllerAPI::registerAfterTimeout(std::function<void (void)> callback, double timeout)
36{
37    // Kills itself when the timer fires
38    new Timer(timeout, false, callback, true);
39}
40
41int ScriptableControllerAPI::registerAtNearObject(std::function<void (int, int)> callback, int obj1, int obj2, double distance)
42{
43    //this->controller_->addNearObjectHandler(obj1, obj1, distance, callback);
44}
45
46int ScriptableControllerAPI::registerAtAreaEnter(std::function<void (int)> callback, int obj, int x, int y, int z, int dx, int dy, int dz)
47{
48
49}
50
51int ScriptableControllerAPI::registerAtAreaLeave(std::function<void (int)> callback, int obj, int x, int y, int z, int dx, int dy, int dz)
52{
53
54}
55
56int ScriptableControllerAPI::registerAtObjectDestroyed(std::function<void (int)> callback, int obj)
57{
58
59}
60
61int ScriptableControllerAPI::registerAtPickup(std::function<void (int)> callback, int pickup_id)
62{
63
64}
65
66}
Note: See TracBrowser for help on using the repository browser.