mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Player attrs: permits to remove an attribute by setting value to nil (#5716)
* Player attrs: permits to remove an attribute by setting value to nil When doing player:set_attribute("attr", nil) remove attribute Also remove a useless check on C++ API part (already done by checkplayer) Fix #5709
This commit is contained in:
parent
0d7c37943b
commit
c1b3ed4180
4 changed files with 29 additions and 14 deletions
|
@ -1202,9 +1202,10 @@ int ObjectRef::l_set_attribute(lua_State *L)
|
|||
}
|
||||
|
||||
std::string attr = luaL_checkstring(L, 2);
|
||||
std::string value = luaL_checkstring(L, 3);
|
||||
|
||||
if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER) {
|
||||
if (lua_isnil(L, 3)) {
|
||||
co->removeExtendedAttribute(attr);
|
||||
} else {
|
||||
std::string value = luaL_checkstring(L, 3);
|
||||
co->setExtendedAttribute(attr, value);
|
||||
}
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue