[Lua] Accept {r=..., g=..., b=...} format for colours in add_overlay_text
This commit is contained in:
parent
d734bfb9e2
commit
69789b7757
1 changed files with 24 additions and 8 deletions
|
@ -2384,11 +2384,19 @@ int game_lua_kernel::intf_set_floating_label(lua_State* L, bool spawn)
|
|||
} else {
|
||||
auto vec = lua_check<std::vector<int>>(L, -1);
|
||||
if(vec.size() != 3) {
|
||||
return luaL_error(L, "floating label text color should be a hex string or an array of 3 integers");
|
||||
int idx = lua_absindex(L, -1);
|
||||
if(luaW_tableget(L, idx, "r") && luaW_tableget(L, idx, "g") && luaW_tableget(L, idx, "b")) {
|
||||
color.r = luaL_checkinteger(L, -3);
|
||||
color.g = luaL_checkinteger(L, -2);
|
||||
color.b = luaL_checkinteger(L, -1);
|
||||
} else {
|
||||
return luaL_error(L, "floating label text color should be a hex string, an array of 3 integers, or a table with r,g,b keys");
|
||||
}
|
||||
} else {
|
||||
color.r = vec[0];
|
||||
color.g = vec[1];
|
||||
color.b = vec[2];
|
||||
}
|
||||
color.r = vec[0];
|
||||
color.g = vec[1];
|
||||
color.b = vec[2];
|
||||
}
|
||||
}
|
||||
if(luaW_tableget(L, 2, "bgcolor")) {
|
||||
|
@ -2397,11 +2405,19 @@ int game_lua_kernel::intf_set_floating_label(lua_State* L, bool spawn)
|
|||
} else {
|
||||
auto vec = lua_check<std::vector<int>>(L, -1);
|
||||
if(vec.size() != 3) {
|
||||
return luaL_error(L, "floating label background color should be a hex string or an array of 3 integers");
|
||||
int idx = lua_absindex(L, -1);
|
||||
if(luaW_tableget(L, idx, "r") && luaW_tableget(L, idx, "g") && luaW_tableget(L, idx, "b")) {
|
||||
bgcolor.r = luaL_checkinteger(L, -3);
|
||||
bgcolor.g = luaL_checkinteger(L, -2);
|
||||
bgcolor.b = luaL_checkinteger(L, -1);
|
||||
} else {
|
||||
return luaL_error(L, "floating label background color should be a hex string, an array of 3 integers, or a table with r,g,b keys");
|
||||
}
|
||||
} else {
|
||||
bgcolor.r = vec[0];
|
||||
bgcolor.g = vec[1];
|
||||
bgcolor.b = vec[2];
|
||||
}
|
||||
bgcolor.r = vec[0];
|
||||
bgcolor.g = vec[1];
|
||||
bgcolor.b = vec[2];
|
||||
bgcolor.a = ALPHA_OPAQUE;
|
||||
}
|
||||
if(luaW_tableget(L, 2, "bgalpha")) {
|
||||
|
|
Loading…
Add table
Reference in a new issue