a huge pile of boilerplate code
This commit is contained in:
@@ -95,6 +95,23 @@ namespace lua {
|
||||
lua_pop(L, -1);
|
||||
return glm::vec2(x, y);
|
||||
}
|
||||
|
||||
inline glm::vec4 tocolor(lua_State* L, int idx) {
|
||||
lua_pushvalue(L, idx);
|
||||
if (!lua_istable(L, -1)) {
|
||||
luaL_error(L, "RGBA array required");
|
||||
}
|
||||
lua_rawgeti(L, -1, 1);
|
||||
lua::luanumber r = lua_tonumber(L, -1); lua_pop(L, -1);
|
||||
lua_rawgeti(L, -2, 2);
|
||||
lua::luanumber g = lua_tonumber(L, -1); lua_pop(L, -1);
|
||||
lua_rawgeti(L, -3, 3);
|
||||
lua::luanumber b = lua_tonumber(L, -1); lua_pop(L, -1);
|
||||
lua_rawgeti(L, -4, 4);
|
||||
lua::luanumber a = lua_tonumber(L, -1); lua_pop(L, -1);
|
||||
lua_pop(L, -1);
|
||||
return glm::vec4(r/255, g/255, b/255, a/255);
|
||||
}
|
||||
}
|
||||
|
||||
#endif // LOGIC_SCRIPTING_LUA_UTIL_H_
|
||||
|
||||
Reference in New Issue
Block a user