1 | |
---|
2 | #include "scriptable_controller_api.h" |
---|
3 | #include "luatb.h" |
---|
4 | #include "scriptable_controller.h" |
---|
5 | #include "tools/Timer.h" |
---|
6 | |
---|
7 | namespace orxonox |
---|
8 | { |
---|
9 | |
---|
10 | ScriptableControllerAPI::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 | |
---|
25 | ScriptableControllerAPI::~ScriptableControllerAPI() |
---|
26 | { |
---|
27 | lua_close(this->lua_); |
---|
28 | } |
---|
29 | |
---|
30 | void ScriptableControllerAPI::orxPrint(std::string msg) |
---|
31 | { |
---|
32 | orxout(user_info) << msg << std::endl; |
---|
33 | } |
---|
34 | |
---|
35 | void 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 | |
---|
41 | int 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 | |
---|
46 | int 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 | |
---|
51 | int 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 | |
---|
56 | int ScriptableControllerAPI::registerAtObjectDestroyed(std::function<void (int)> callback, int obj) |
---|
57 | { |
---|
58 | |
---|
59 | } |
---|
60 | |
---|
61 | int ScriptableControllerAPI::registerAtPickup(std::function<void (int)> callback, int pickup_id) |
---|
62 | { |
---|
63 | |
---|
64 | } |
---|
65 | |
---|
66 | } |
---|