Skip to content

Commit

Permalink
Add push_ARGB8 to script/common/c_converter
Browse files Browse the repository at this point in the history
  • Loading branch information
TeTpaAka authored and kwolekr committed May 15, 2015
1 parent 18c2f16 commit 19cbb6b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
13 changes: 13 additions & 0 deletions src/script/common/c_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/script/common/c_converter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
10 changes: 1 addition & 9 deletions src/script/lua_api/l_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 19cbb6b

Please sign in to comment.