diff options
author | TeTpaAka <TeTpaAka@users.noreply.github.com> | 2015-05-15 22:16:39 +0200 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-05-15 16:21:56 -0400 |
commit | 19cbb6b37b9a35df7892bde5aad138266496eb8f (patch) | |
tree | aa984b253a03dc2e60d0236cac274ef0ff075ad1 | |
parent | 18c2f16c138f4b40b4705507b46d24e1518e4705 (diff) | |
download | minetest-19cbb6b37b9a35df7892bde5aad138266496eb8f.tar.gz minetest-19cbb6b37b9a35df7892bde5aad138266496eb8f.tar.bz2 minetest-19cbb6b37b9a35df7892bde5aad138266496eb8f.zip |
Add push_ARGB8 to script/common/c_converter
-rw-r--r-- | src/script/common/c_converter.cpp | 13 | ||||
-rw-r--r-- | src/script/common/c_converter.h | 1 | ||||
-rw-r--r-- | src/script/lua_api/l_object.cpp | 10 |
3 files changed, 15 insertions, 9 deletions
diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp index fc489ea95..9d6829815 100644 --- a/src/script/common/c_converter.cpp +++ b/src/script/common/c_converter.cpp @@ -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); diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h index 0847f47c9..ff1fcaadf 100644 --- a/src/script/common/c_converter.h +++ b/src/script/common/c_converter.h @@ -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); diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 845aab732..74903df5f 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -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; |