Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Not working yet

File size: 2.4 KB
Line 
1
2#include "scriptable_controller_api.h"
3#include <chrono>
4#include "lua.hpp"
5#include "luatb.h"
6#include "scriptable_controller.h"
7
8namespace orxonox
9{
10
11ScriptableControllerAPI::ScriptableControllerAPI(lua_State *lua, ScriptableController *controller)
12{
13    this->lua_ = lua;
14    this->controller_ = controller;
15
16    // Haven't found a shorter way yet to write that...
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::registerAfterTimeout(std::function<void (void)> callback, double timeout)
31{
32    this->controller_->registerTimeout(callback, timeout);
33}
34
35int ScriptableControllerAPI::registerAtNearObject(std::function<void (int, int)> callback, int obj1, int obj2, double distance)
36{
37    orxout(user_warning) << "Working!" << std::endl;
38}
39
40int ScriptableControllerAPI::registerAtAreaEnter(std::function<void (int)> callback, int obj, int x, int y, int z, int dx, int dy, int dz)
41{
42
43}
44
45int ScriptableControllerAPI::registerAtAreaLeave(std::function<void (int)> callback, int obj, int x, int y, int z, int dx, int dy, int dz)
46{
47
48}
49
50int ScriptableControllerAPI::registerAtObjectDestroyed(std::function<void (int)> callback, int obj)
51{
52
53}
54
55int ScriptableControllerAPI::registerAtPickup(std::function<void (int)> callback, int pickup_id)
56{
57
58}
59
60}
Note: See TracBrowser for help on using the repository browser.