Changeset 8066 in orxonox.OLD for branches/script_engine/src/lib
- Timestamp:
- Jun 1, 2006, 2:06:34 PM (18 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/Script.cc
r8061 r8066 74 74 bool Script::selectFunction(std::string& functionName, int retCount) 75 75 { 76 if(returnCount == 0) //no return values left on the stack 77 { 76 78 lua_pushlstring(luaState, functionName.c_str(), functionName.size() ); 77 79 lua_gettable(luaState, LUA_GLOBALSINDEX); … … 86 88 else 87 89 return false; 88 90 } 91 else 92 printf("there are unremoved return values on the stack. Please remove them first.\n"); 89 93 } 90 94 … … 103 107 { 104 108 currentFunction.assign("");//a function gets unusable after beeing called for the first time 105 returnCount =argumentCount = 0;109 argumentCount = 0; 106 110 return true; 107 111 } … … 164 168 int Script::getReturnedInt() 165 169 { 170 int returnValue; 166 171 if(returnCount > 0) 167 172 { 168 printf("int found"); 169 if(lua_isnumber(luaState, 1)) 170 { 171 printf("int found"); 172 int returnValue = (int)lua_tonumber(luaState, 1); 173 if(lua_isnumber(luaState, -1)) 174 { 175 returnValue = (int)lua_tonumber(luaState, -1); 173 176 returnCount--; 174 177 } 175 178 } 179 return returnValue; 180 } 181 182 183 bool Script::getReturnedBool() 184 { 185 bool returnValue; 186 if(returnCount > 0) 187 { 188 if(lua_isboolean(luaState, -1)) 189 { 190 returnValue = (bool)lua_toboolean(luaState, -1); 191 returnCount--; 192 } 193 } 194 return returnValue; 176 195 } 177 196 -
branches/script_engine/src/lib/script_engine/Script.h
r8061 r8066 22 22 bool selectFunction(std::string& functionName, int retCount); 23 23 bool executeFunction(); 24 // push parameters for luafunction 24 25 bool pushParam(int param, std::string& toFunction);//overload this function to add different types 25 26 bool pushParam(float param, std::string& toFunction); 26 27 bool pushParam(double param, std::string& toFunction); 27 int getReturnedInt(); 28 28 // get returned values 29 int getReturnedInt();//overload this function to get different types 30 bool getReturnedBool(); 29 31 30 32
Note: See TracChangeset
for help on using the changeset viewer.