Add push_ARGB8 to script/common/c_converter
authorTeTpaAka <TeTpaAka@users.noreply.github.com>
Fri, 15 May 2015 20:16:39 +0000 (22:16 +0200)
committerkwolekr <kwolekr@minetest.net>
Fri, 15 May 2015 20:21:56 +0000 (16:21 -0400)
src/script/common/c_converter.cpp
src/script/common/c_converter.h
src/script/lua_api/l_object.cpp

index fc489ea9574d00726009eee8ab8a849fbfcfbcc5..9d68298155cf08672011abfcbf8a9c428e5546fb 100644 (file)
@@ -39,6 +39,19 @@ extern "C" {
 #define CHECK_POS_TAB(index) CHECK_TYPE(index, "position", LUA_TTABLE)
 
 
+void push_ARGB8(lua_State *L, video::SColor color)
+{
+       lua_newtable(L);
+       lua_pushnumber(L, color.getAlpha());
+       lua_setfield(L, -2, "a");
+       lua_pushnumber(L, color.getRed());
+       lua_setfield(L, -2, "r");
+       lua_pushnumber(L, color.getGreen());
+       lua_setfield(L, -2, "g");
+       lua_pushnumber(L, color.getBlue());
+       lua_setfield(L, -2, "b");
+}
+
 void push_v3f(lua_State *L, v3f p)
 {
        lua_newtable(L);
index 0847f47c9ed26d241b943fff58fe89cf19a80df4..ff1fcaadfc9eb3aaed7dbc35d467aa8afbdc6645 100644 (file)
@@ -95,6 +95,7 @@ size_t              read_stringlist     (lua_State *L, int index,
                                          std::vector<std::string> *result);
 
 void                push_v3s16          (lua_State *L, v3s16 p);
+void                push_ARGB8          (lua_State *L, video::SColor color);
 void                pushFloatPos        (lua_State *L, v3f p);
 void                push_v3f            (lua_State *L, v3f p);
 void                push_v2f            (lua_State *L, v2f p);
index 845aab732c2ddc8cfd16658ef1c411887fcd844e..74903df5fa4d9533d93b5bf267fbf21e71d1ff12 100644 (file)
@@ -1305,15 +1305,7 @@ int ObjectRef::l_get_nametag_attributes(lua_State *L)
        video::SColor color = playersao->getNametagColor();
 
        lua_newtable(L);
-       lua_newtable(L);
-       lua_pushnumber(L, color.getAlpha());
-       lua_setfield(L, -2, "a");
-       lua_pushnumber(L, color.getRed());
-       lua_setfield(L, -2, "r");
-       lua_pushnumber(L, color.getGreen());
-       lua_setfield(L, -2, "g");
-       lua_pushnumber(L, color.getBlue());
-       lua_setfield(L, -2, "b");
+       push_ARGB8(L, color);
        lua_setfield(L, -2, "color");
 
        return 1;