Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

See previous

File size: 2.7 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::this_;
12
13ScriptableControllerAPI::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
29ScriptableControllerAPI::~ScriptableControllerAPI()
30{
31    lua_close(this->lua_);
32}
33
34void ScriptableControllerAPI::testOutput()
35{
36    orxout(user_info) << "Wheee!!!" << std::endl;
37}
38
39void ScriptableControllerAPI::registerAfterTimeout(std::function<void (void)> callback, int timeout_ms)
40{
41
42}
43
44int ScriptableControllerAPI::registerAtNearObject(std::function<void (int, int)> callback, int obj1, int obj2, double distance)
45{
46
47}
48
49int 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
54int 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
59int ScriptableControllerAPI::registerAtObjectDestroyed(std::function<void (int)> callback, int obj)
60{
61
62}
63
64int ScriptableControllerAPI::registerAtPickup(std::function<void (int)> callback, int pickup_id)
65{
66
67}
68
69}
Note: See TracBrowser for help on using the repository browser.