From 939019f4c68f9cfc735e3a35ec2b2774957cc7fe Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Mon, 29 Nov 2021 20:03:30 +0100 Subject: [PATCH] Don't allow putting a filled bag in another bag --- README.md | 2 ++ src/bags.lua | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index e59e834..12c0d13 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,6 @@ The `i3` inventory is 9 slots wide by default, such as Minecraft. Report bugs on the [**Bug Tracker**](https://github.com/minetest-mods/i3/issues). +**Video review on YouTube:** https://www.youtube.com/watch?v=Xd14BCdEZ3o + ![Preview](https://user-images.githubusercontent.com/7883281/142780121-564c1969-b95b-4cc9-99df-9f2362c67e07.png) diff --git a/src/bags.lua b/src/bags.lua index 0c7fe85..b654278 100644 --- a/src/bags.lua +++ b/src/bags.lua @@ -101,6 +101,18 @@ local function init_bags(player) on_move = save_content, on_put = save_content, on_take = save_content, + + allow_put = function(_, _, _, stack) + local meta = stack:get_meta() + local content = dslz(meta:get_string"content") + + if content then + msg(name, "You cannot put a bag in another bag") + return 0, play_sound(name, "i3_cannot", 0.8) + end + + return stack:get_count() + end, }, name) bag_content:set_size("main", 4*4)