summaryrefslogtreecommitdiff
path: root/mods/vzxv_itemstacks/init.lua
blob: ee6c4dca506f43e58299b8369a2a22bad5684982 (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
38
39
40
41
42

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)
	local npos = {}
	npos.x = math.floor(pos.x)
	npos.y = math.floor(pos.y)
	npos.z = math.floor(pos.z)
	minetest.set_node(npos, {name="vzxv_itemstacks:item"})
	vzxv.set_container_stack(npos, stack)
end

vzxv.include "loose.lua"