Changeset 1204

Show
Ignore:
Timestamp:
03/04/2010 01:21:04 PM (6 months ago)
Author:
Paroxysm
Message:

FIXED : unit:RegisterEvent should work again. Console shouldn't spam lua errors anymore.
ADDED: Global function GetPlatform?() that returns either "windows" or "linux"

Location:
Trunk/src/LuaEngine
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • Trunk/src/LuaEngine/GlobalFunctions.h

    r1191 r1204  
    605605                return 1; 
    606606        } 
     607        int GetPlatform(lua_State * L) 
     608        { 
     609#ifdef WIN32 
     610                lua_pushliteral(L,"windows"); 
     611#else 
     612                lua_pushliteral(L,"linux"); 
     613#endif 
     614                return 1; 
     615        } 
    607616} 
    608617void RegisterGlobalFunctions(lua_State *L) 
     
    646655        lua_register(L, "HasTimedEventWithName", &luaGlobalFunctions::HasTimedEventWithName); 
    647656        lua_register(L, "HasTimedEvent", &luaGlobalFunctions::HasTimedEvent); 
     657        lua_register(L,"GetPlatform",&luaGlobalFunctions::GetPlatform); 
    648658} 
    649659#endif 
  • Trunk/src/LuaEngine/LUAEngine.cpp

    r1203 r1204  
    241241                lua_rawgeti(lu,LUA_REGISTRYINDEX,fReference); 
    242242                if(!lua_isfunction(lu,-1) ) 
    243                         luaL_error(lu,"Attempted to call an invalid function. \n"); 
     243                        luaL_error(lu,"Attempted to call invalid function. \n"); 
    244244        } 
    245245} 
     
    247247{ 
    248248        bool ret = true; 
    249         if(lua_pcall(lu,params,res,0) ) 
    250         { 
    251                 report(lu); 
     249        int top = lua_gettop(lu); 
     250        if(strcmp(luaL_typename(lu,top-params),"function") ) 
    252251                ret = false; 
     252        else 
     253        { 
     254                if(lua_pcall(lu,params,res,0) ) 
     255                { 
     256                        report(lu); 
     257                        ret = false; 
     258                } 
    253259        } 
    254260        return ret; 
  • Trunk/src/LuaEngine/UnitFunctions.h

    r1199 r1204  
    573573                uint16 functionRef = 0; 
    574574                lua_settop(L,1); 
    575                 if(typeName == "function") 
     575                if(!strcmp(typeName,"function")) 
    576576                        functionRef = (uint16)lua_ref(L,true); 
    577                 else if(typeName == "string") 
     577                else if(!strcmp(typeName,"string")) 
    578578                { 
    579579                        const char * functionName = luaL_checkstring(L,1);