Example #1
0
	LuaReturn::LuaReturn(lua_State* pState, const int& pVarNumber)
	{
		if(pState != NULL)
		{
			for(int i = 0; i < pVarNumber; ++i)
			{
				if(lua_isnumber(pState,-1))
				{
					mArgs.push_back(LuaArgument((double)(lua_tonumber(pState,-1))));
				}
				else if(lua_isstring(pState,-1))
				{
					mArgs.push_back(LuaArgument(std::string(lua_tostring(pState,-1))));
				}
				else if(lua_isboolean(pState,-1))
				{
					mArgs.push_back(LuaArgument((bool)(lua_toboolean(pState,-1))));
				}
				else if(lua_isnoneornil(pState,-1))
				{
					mArgs.push_back(LuaArgument());
				}
				else
				{
					printf("LuaReturn::LuaReturn(pState,pVarNumber): Error, unable to define argument type.");
				}
				lua_pop(pState,1);
			}
		}
		else
		{
			printf("LuaReturn::LuaReturn(pState,pVarNumber): Error, lua state is NULL.");
		}
	}
LuaArgument LuaFunctionArguments::operator[](size_t index)
{
    if(index > m_arguments.size())
        return LuaArgument();

    return m_arguments[index];
}