| 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::this_; |
|---|
| 12 | |
|---|
| 13 | ScriptableControllerAPI::ScriptableControllerAPI(lua_State *lua, ScriptableController *controller) |
|---|
| 14 | { |
|---|
| 15 | this->lua_ = lua; |
|---|
| 16 | this->controller_ = controller; |
|---|
| 17 | ScriptableControllerAPI::this_ = this; |
|---|
| 18 | |
|---|
| 19 | // Haven't found a shorter way yet to write that... |
|---|
| 20 | LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::testOutput)>::registerFunction<&ScriptableControllerAPI::testOutput>(this, lua, "testOutput"); |
|---|
| 21 | LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAfterTimeout)>::registerFunction<&ScriptableControllerAPI::registerAfterTimeout>(this, lua, "registerAfterTimeout"); |
|---|
| 22 | LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAtNearObject)>::registerFunction<&ScriptableControllerAPI::registerAtNearObject>(this, lua, "registerAtNearObject"); |
|---|
| 23 | LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAtAreaEnter)>::registerFunction<&ScriptableControllerAPI::registerAtAreaEnter>(this, lua, "registerAtAreaEnter"); |
|---|
| 24 | LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAtAreaLeave)>::registerFunction<&ScriptableControllerAPI::registerAtAreaLeave>(this, lua, "registerAtAreaLeave"); |
|---|
| 25 | LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAtObjectDestroyed)>::registerFunction<&ScriptableControllerAPI::registerAtObjectDestroyed>(this, lua, "registerAtObjectDestroyed"); |
|---|
| 26 | LuaTB<ScriptableControllerAPI, decltype(&ScriptableControllerAPI::registerAtPickup)>::registerFunction<&ScriptableControllerAPI::registerAtPickup>(this, lua, "registerAtPickup"); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | ScriptableControllerAPI::~ScriptableControllerAPI() |
|---|
| 30 | { |
|---|
| 31 | lua_close(this->lua_); |
|---|
| 32 | } |
|---|
| 33 | |
|---|
| 34 | void ScriptableControllerAPI::testOutput() |
|---|
| 35 | { |
|---|
| 36 | orxout(user_info) << "Wheee!!!" << std::endl; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | void ScriptableControllerAPI::registerAfterTimeout(std::function<void (void)> callback, int timeout_ms) |
|---|
| 40 | { |
|---|
| 41 | |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | int ScriptableControllerAPI::registerAtNearObject(std::function<void (int, int)> callback, int obj1, int obj2, double distance) |
|---|
| 45 | { |
|---|
| 46 | |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | int ScriptableControllerAPI::registerAtAreaEnter(std::function<void (int)> callback, int obj, int x, int y, int z, int dx, int dy, int dz) |
|---|
| 50 | { |
|---|
| 51 | |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | int ScriptableControllerAPI::registerAtAreaLeave(std::function<void (int)> callback, int obj, int x, int y, int z, int dx, int dy, int dz) |
|---|
| 55 | { |
|---|
| 56 | |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | int ScriptableControllerAPI::registerAtObjectDestroyed(std::function<void (int)> callback, int obj) |
|---|
| 60 | { |
|---|
| 61 | |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | int ScriptableControllerAPI::registerAtPickup(std::function<void (int)> callback, int pickup_id) |
|---|
| 65 | { |
|---|
| 66 | |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | } |
|---|