Don't allow putting a filled bag in another bag
This commit is contained in:
parent
27226a0d1b
commit
939019f4c6
|
@ -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)
|
||||
|
|
12
src/bags.lua
12
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)
|
||||
|
|
Ŝarĝante…
Reference in New Issue