diff options
author | darkrose <lisa@ltmnet.com> | 2012-06-03 20:37:55 +1000 |
---|---|---|
committer | Perttu Ahola <celeron55@gmail.com> | 2012-06-03 22:31:02 +0300 |
commit | 3e419ffb38df3f802ed30c5e114b8b3e8b7a6c1f (patch) | |
tree | ad8f48991e7ed65d127021f4974243ddf5855cbb /src | |
parent | a149c6ecde66a89bd1080bddf8848a19115a79d4 (diff) | |
download | minetest-3e419ffb38df3f802ed30c5e114b8b3e8b7a6c1f.tar.gz minetest-3e419ffb38df3f802ed30c5e114b8b3e8b7a6c1f.tar.bz2 minetest-3e419ffb38df3f802ed30c5e114b8b3e8b7a6c1f.zip |
Add InvRef:is_empty(listname) and make chests/furnaces not diggable if not empty in minimal game
Diffstat (limited to 'src')
-rw-r--r-- | src/scriptapi.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/scriptapi.cpp b/src/scriptapi.cpp index 9744aaa33..e231a9879 100644 --- a/src/scriptapi.cpp +++ b/src/scriptapi.cpp @@ -1718,6 +1718,20 @@ private: return 0; } + // is_empty(self, listname) -> true/false + static int l_is_empty(lua_State *L) + { + InvRef *ref = checkobject(L, 1); + const char *listname = luaL_checkstring(L, 2); + InventoryList *list = getlist(L, ref, listname); + if(list && list->getUsedSlots() > 0){ + lua_pushboolean(L, false); + } else { + lua_pushboolean(L, true); + } + return 1; + } + // get_size(self, listname) static int l_get_size(lua_State *L) { @@ -1944,6 +1958,7 @@ public: }; const char InvRef::className[] = "InvRef"; const luaL_reg InvRef::methods[] = { + method(InvRef, is_empty), method(InvRef, get_size), method(InvRef, set_size), method(InvRef, get_stack), |