From c820cb204a22c9ab36f6eddb197cac4431de3402 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Tue, 13 Dec 2022 08:00:12 +1300 Subject: [PATCH] Make MetaDataRef:get return nil instead of nothing (#114) Co-authored-by: Jude Melton-Houghton --- src/script/lua_api/l_metadata.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/script/lua_api/l_metadata.cpp b/src/script/lua_api/l_metadata.cpp index e33a99690..0ec18eda6 100644 --- a/src/script/lua_api/l_metadata.cpp +++ b/src/script/lua_api/l_metadata.cpp @@ -82,9 +82,10 @@ int MetaDataRef::l_get(lua_State *L) std::string str; if (meta->getStringToRef(name, str)) { lua_pushlstring(L, str.c_str(), str.size()); - return 1; + } else { + lua_pushnil(L); } - return 0; + return 1; } // get_string(self, name)