- Timestamp:
- Jun 1, 2006, 3:26:41 PM (19 years ago)
- Location:
- branches/script_engine/src/lib/script_engine
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/script_engine/src/lib/script_engine/Script.cc
r8066 r8072 175 175 returnValue = (int)lua_tonumber(luaState, -1); 176 176 returnCount--; 177 lua_pop(luaState,1); 177 178 } 178 179 } … … 190 191 returnValue = (bool)lua_toboolean(luaState, -1); 191 192 returnCount--; 193 lua_pop(luaState,1); 192 194 } 193 195 } … … 195 197 } 196 198 199 float Script::getReturnedFloat() 200 { 201 float returnValue; 202 if(returnCount > 0) 203 { 204 if(lua_isnumber(luaState, -1)) 205 { 206 returnValue = (float)lua_tonumber(luaState, -1); 207 returnCount--; 208 lua_pop(luaState,1); 209 } 210 } 211 return returnValue; 212 } 197 213 198 214 int Script::reportError(int error) -
branches/script_engine/src/lib/script_engine/Script.h
r8066 r8072 23 23 bool executeFunction(); 24 24 // push parameters for luafunction 25 bool pushParam(int param, std::string& toFunction);//overload this function to add different types 26 bool pushParam(float param, std::string& toFunction); 27 bool pushParam(double param, std::string& toFunction); 28 // get returned values 29 int getReturnedInt();//overload this function to get different types 30 bool getReturnedBool(); 25 bool pushParam(int param, std::string& toFunction);//overload this function to add different types 26 bool pushParam(float param, std::string& toFunction); 27 bool pushParam(double param, std::string& toFunction); 28 // get returned values the last return value in lua is the first in c. 29 int getReturnedInt();//overload this function to get different types 30 bool getReturnedBool(); 31 float getReturnedFloat(); 31 32 32 33 -
branches/script_engine/src/lib/script_engine/account.cc
r8061 r8072 89 89 90 90 std::string main("main"); 91 if( script.selectFunction(main, 1))91 if( script.selectFunction(main,3)) 92 92 printf("function %s selected\n",main.c_str()); 93 93 … … 95 95 script.executeFunction(); 96 96 97 float retf = script.getReturnedFloat(); 98 printf("main returned %f\n",retf); 99 100 101 if(script.getReturnedBool()) 102 printf("main returned true\n"); 103 else 104 printf("main returned false\n"); 105 97 106 int ret = script.getReturnedInt(); 98 107 printf("main returned %i\n",ret); 99 108 100 109 //if(argc>1) lua_dofile(script.getLuaState(), argv[1]); 101 110 -
branches/script_engine/src/lib/script_engine/lunartest2.lua
r8061 r8072 28 28 Obj:printName() 29 29 30 return 2 30 return 2,false,2.72 31 31 --debug.debug() 32 32 end
Note: See TracChangeset
for help on using the changeset viewer.