1 | |
---|
2 | #include "scriptable_controller_api.h" |
---|
3 | #include <chrono> |
---|
4 | #include "lua.hpp" |
---|
5 | #include "luatb.h" |
---|
6 | #include "scriptable_controller.h" |
---|
7 | |
---|
8 | namespace orxonox |
---|
9 | { |
---|
10 | |
---|
11 | ScriptableControllerAPI::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 | |
---|
25 | ScriptableControllerAPI::~ScriptableControllerAPI() |
---|
26 | { |
---|
27 | lua_close(this->lua_); |
---|
28 | } |
---|
29 | |
---|
30 | void ScriptableControllerAPI::registerAfterTimeout(std::function<void (void)> callback, double timeout) |
---|
31 | { |
---|
32 | this->controller_->registerTimeout(callback, timeout); |
---|
33 | } |
---|
34 | |
---|
35 | int ScriptableControllerAPI::registerAtNearObject(std::function<void (int, int)> callback, int obj1, int obj2, double distance) |
---|
36 | { |
---|
37 | orxout(user_warning) << "Working!" << std::endl; |
---|
38 | } |
---|
39 | |
---|
40 | int 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 | |
---|
45 | int 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 | |
---|
50 | int ScriptableControllerAPI::registerAtObjectDestroyed(std::function<void (int)> callback, int obj) |
---|
51 | { |
---|
52 | |
---|
53 | } |
---|
54 | |
---|
55 | int ScriptableControllerAPI::registerAtPickup(std::function<void (int)> callback, int pickup_id) |
---|
56 | { |
---|
57 | |
---|
58 | } |
---|
59 | |
---|
60 | } |
---|