summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_inventory.cpp
diff options
context:
space:
mode:
authorDániel Juhász <juhdanad@gmail.com>2017-06-20 09:19:56 +0000
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-06-20 11:19:56 +0200
commit0fcaf9fb1b61caaf8ed78a5d3005b1d9d1c43b57 (patch)
tree39b19a3fa61dc29b921739a26d7598222cdbd5f3 /src/script/lua_api/l_inventory.cpp
parent7c07cb4ec23ebb0f3d5f3d913bea205660515836 (diff)
downloadminetest-0fcaf9fb1b61caaf8ed78a5d3005b1d9d1c43b57.tar.gz
minetest-0fcaf9fb1b61caaf8ed78a5d3005b1d9d1c43b57.tar.bz2
minetest-0fcaf9fb1b61caaf8ed78a5d3005b1d9d1c43b57.zip
Automatic item and node colorization (#5640)
* Automatic item and node colorization Now nodes with a palette yield colored item stacks, and colored items place colored nodes by default. The client predicts the colorization. * Backwards compatibility * Use nil * Style fixes * Fix code style * Document changes
Diffstat (limited to 'src/script/lua_api/l_inventory.cpp')
-rw-r--r--src/script/lua_api/l_inventory.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/script/lua_api/l_inventory.cpp b/src/script/lua_api/l_inventory.cpp
index f5e76a7b6..e92197c14 100644
--- a/src/script/lua_api/l_inventory.cpp
+++ b/src/script/lua_api/l_inventory.cpp
@@ -325,8 +325,8 @@ int InvRef::l_room_for_item(lua_State *L)
return 1;
}
-// contains_item(self, listname, itemstack or itemstring or table or nil) -> true/false
-// Returns true if the list contains the given count of the given item name
+// contains_item(self, listname, itemstack or itemstring or table or nil, [match_meta]) -> true/false
+// Returns true if the list contains the given count of the given item
int InvRef::l_contains_item(lua_State *L)
{
NO_MAP_LOCK_REQUIRED;
@@ -334,8 +334,11 @@ int InvRef::l_contains_item(lua_State *L)
const char *listname = luaL_checkstring(L, 2);
ItemStack item = read_item(L, 3, getServer(L)->idef());
InventoryList *list = getlist(L, ref, listname);
- if(list){
- lua_pushboolean(L, list->containsItem(item));
+ bool match_meta = false;
+ if (lua_isboolean(L, 4))
+ match_meta = lua_toboolean(L, 4);
+ if (list) {
+ lua_pushboolean(L, list->containsItem(item, match_meta));
} else {
lua_pushboolean(L, false);
}