Changeset 7815 in orxonox.OLD for branches/script_engine
- Timestamp:
- May 24, 2006, 4:49:35 PM (18 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/account.cc
r7808 r7815 22 22 int deposit(lua_State* L) 23 23 { 24 std::cout<<"deposit called"<<std::endl; 24 25 m_balance += lua_tonumber(L, -1); 25 26 lua_pop(L, 1); -
branches/script_engine/src/lib/script_engine/account.lua
r7808 r7815 5 5 print("testoutput from lua") 6 6 local a = Account{balance=100} 7 a:withdraw(25.00) 7 8 a:deposit(50.00) 8 a:withdraw(25.00)9 9 print("Account balance = $"..a:balance()) 10 10 -
branches/script_engine/src/lib/script_engine/luna.h
r7808 r7815 43 43 /* stack = closure(-1), [args...], 'self' table(1) */ 44 44 //int i = static_cast<int>(lua_tonumber(L,-1)); 45 int i = lua_upvalueindex (1); 45 46 int i = lua_upvalueindex (1); 47 46 48 //lua_pushnumber(L, 0); /* userdata object at index 0 */ 47 49 //lua_gettable(L, 1); 48 50 lua_rawgeti (L, 1, 0); 49 51 T* obj = (T*)(lua_touserdata(L,-1)); 50 lua_pop(L, 2); /* pop closure value and obj */52 lua_pop(L, 1); /* pop closure value and obj */ 51 53 52 54 printf("FUNCTION:: %d\n", i ); … … 88 90 89 91 private: 92 90 93 static int registerObject(T* obj, lua_State* L) 91 94 { 92 95 lua_newtable(L); /* new table object */ 93 int objRef = luaL_ref (L, LUA_REGISTRYINDEX);96 //int objRef = luaL_ref (L, LUA_REGISTRYINDEX); 94 97 95 98 //lua_pushnumber(L, 0); /* userdata obj at index 0 */ 96 lua_rawgeti(L, LUA_REGISTRYINDEX, objRef);99 //lua_rawgeti(L, LUA_REGISTRYINDEX, objRef); 97 100 lua_pushlightuserdata(L, obj); 98 101 lua_rawseti(L,-2,0); … … 101 104 //std::cout<<"test"<<std::endl; 102 105 103 /* Set up garbage collection */106 /* Set up garbage collection 104 107 if(lua_getmetatable(L, objRef) != 0) 105 108 { … … 109 112 lua_settable(L,-3); 110 113 } 111 112 lua_rawgeti (L, LUA_REGISTRYINDEX, objRef);114 */ 115 //lua_rawgeti (L, LUA_REGISTRYINDEX, objRef); 113 116 /* register the member functions */ 114 for (int i=0; T::Register[i].name; i++) {115 117 for (int i=0; T::Register[i].name; i++) 118 { 116 119 lua_pushstring(L, T::Register[i].name); 117 120 lua_pushnumber(L, i);
Note: See TracChangeset
for help on using the changeset viewer.