Line | |
---|
1 | |
---|
2 | #include <iostream> |
---|
3 | |
---|
4 | #include "base_object.h" |
---|
5 | #include "lunar.h" |
---|
6 | |
---|
7 | #include "script_class.h" |
---|
8 | |
---|
9 | |
---|
10 | class Object : public BaseObject |
---|
11 | { |
---|
12 | public: |
---|
13 | Object(lua_State* L) {callCount = 0; } |
---|
14 | Object(){callCount = 0;this->setClassID(CL_TEST_OBJECT, "Object");}; |
---|
15 | ~Object() { printf("deleted Object (%p)\n", this); } |
---|
16 | |
---|
17 | //meber functions |
---|
18 | void takeParam(int i) |
---|
19 | { |
---|
20 | printf("Lua passed %i to c++\n",i); |
---|
21 | } |
---|
22 | |
---|
23 | int printName(lua_State* L) |
---|
24 | { |
---|
25 | this->printName(); |
---|
26 | return 0; |
---|
27 | } |
---|
28 | |
---|
29 | void printName() |
---|
30 | { |
---|
31 | callCount ++; |
---|
32 | printf("Hi i'm object %p ! This is the %i. call.\n",this,callCount); |
---|
33 | } |
---|
34 | |
---|
35 | int getCallCount(){ return callCount; } |
---|
36 | |
---|
37 | private: |
---|
38 | int callCount; |
---|
39 | |
---|
40 | }; |
---|
41 | |
---|
42 | |
---|
43 | CREATE_SCRIPTABLE_CLASS(Object, CL_TEST_OBJECT, |
---|
44 | addMethod("printName", ExecutorLua0<Object>(&Object::printName)) |
---|
45 | ->addMethod("getCallCount", ExecutorLua0ret<Object, int>(&Object::getCallCount)) |
---|
46 | ->addMethod("takeParam", ExecutorLua1<Object, int>(&Object::takeParam))); |
---|
Note: See
TracBrowser
for help on using the repository browser.