Changeset 8080 in orxonox.OLD for branches/script_engine/src
- Timestamp:
- Jun 1, 2006, 4:25:03 PM (19 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/account.cc
r8078 r8080 43 43 44 44 //lua Interface 45 int getCallCount(lua_State* L){int calls = getCallCount(); lua_pushnumber(L,(lua_Number)calls);return 1;} 45 //function that returns a value to lua 46 int getCallCount(lua_State* L) 47 { 48 int calls = getCallCount(); 49 lua_pushnumber(L,(lua_Number)calls); 50 return 1; // return number of values that the function wants to return to lua 51 } 46 52 53 //function that takes an argument from lua 54 int takeParam(lua_State* L) 55 { 56 int param = (int)lua_tonumber(L,-1); 57 takeParam(param); 58 return 0; 59 } 60 61 //meber functions 62 void takeParam(int i) 63 { 64 printf("Lua passed %i to c++\n",i); 65 } 47 66 48 67 int printName(lua_State* L) … … 65 84 method(Object, printName), 66 85 method(Object, getCallCount), 86 method(Object, takeParam), 67 87 {0,0} 68 88 }; -
branches/script_engine/src/lib/script_engine/lunartest2.lua
r8078 r8080 18 18 io.write("main received ", arg) 19 19 io.write(" as parameter\n") 20 --call member 20 21 Obj:printName() 22 23 --create object 24 25 o = Object() 26 o:printName() 27 28 --take returnvalue from c 21 29 callCount = Obj:getCallCount() 22 30 io.write("callCount is now ",callCount) 23 31 io.write("\n") 32 33 --pass parameters to a c++ method 34 Obj:takeParam(3) 24 35 36 --print object information 25 37 print('a =', a) 26 38 print('b =', b)
Note: See TracChangeset
for help on using the changeset viewer.