2020-02-18 20:34:52 +03:00
|
|
|
local S = minetest.get_translator("pipeworks")
|
2015-01-30 00:24:14 +03:00
|
|
|
if pipeworks.enable_sand_tube then
|
2015-01-31 18:10:25 +03:00
|
|
|
pipeworks.register_tube("pipeworks:sand_tube", {
|
2020-02-18 20:34:52 +03:00
|
|
|
description = S("Vacuuming Pneumatic Tube Segment"),
|
2017-04-14 04:13:30 +03:00
|
|
|
inventory_image = "pipeworks_sand_tube_inv.png",
|
|
|
|
short = "pipeworks_sand_tube_short.png",
|
|
|
|
noctr = {"pipeworks_sand_tube_noctr.png"},
|
|
|
|
plain = {"pipeworks_sand_tube_plain.png"},
|
|
|
|
ends = {"pipeworks_sand_tube_end.png"},
|
|
|
|
node_def = {groups = {vacuum_tube = 1}},
|
2015-01-31 18:10:25 +03:00
|
|
|
})
|
2015-01-30 00:47:33 +03:00
|
|
|
|
|
|
|
minetest.register_craft( {
|
|
|
|
output = "pipeworks:sand_tube_1 2",
|
|
|
|
recipe = {
|
2018-10-31 03:45:48 +03:00
|
|
|
{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"},
|
2017-04-14 04:13:30 +03:00
|
|
|
{"group:sand", "group:sand", "group:sand"},
|
2018-10-31 03:45:48 +03:00
|
|
|
{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet"}
|
2015-01-30 00:47:33 +03:00
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft( {
|
|
|
|
output = "pipeworks:sand_tube_1",
|
|
|
|
recipe = {
|
2017-04-14 04:13:30 +03:00
|
|
|
{"group:sand", "pipeworks:tube_1", "group:sand"},
|
2015-01-30 00:47:33 +03:00
|
|
|
},
|
|
|
|
})
|
2015-01-30 00:24:14 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
if pipeworks.enable_mese_sand_tube then
|
2015-01-31 18:10:25 +03:00
|
|
|
pipeworks.register_tube("pipeworks:mese_sand_tube", {
|
2020-02-18 20:34:52 +03:00
|
|
|
description = S("Adjustable Vacuuming Pneumatic Tube Segment"),
|
2015-01-31 18:10:25 +03:00
|
|
|
inventory_image = "pipeworks_mese_sand_tube_inv.png",
|
|
|
|
short = "pipeworks_mese_sand_tube_short.png",
|
2017-04-14 04:13:30 +03:00
|
|
|
noctr = {"pipeworks_mese_sand_tube_noctr.png"},
|
|
|
|
plain = {"pipeworks_mese_sand_tube_plain.png"},
|
|
|
|
ends = {"pipeworks_mese_sand_tube_end.png"},
|
2015-01-31 18:10:25 +03:00
|
|
|
node_def = {
|
|
|
|
groups = {vacuum_tube = 1},
|
2015-01-30 23:38:04 +03:00
|
|
|
on_construct = function(pos)
|
|
|
|
local meta = minetest.get_meta(pos)
|
|
|
|
meta:set_int("dist", 0)
|
2021-04-02 22:47:48 +03:00
|
|
|
meta:set_string("formspec",
|
|
|
|
"size[6.0,2.2]"..
|
|
|
|
"image[0.2,0;1,1;pipeworks_mese_sand_tube_inv.png]"..
|
|
|
|
"label[1.2,0.2;"..S("Adjustable Vacuuming Tube").."]"..
|
|
|
|
"field[0.5,1.6;2.1,1;dist;"..S("Radius")..";${dist}]"..
|
|
|
|
"button[2.3,1.3;1.5,1;set_dist;"..S("Set").."]"..
|
2022-03-15 04:39:58 +03:00
|
|
|
"button_exit[3.8,1.3;2,1;close;"..S("Close").."]")
|
2020-02-18 20:34:52 +03:00
|
|
|
meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment"))
|
2015-01-30 23:38:04 +03:00
|
|
|
end,
|
|
|
|
on_receive_fields = function(pos,formname,fields,sender)
|
2021-04-02 22:47:48 +03:00
|
|
|
if (fields.quit and not fields.key_enter_field)
|
|
|
|
or (fields.key_enter_field ~= "dist" and not fields.set_dist)
|
|
|
|
or not pipeworks.may_configure(pos, sender) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2015-01-30 23:38:04 +03:00
|
|
|
local meta = minetest.get_meta(pos)
|
2015-01-31 01:51:11 +03:00
|
|
|
local dist = tonumber(fields.dist)
|
2015-02-03 11:23:38 +03:00
|
|
|
if dist then
|
|
|
|
dist = math.max(0, dist)
|
|
|
|
dist = math.min(8, dist)
|
2015-01-30 23:38:04 +03:00
|
|
|
meta:set_int("dist", dist)
|
2021-04-02 22:47:48 +03:00
|
|
|
meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment (@1m)", dist))
|
2015-01-30 23:38:04 +03:00
|
|
|
end
|
|
|
|
end,
|
2015-01-31 18:10:25 +03:00
|
|
|
},
|
2015-01-30 00:24:14 +03:00
|
|
|
})
|
2015-01-30 00:47:33 +03:00
|
|
|
end
|
2015-01-30 20:18:19 +03:00
|
|
|
|
|
|
|
local function vacuum(pos, radius)
|
|
|
|
radius = radius + 0.5
|
2017-04-14 04:13:30 +03:00
|
|
|
for _, object in pairs(minetest.get_objects_inside_radius(pos, math.sqrt(3) * radius)) do
|
2015-01-30 20:18:19 +03:00
|
|
|
local lua_entity = object:get_luaentity()
|
|
|
|
if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
|
2018-07-03 23:30:44 +03:00
|
|
|
local obj_pos = object:get_pos()
|
2017-04-14 04:13:30 +03:00
|
|
|
local minpos = vector.subtract(pos, radius)
|
|
|
|
local maxpos = vector.add(pos, radius)
|
|
|
|
if obj_pos.x >= minpos.x and obj_pos.x <= maxpos.x
|
|
|
|
and obj_pos.y >= minpos.y and obj_pos.y <= maxpos.y
|
|
|
|
and obj_pos.z >= minpos.z and obj_pos.z <= maxpos.z then
|
2015-01-30 20:18:19 +03:00
|
|
|
if lua_entity.itemstring ~= "" then
|
2017-04-14 04:13:30 +03:00
|
|
|
pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), lua_entity.itemstring)
|
2015-01-30 20:18:19 +03:00
|
|
|
lua_entity.itemstring = ""
|
|
|
|
end
|
|
|
|
object:remove()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_abm({nodenames = {"group:vacuum_tube"},
|
2017-04-14 04:13:30 +03:00
|
|
|
interval = 1,
|
|
|
|
chance = 1,
|
|
|
|
label = "Vacuum tubes",
|
|
|
|
action = function(pos, node, active_object_count, active_object_count_wider)
|
|
|
|
if node.name:find("pipeworks:sand_tube") then
|
|
|
|
vacuum(pos, 2)
|
|
|
|
else
|
|
|
|
local radius = minetest.get_meta(pos):get_int("dist")
|
|
|
|
vacuum(pos, radius)
|
|
|
|
end
|
|
|
|
end
|
2015-01-30 20:18:19 +03:00
|
|
|
})
|