forked from mt-mods/vacuum
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphysics_drop.lua
49 lines (41 loc) · 1.47 KB
/
physics_drop.lua
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
-- weird behaving nodes in vacuum
local drop_nodes = {"default:torch", "default:torch_wall", "default:torch_ceiling", "default:ladder_wood",
"default:dry_shrub", "default:papyrus", "default:cactus", "group:wool", "group:pillow",
"group:wood", "group:tree"}
local function get_node_drops(node)
if node.name == "default:papyrus" then
if math.random(3) == 1 then
return {"default:paper"}
end
return {}
end
return minetest.get_node_drops(node)
end
function vacuum.register_physics_drop(height)
-- weird nodes in vacuum
minetest.register_abm({
label = "space drop nodes",
nodenames = drop_nodes,
neighbors = {"vacuum:vacuum"},
interval = 1,
chance = 1,
max_y = height.end_height,
min_y = height.start_height,
action = vacuum.throttle(100, function(pos, node)
if vacuum.is_pos_in_spawn(pos) then
return
end
if not vacuum.is_pos_in_space(pos) or vacuum.near_powered_airpump(pos, 3) then
return
end
-- local node = minetest.get_node(pos)
-- minetest.set_node(pos, {name = "vacuum:vacuum"})
minetest.set_node(pos, {
name = "vacuum:atmos_thin"
})
for _, drop in pairs(get_node_drops(node)) do
minetest.add_item(pos, ItemStack(drop))
end
end)
})
end