Changeset 8058 in orxonox.OLD for branches/script_engine/src/lib
- Timestamp:
- Jun 1, 2006, 1:30:30 PM (18 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/Script.cc
r8045 r8058 74 74 bool Script::selectFunction(std::string& functionName, int retCount) 75 75 { 76 77 returnCount = retCount; 78 argumentCount = 0; 79 currentFunction = functionName; 80 lua_pushlstring(luaState, currentFunction.c_str(), currentFunction.size() ); 76 lua_pushlstring(luaState, functionName.c_str(), functionName.size() ); 81 77 lua_gettable(luaState, LUA_GLOBALSINDEX); 82 78 83 /*if(lua_isfunction( luaState , -1))79 if(lua_isfunction( luaState , -1)) 84 80 { 81 returnCount = retCount; 82 argumentCount = 0; 83 currentFunction = functionName; 85 84 return true; 86 85 } 87 86 else 88 return false;*/89 return true; 87 return false; 88 90 89 } 91 90 … … 163 162 } 164 163 164 int Script::getReturnedInt() 165 { 166 if(returnCount > 0) 167 { 168 if(lua_isnumber(luaState, 1)) 169 { 170 printf("int found"); 171 int returnValue = (int)lua_tonumber(luaState, 1); 172 returnCount--; 173 } 174 } 175 } 176 177 165 178 int Script::reportError(int error) 166 179 { -
branches/script_engine/src/lib/script_engine/Script.h
r8045 r8058 25 25 bool pushParam(float param, std::string& toFunction); 26 26 bool pushParam(double param, std::string& toFunction); 27 27 int getReturnedInt(); 28 28 29 29 -
branches/script_engine/src/lib/script_engine/account.cc
r8045 r8058 89 89 90 90 std::string main("main"); 91 script.selectFunction(main,0); 91 if( script.selectFunction(main,0)) 92 printf("function %s selected\n",main.c_str()); 93 92 94 script.pushParam(3.14159,main); 93 95 script.executeFunction(); 96 97 int ret = script.getReturnedInt(); 98 printf("main returned %i\n",ret); 94 99 95 100 //if(argc>1) lua_dofile(script.getLuaState(), argv[1]); -
branches/script_engine/src/lib/script_engine/lunartest2.lua
r8046 r8058 27 27 a:show() a:deposit(50.30) a:show() a:withdraw(25.10) a:show() 28 28 Obj:printName() 29 30 return 2 29 31 --debug.debug() 30 32 end
Note: See TracChangeset
for help on using the changeset viewer.