diff options
author | Lejo <Lejo_1@web.de> | 2020-05-02 12:57:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-02 12:57:04 +0200 |
commit | 808eb4c5714da5ac36f4a70653d6b3805060828c (patch) | |
tree | 4c53d07664c85556906e54ad7e8ba5cca02197bc /src/script | |
parent | 61d93988d8b44a9905451c4c288e02c04d41abb0 (diff) | |
download | minetest-808eb4c5714da5ac36f4a70653d6b3805060828c.tar.gz minetest-808eb4c5714da5ac36f4a70653d6b3805060828c.tar.bz2 minetest-808eb4c5714da5ac36f4a70653d6b3805060828c.zip |
Auto delete MetaData when = 0 (#8770)
* Auto delete MetaData when = 0
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_metadata.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/script/lua_api/l_metadata.cpp b/src/script/lua_api/l_metadata.cpp index 21002e6a7..61a25a761 100644 --- a/src/script/lua_api/l_metadata.cpp +++ b/src/script/lua_api/l_metadata.cpp @@ -153,7 +153,9 @@ int MetaDataRef::l_set_int(lua_State *L) MetaDataRef *ref = checkobject(L, 1); std::string name = luaL_checkstring(L, 2); int a = luaL_checkint(L, 3); - std::string str = itos(a); + std::string str; + if (a != 0) + str = itos(a); Metadata *meta = ref->getmeta(true); if (meta == NULL || str == meta->getString(name)) @@ -191,7 +193,9 @@ int MetaDataRef::l_set_float(lua_State *L) MetaDataRef *ref = checkobject(L, 1); std::string name = luaL_checkstring(L, 2); float a = readParam<float>(L, 3); - std::string str = ftos(a); + std::string str; + if (a != 0) + str = ftos(a); Metadata *meta = ref->getmeta(true); if (meta == NULL || str == meta->getString(name)) |