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
43
44
45
46
47
48
49
50
51
52
53
|
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,
})
vzxv.include "loose.lua"
local itemnodetable = {} -- we can't rely on set_node to know if an item node
-- was placed, so here's a temporary table that will be cleared every tick
-- speaking of clearing it every tick,
minetest.register_globalstep(function()
itemnodetable = {}
end)
function vzxv.drop(pos, stack)
local npos = vzxv.floor_pos(pos)
local node = minetest.get_node(npos)
local hash = minetest.hash_node_position(npos)
if not node.name == "air" or itemnodetable[hash] then
vzxv.drop_loose(npos, stack)
else
itemnodetable[hash] = true
minetest.set_node(npos, {name="vzxv_itemstacks:item"})
vzxv.set_container_stack(npos, stack)
end
end
|