Don't allow putting a filled bag in another bag

This commit is contained in:
Jean-Patrick Guerrero 2021-11-29 20:03:30 +01:00
parent 27226a0d1b
commit 939019f4c6
2 changed files with 14 additions and 0 deletions

View File

@ -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). 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) ![Preview](https://user-images.githubusercontent.com/7883281/142780121-564c1969-b95b-4cc9-99df-9f2362c67e07.png)

View File

@ -101,6 +101,18 @@ local function init_bags(player)
on_move = save_content, on_move = save_content,
on_put = save_content, on_put = save_content,
on_take = 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) }, name)
bag_content:set_size("main", 4*4) bag_content:set_size("main", 4*4)