summaryrefslogtreecommitdiff
path: root/mods/vzxv_itemstacks/init.lua
blob: 48d9545c4b590ab250790f16ce4d91d3f56b8b28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

vzxv.include "container.lua"

vzxv.mundane_block("vzxv_itemstacks:item","Item","apioform",{
	groups = { handy = 3, container = 1, small = 1 },
	drawtype = "airlike",
	sunlight_propagates = true,
	paramtype = "light",
	selection_box = {
		type = "fixed",
		fixed = {
			{-0.30,-0.5,-0.30,0.30,0.10,0.30},
		},
	},
	collision_box = {
		type = "fixed",
		fixed = {
			{-0.30,-0.5,-0.30,0.30,0.10,0.30},
		},
	},
	on_destruct = vzxv.container_destruct,
	on_rightclick = vzxv.player_add_container_items,
	on_dig = function(pos, ...)
		local s = vzxv.player_take_container_items(pos, ...)
		if vzxv.get_container_stack(pos):is_empty() then
			minetest.add_node(pos, {name = "air"})
		end
		return true
	end,
})

-- TODO: handle dropping into nonair block correctly
function vzxv.drop(pos, stack)
	minetest.set_node(pos, {name="vzxv_itemstacks:item"})
	vzxv.set_container_stack(pos, stack)
end