Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 11552 was 11552, checked in by kohlia, 6 years ago

Lua bindings should work now

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