summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--default_settings.lua40
-rw-r--r--default_settings.txt24
-rw-r--r--init.lua2
-rw-r--r--settingtypes.txt70
-rw-r--r--vacuum_tubes.lua74
5 files changed, 146 insertions, 64 deletions
diff --git a/default_settings.lua b/default_settings.lua
new file mode 100644
index 0000000..6f661b5
--- /dev/null
+++ b/default_settings.lua
@@ -0,0 +1,40 @@
+-- Various settings
+
+local prefix = "pipeworks_"
+
+local settings = {
+ enable_pipes = true,
+ enable_autocrafter = true,
+ enable_deployer = true,
+ enable_dispenser = true,
+ enable_node_breaker = true,
+ enable_teleport_tube = true,
+ enable_pipe_devices = true,
+ enable_redefines = true,
+ enable_mese_tube = true,
+ enable_detector_tube = true,
+ enable_digiline_detector_tube = true,
+ enable_conductor_tube = true,
+ enable_accelerator_tube = true,
+ enable_crossing_tube = true,
+ enable_sand_tube = true,
+ enable_mese_sand_tube = true,
+ enable_one_way_tube = true,
+ enable_priority_tube = true,
+ enable_cyclic_mode = true,
+ drop_on_routing_fail = false,
+
+ delete_item_on_clearobject = true,
+}
+
+for name, value in pairs(settings) do
+ local setting_type = type(value)
+ if setting_type == "boolean" then
+ pipeworks[name] = minetest.setting_getbool(prefix..name)
+ if pipeworks[name] == nil then
+ pipeworks[name] = value
+ end
+ else
+ pipeworks[name] = value
+ end
+end
diff --git a/default_settings.txt b/default_settings.txt
deleted file mode 100644
index b1aa331..0000000
--- a/default_settings.txt
+++ /dev/null
@@ -1,24 +0,0 @@
--- Various settings
-
-pipeworks.enable_pipes = true
-pipeworks.enable_autocrafter = true
-pipeworks.enable_deployer = true
-pipeworks.enable_dispenser = true
-pipeworks.enable_node_breaker = true
-pipeworks.enable_teleport_tube = true
-pipeworks.enable_pipe_devices = true
-pipeworks.enable_redefines = true
-pipeworks.enable_mese_tube = true
-pipeworks.enable_detector_tube = true
-pipeworks.enable_digiline_detector_tube = true
-pipeworks.enable_conductor_tube = true
-pipeworks.enable_accelerator_tube = true
-pipeworks.enable_crossing_tube = true
-pipeworks.enable_sand_tube = true
-pipeworks.enable_mese_sand_tube = true
-pipeworks.enable_one_way_tube = true
-pipeworks.enable_priority_tube = true
-pipeworks.enable_cyclic_mode = true
-pipeworks.drop_on_routing_fail = false
-
-pipeworks.delete_item_on_clearobject = true
diff --git a/init.lua b/init.lua
index ab5cf3c..1766e2d 100644
--- a/init.lua
+++ b/init.lua
@@ -13,7 +13,7 @@ local DEBUG = false
pipeworks.worldpath = minetest.get_worldpath()
pipeworks.modpath = minetest.get_modpath("pipeworks")
-dofile(pipeworks.modpath.."/default_settings.txt")
+dofile(pipeworks.modpath.."/default_settings.lua")
-- Read the external config file if it exists.
local worldsettingspath = pipeworks.worldpath.."/pipeworks_settings.txt"
diff --git a/settingtypes.txt b/settingtypes.txt
new file mode 100644
index 0000000..1d3c10c
--- /dev/null
+++ b/settingtypes.txt
@@ -0,0 +1,70 @@
+#Enable pipes.
+pipeworks_enable_pipes (Enable Pipes) bool true
+
+#Enable autocrafter.
+pipeworks_enable_autocrafter (Enable Autocrafter) bool true
+
+#Enable deployer.
+pipeworks_enable_deployer (Enable Deployer) bool true
+
+#Enable dispenser.
+pipeworks_enable_dispenser (Enable Dispenser) bool true
+
+#Enable node breaker.
+pipeworks_enable_node_breaker (Enable Node Breaker) bool true
+
+#Enable teleport tube.
+pipeworks_enable_teleport_tube (Enable Teleport Tube) bool true
+
+#Enable pipe devices.
+pipeworks_enable_pipe_devices (Enable Pipe Devices) bool true
+
+#Enable redefines.
+pipeworks_enable_redefines (Enable Node Redefines) bool true
+
+#Enable sorting tube.
+pipeworks_enable_mese_tube (Enable Sorting Tube) bool true
+
+#Enable detector tube.
+pipeworks_enable_detector_tube (Enable Detector Tube) bool true
+
+#Enable digiline detector tube.
+pipeworks_enable_digiline_detector_tube (Enable Digiline Detector Tube) bool true
+
+#Enable mesecon signal conducting tube.
+pipeworks_enable_conductor_tube (Enable Conductor Tube) bool true
+
+#Enable accelerator tube.
+pipeworks_enable_accelerator_tube (Enable Accelerator Tube) bool true
+
+#Enable crossing tube.
+#It sends all incoming items to the other side, or if there is no other tube, it sends them back.
+pipeworks_enable_crossing_tube (Enable Crossing Tube) bool true
+
+#Enable vacuum tube.
+#It picks up all items that lay around next to it.
+pipeworks_enable_sand_tube (Enable Vacuum Tube) bool true
+
+#Enable mese vacuum tube.
+#It's like the normal vacuum tube with the
+#differance that you can set the radius up to 8 nodes.
+pipeworks_enable_mese_sand_tube (Enable Mese Vacuum Tube) bool true
+
+#Enable one way tube.
+#It sends items only in one direction.
+#Use it to drop items out of tubes.
+pipeworks_enable_one_way_tube (Enable One Way Tube) bool true
+
+#Enable high priority tube.
+#It has a very high priority and so, on crossings, the items will
+#always go to it if there are multible ways.
+pipeworks_enable_priority_tube (Enable High Priority Tube) bool true
+
+#Enable cyclic mode.
+pipeworks_enable_cyclic_mode (Enable Cyclic Mode) bool true
+
+#Drop on routing fail.
+pipeworks_drop_on_routing_fail (Drop On Routing Fail) bool false
+
+#Delete item on clearobject.
+pipeworks_delete_item_on_clearobject (Delete Item On Clearobject) bool true \ No newline at end of file
diff --git a/vacuum_tubes.lua b/vacuum_tubes.lua
index 51f6f81..211c3ee 100644
--- a/vacuum_tubes.lua
+++ b/vacuum_tubes.lua
@@ -1,27 +1,27 @@
if pipeworks.enable_sand_tube then
pipeworks.register_tube("pipeworks:sand_tube", {
- description = "Vacuuming Pneumatic Tube Segment",
- 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}},
+ description = "Vacuuming Pneumatic Tube Segment",
+ 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}},
})
minetest.register_craft( {
output = "pipeworks:sand_tube_1 2",
recipe = {
- { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
- { "group:sand", "group:sand", "group:sand" },
- { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
+ {"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"},
+ {"group:sand", "group:sand", "group:sand"},
+ {"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting"}
},
})
minetest.register_craft( {
output = "pipeworks:sand_tube_1",
recipe = {
- { "group:sand", "pipeworks:tube_1", "group:sand" },
+ {"group:sand", "pipeworks:tube_1", "group:sand"},
},
})
end
@@ -31,9 +31,9 @@ if pipeworks.enable_mese_sand_tube then
description = "Adjustable Vacuuming Pneumatic Tube Segment",
inventory_image = "pipeworks_mese_sand_tube_inv.png",
short = "pipeworks_mese_sand_tube_short.png",
- noctr = { "pipeworks_mese_sand_tube_noctr.png" },
- plain = { "pipeworks_mese_sand_tube_plain.png" },
- ends = { "pipeworks_mese_sand_tube_end.png" },
+ noctr = {"pipeworks_mese_sand_tube_noctr.png"},
+ plain = {"pipeworks_mese_sand_tube_plain.png"},
+ ends = {"pipeworks_mese_sand_tube_end.png"},
node_def = {
groups = {vacuum_tube = 1},
on_construct = function(pos)
@@ -63,9 +63,9 @@ if pipeworks.enable_mese_sand_tube then
minetest.register_craft( {
output = "pipeworks:mese_sand_tube_1 2",
recipe = {
- { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
- { "group:sand", "default:mese_crystal", "group:sand" },
- { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
+ {"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" },
+ {"group:sand", "default:mese_crystal", "group:sand" },
+ {"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }
},
})
@@ -82,23 +82,19 @@ if pipeworks.enable_mese_sand_tube then
})
end
-local sqrt_3 = math.sqrt(3)
-local tube_inject_item = pipeworks.tube_inject_item
-local get_objects_inside_radius = minetest.get_objects_inside_radius
local function vacuum(pos, radius)
radius = radius + 0.5
- for _, object in pairs(get_objects_inside_radius(pos, sqrt_3 * radius)) do
+ for _, object in pairs(minetest.get_objects_inside_radius(pos, math.sqrt(3) * radius)) do
local lua_entity = object:get_luaentity()
if not object:is_player() and lua_entity and lua_entity.name == "__builtin:item" then
local obj_pos = object:getpos()
- local x1, y1, z1 = pos.x, pos.y, pos.z
- local x2, y2, z2 = obj_pos.x, obj_pos.y, obj_pos.z
-
- if x1 - radius <= x2 and x2 <= x1 + radius
- and y1 - radius <= y2 and y2 <= y1 + radius
- and z1 - radius <= z2 and z2 <= z1 + radius then
+ 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
if lua_entity.itemstring ~= "" then
- tube_inject_item(pos, pos, vector.new(0, 0, 0), lua_entity.itemstring)
+ pipeworks.tube_inject_item(pos, pos, vector.new(0, 0, 0), lua_entity.itemstring)
lua_entity.itemstring = ""
end
object:remove()
@@ -108,15 +104,15 @@ local function vacuum(pos, radius)
end
minetest.register_abm({nodenames = {"group:vacuum_tube"},
- 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
+ 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
})