forked from mtcontrib/pipeworks
		
	Compare commits
	
		
			19 Commits
		
	
	
		
			ee03959a65
			...
			2021-04-14
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | db6d1bd9c1 | ||
|  | 79dc5f5c7d | ||
|  | 01d44056a2 | ||
|  | c7d44272e6 | ||
|  | 5837d62979 | ||
|  | fc6efb450c | ||
|  | 828c50e85d | ||
|  | 4add40705f | ||
|  | a6e4f2dceb | ||
|  | 7ad991ce40 | ||
|  | d2954c5277 | ||
|  | 9ad6e5d07a | ||
|  | 31e1255245 | ||
|  | a735d1a155 | ||
|  | a2c0dd1130 | ||
|  | f0ef43823c | ||
|  | 17a602a5a1 | ||
|  | 2294a23582 | ||
|  | b2d2ccbcba | 
							
								
								
									
										8
									
								
								.gitlab-ci.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								.gitlab-ci.yml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,8 @@ | |||||||
|  | stages: | ||||||
|  |   - test | ||||||
|  |  | ||||||
|  | luacheck: | ||||||
|  |  stage: test | ||||||
|  |  image: pipelinecomponents/luacheck:latest | ||||||
|  |  script: | ||||||
|  |   - luacheck . | ||||||
							
								
								
									
										24
									
								
								.luacheckrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								.luacheckrc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,24 @@ | |||||||
|  | unused_args = false | ||||||
|  | max_line_length= 240 | ||||||
|  | redefined = false | ||||||
|  |  | ||||||
|  | globals = { | ||||||
|  | 	"pipeworks", | ||||||
|  | 	"luaentity" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | read_globals = { | ||||||
|  | 	-- Stdlib | ||||||
|  | 	string = {fields = {"split"}}, | ||||||
|  | 	table = {fields = {"copy", "getn"}}, | ||||||
|  |  | ||||||
|  | 	-- Minetest | ||||||
|  | 	"vector", "ItemStack", | ||||||
|  | 	"dump", "minetest", | ||||||
|  | 	"VoxelManip", "VoxelArea", | ||||||
|  |  | ||||||
|  | 	-- mods | ||||||
|  | 	"default", "mesecon", "digiline", | ||||||
|  | 	"screwdriver", "unified_inventory" | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -47,7 +47,7 @@ local function autocraft(inventory, craft) | |||||||
| 	end | 	end | ||||||
| 	-- consume material | 	-- consume material | ||||||
| 	for itemname, number in pairs(consumption) do | 	for itemname, number in pairs(consumption) do | ||||||
| 		for i = 1, number do -- We have to do that since remove_item does not work if count > stack_max | 		for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max | ||||||
| 			inventory:remove_item("src", ItemStack(itemname)) | 			inventory:remove_item("src", ItemStack(itemname)) | ||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
| @@ -73,7 +73,7 @@ local function run_autocrafter(pos, elapsed) | |||||||
| 		return false | 		return false | ||||||
| 	end | 	end | ||||||
|  |  | ||||||
| 	for step = 1, math.floor(elapsed/craft_time) do | 	for _ = 1, math.floor(elapsed/craft_time) do | ||||||
| 		local continue = autocraft(inventory, craft) | 		local continue = autocraft(inventory, craft) | ||||||
| 		if not continue then return false end | 		if not continue then return false end | ||||||
| 	end | 	end | ||||||
| @@ -106,7 +106,6 @@ local function after_recipe_change(pos, inventory) | |||||||
| 		inventory:set_stack("output", 1, "") | 		inventory:set_stack("output", 1, "") | ||||||
| 		return | 		return | ||||||
| 	end | 	end | ||||||
| 	local recipe_changed = false |  | ||||||
| 	local recipe = inventory:get_list("recipe") | 	local recipe = inventory:get_list("recipe") | ||||||
|  |  | ||||||
| 	local hash = minetest.hash_node_position(pos) | 	local hash = minetest.hash_node_position(pos) | ||||||
| @@ -424,6 +423,7 @@ minetest.register_node("pipeworks:autocrafter", { | |||||||
| 		}, | 		}, | ||||||
| 	}, | 	}, | ||||||
| }) | }) | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:autocrafter" | ||||||
|  |  | ||||||
| minetest.register_craft( { | minetest.register_craft( { | ||||||
| 	output = "pipeworks:autocrafter 2", | 	output = "pipeworks:autocrafter 2", | ||||||
|   | |||||||
| @@ -81,7 +81,7 @@ local function tube_autoroute(pos) | |||||||
| 	local basename = nodedef.basename | 	local basename = nodedef.basename | ||||||
| 	if nodedef.style == "old" then | 	if nodedef.style == "old" then | ||||||
| 		local nsurround = "" | 		local nsurround = "" | ||||||
| 		for i, n in ipairs(active) do | 		for _, n in ipairs(active) do | ||||||
| 			nsurround = nsurround..n | 			nsurround = nsurround..n | ||||||
| 		end | 		end | ||||||
| 		nctr.name = basename.."_"..nsurround | 		nctr.name = basename.."_"..nsurround | ||||||
|   | |||||||
| @@ -114,7 +114,7 @@ local fs_helpers = {} | |||||||
| pipeworks.fs_helpers = fs_helpers | pipeworks.fs_helpers = fs_helpers | ||||||
| function fs_helpers.on_receive_fields(pos, fields) | function fs_helpers.on_receive_fields(pos, fields) | ||||||
| 	local meta = minetest.get_meta(pos) | 	local meta = minetest.get_meta(pos) | ||||||
| 	for field, value in pairs(fields) do | 	for field in pairs(fields) do | ||||||
| 		if pipeworks.string_startswith(field, "fs_helpers_cycling:") then | 		if pipeworks.string_startswith(field, "fs_helpers_cycling:") then | ||||||
| 			local l = field:split(":") | 			local l = field:split(":") | ||||||
| 			local new_value = tonumber(l[2]) | 			local new_value = tonumber(l[2]) | ||||||
| @@ -223,7 +223,7 @@ function pipeworks.create_fake_player(def, is_dynamic) | |||||||
| 				return self._inventory:set_stack(def.wield_list, | 				return self._inventory:set_stack(def.wield_list, | ||||||
| 					self._wield_index, item) | 					self._wield_index, item) | ||||||
| 			end | 			end | ||||||
| 			_wielded_item = ItemStack(item) | 			self._wielded_item = ItemStack(item) | ||||||
| 		end, | 		end, | ||||||
| 		get_wielded_item = function(self, item) | 		get_wielded_item = function(self, item) | ||||||
| 			if self._inventory and def.wield_list then | 			if self._inventory and def.wield_list then | ||||||
| @@ -242,17 +242,18 @@ function pipeworks.create_fake_player(def, is_dynamic) | |||||||
| 		set_bone_position = delay(), | 		set_bone_position = delay(), | ||||||
| 		hud_change = delay(), | 		hud_change = delay(), | ||||||
| 	} | 	} | ||||||
| 	local _trash |  | ||||||
| 	-- Getter & setter functions | 	-- Getter & setter functions | ||||||
| 	p.get_inventory_formspec, p.set_inventory_formspec | 	p.get_inventory_formspec, p.set_inventory_formspec | ||||||
| 		= get_set_wrap("formspec", is_dynamic) | 		= get_set_wrap("formspec", is_dynamic) | ||||||
| 	p.get_breath, p.set_breath = get_set_wrap("breath", is_dynamic) | 	p.get_breath, p.set_breath = get_set_wrap("breath", is_dynamic) | ||||||
| 	p.get_hp, p.set_hp = get_set_wrap("hp", is_dynamic) | 	p.get_hp, p.set_hp = get_set_wrap("hp", is_dynamic) | ||||||
| 	p.get_pos, p.set_pos = get_set_wrap("pos", is_dynamic) | 	p.get_pos, p.set_pos = get_set_wrap("pos", is_dynamic) | ||||||
| 	_trash, p.move_to = get_set_wrap("pos", is_dynamic) |  | ||||||
| 	p.get_wield_index, p.set_wield_index = get_set_wrap("wield_index", true) | 	p.get_wield_index, p.set_wield_index = get_set_wrap("wield_index", true) | ||||||
| 	p.get_properties, p.set_properties = get_set_wrap("properties", false) | 	p.get_properties, p.set_properties = get_set_wrap("properties", false) | ||||||
|  |  | ||||||
|  | 	-- For players, move_to and get_pos do the same | ||||||
|  | 	p.move_to = p.get_pos | ||||||
|  |  | ||||||
| 	-- Backwards compatibilty | 	-- Backwards compatibilty | ||||||
| 	p.getpos = p.get_pos | 	p.getpos = p.get_pos | ||||||
| 	p.setpos = p.set_pos | 	p.setpos = p.set_pos | ||||||
|   | |||||||
| @@ -65,7 +65,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) | |||||||
| 				local node = minetest.get_node(pos) | 				local node = minetest.get_node(pos) | ||||||
|  |  | ||||||
| 				open_chests[pn] = nil | 				open_chests[pn] = nil | ||||||
| 				for k, v in pairs(open_chests) do | 				for _, v in pairs(open_chests) do | ||||||
| 					if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then | 					if v.pos.x == pos.x and v.pos.y == pos.y and v.pos.z == pos.z then | ||||||
| 						return true | 						return true | ||||||
| 					end | 					end | ||||||
| @@ -230,7 +230,7 @@ override.tiles = { | |||||||
| } | } | ||||||
|  |  | ||||||
| -- Add the extra groups | -- Add the extra groups | ||||||
| for i,v in ipairs({override_protected, override, override_open, override_protected_open}) do | for _,v in ipairs({override_protected, override, override_open, override_protected_open}) do | ||||||
| 	v.groups.tubedevice = 1 | 	v.groups.tubedevice = 1 | ||||||
| 	v.groups.tubedevice_receiver = 1 | 	v.groups.tubedevice_receiver = 1 | ||||||
| end | end | ||||||
|   | |||||||
| @@ -7,7 +7,7 @@ local DS = minetest.get_translator("default") | |||||||
|  |  | ||||||
| local fs_helpers = pipeworks.fs_helpers | local fs_helpers = pipeworks.fs_helpers | ||||||
|  |  | ||||||
| tube_entry = "^pipeworks_tube_connection_stony.png" | local tube_entry = "^pipeworks_tube_connection_stony.png" | ||||||
|  |  | ||||||
| local function active_formspec(fuel_percent, item_percent, pos, meta) | local function active_formspec(fuel_percent, item_percent, pos, meta) | ||||||
| 	local formspec = | 	local formspec = | ||||||
|   | |||||||
| @@ -28,6 +28,7 @@ minetest.register_node("pipeworks:steel_block_embedded_tube", { | |||||||
| 	after_dig_node = pipeworks.after_dig, | 	after_dig_node = pipeworks.after_dig, | ||||||
| 	on_rotate = pipeworks.on_rotate, | 	on_rotate = pipeworks.on_rotate, | ||||||
| }) | }) | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:steel_block_embedded_tube" | ||||||
|  |  | ||||||
| minetest.register_craft( { | minetest.register_craft( { | ||||||
| 	output = "pipeworks:steel_block_embedded_tube 1", | 	output = "pipeworks:steel_block_embedded_tube 1", | ||||||
| @@ -45,6 +46,10 @@ local pane_box = { | |||||||
| 		{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 } -- pane | 		{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 } -- pane | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes | ||||||
|  | 	and "clip" or true | ||||||
|  |  | ||||||
| minetest.register_node("pipeworks:steel_pane_embedded_tube", { | minetest.register_node("pipeworks:steel_pane_embedded_tube", { | ||||||
| 	drawtype = "nodebox", | 	drawtype = "nodebox", | ||||||
| 	description = S("Airtight panel embedded tube"), | 	description = S("Airtight panel embedded tube"), | ||||||
| @@ -55,6 +60,7 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", { | |||||||
| 		"pipeworks_pane_embedded_tube_sides.png", | 		"pipeworks_pane_embedded_tube_sides.png", | ||||||
| 		"pipeworks_pane_embedded_tube_ends.png", "pipeworks_pane_embedded_tube_ends.png", | 		"pipeworks_pane_embedded_tube_ends.png", "pipeworks_pane_embedded_tube_ends.png", | ||||||
| 		}, | 		}, | ||||||
|  | 	use_texture_alpha = texture_alpha_mode, | ||||||
| 	node_box = pane_box, | 	node_box = pane_box, | ||||||
| 	selection_box = pane_box, | 	selection_box = pane_box, | ||||||
| 	collision_box = pane_box, | 	collision_box = pane_box, | ||||||
| @@ -76,6 +82,7 @@ minetest.register_node("pipeworks:steel_pane_embedded_tube", { | |||||||
| 	after_dig_node = pipeworks.after_dig, | 	after_dig_node = pipeworks.after_dig, | ||||||
| 	on_rotate = pipeworks.on_rotate, | 	on_rotate = pipeworks.on_rotate, | ||||||
| }) | }) | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:steel_pane_embedded_tube" | ||||||
|  |  | ||||||
| minetest.register_craft( { | minetest.register_craft( { | ||||||
| 	output = "pipeworks:steel_pane_embedded_tube 1", | 	output = "pipeworks:steel_pane_embedded_tube 1", | ||||||
|   | |||||||
							
								
								
									
										37
									
								
								devices.lua
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								devices.lua
									
									
									
									
									
								
							| @@ -10,7 +10,7 @@ function pipeworks.fix_after_rotation(pos, node, user, mode, new_param2) | |||||||
|  |  | ||||||
| 	if string.find(node.name, "spigot") then new_param2 = new_param2 % 4 end | 	if string.find(node.name, "spigot") then new_param2 = new_param2 % 4 end | ||||||
|  |  | ||||||
| 	newnode = string.gsub(node.name, "_on", "_off") | 	local newnode = string.gsub(node.name, "_on", "_off") | ||||||
| 	minetest.swap_node(pos, { name = newnode, param2 = new_param2 }) | 	minetest.swap_node(pos, { name = newnode, param2 = new_param2 }) | ||||||
| 	pipeworks.scan_for_pipe_objects(pos) | 	pipeworks.scan_for_pipe_objects(pos) | ||||||
|  |  | ||||||
| @@ -36,9 +36,7 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing) | |||||||
| 			local under = pointed_thing.under | 			local under = pointed_thing.under | ||||||
| 			local fdir = minetest.dir_to_facedir(placer:get_look_dir()) | 			local fdir = minetest.dir_to_facedir(placer:get_look_dir()) | ||||||
| 			local undernode = minetest.get_node(under) | 			local undernode = minetest.get_node(under) | ||||||
| 			local abovenode = minetest.get_node(above) |  | ||||||
| 			local uname = undernode.name | 			local uname = undernode.name | ||||||
| 			local aname = abovenode.name |  | ||||||
| 			local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0) | 			local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0) | ||||||
| 			local pos1 = above | 			local pos1 = above | ||||||
|  |  | ||||||
| @@ -105,6 +103,7 @@ if minetest.get_modpath("mesecons") then | |||||||
| 	} | 	} | ||||||
| end | end | ||||||
|  |  | ||||||
|  | --[[ | ||||||
| local pipes_devicelist = { | local pipes_devicelist = { | ||||||
| 	"pump", | 	"pump", | ||||||
| 	"valve", | 	"valve", | ||||||
| @@ -120,14 +119,15 @@ local pipes_devicelist = { | |||||||
| 	"storage_tank_9", | 	"storage_tank_9", | ||||||
| 	"storage_tank_10" | 	"storage_tank_10" | ||||||
| } | } | ||||||
|  | --]] | ||||||
|  |  | ||||||
| -- Now define the nodes. | -- Now define the nodes. | ||||||
|  |  | ||||||
| local states = { "on", "off" } | local states = { "on", "off" } | ||||||
| local dgroups = "" |  | ||||||
|  |  | ||||||
| for s in ipairs(states) do | for s in ipairs(states) do | ||||||
|  |  | ||||||
|  | 	local dgroups | ||||||
| 	if states[s] == "off" then | 	if states[s] == "off" then | ||||||
| 		dgroups = {snappy=3, pipe=1} | 		dgroups = {snappy=3, pipe=1} | ||||||
| 	else | 	else | ||||||
| @@ -187,11 +187,11 @@ for s in ipairs(states) do | |||||||
| 		paramtype = "light", | 		paramtype = "light", | ||||||
| 		paramtype2 = "facedir", | 		paramtype2 = "facedir", | ||||||
| 		selection_box = { | 		selection_box = { | ||||||
| 	             	type = "fixed", | 			type = "fixed", | ||||||
| 			fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | 			fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | ||||||
| 		}, | 		}, | ||||||
| 		collision_box = { | 		collision_box = { | ||||||
| 	             	type = "fixed", | 			type = "fixed", | ||||||
| 			fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | 			fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | ||||||
| 		}, | 		}, | ||||||
| 		groups = dgroups, | 		groups = dgroups, | ||||||
| @@ -222,6 +222,8 @@ for s in ipairs(states) do | |||||||
| 		new_flow_logic_register.directional_horizonal_rotate(nodename_valve_empty, true) | 		new_flow_logic_register.directional_horizonal_rotate(nodename_valve_empty, true) | ||||||
| 	end | 	end | ||||||
| end | end | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:pump_off" | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:valve_off_empty" | ||||||
|  |  | ||||||
| local nodename_valve_loaded = "pipeworks:valve_on_loaded" | local nodename_valve_loaded = "pipeworks:valve_on_loaded" | ||||||
| minetest.register_node(nodename_valve_loaded, { | minetest.register_node(nodename_valve_loaded, { | ||||||
| @@ -233,11 +235,11 @@ minetest.register_node(nodename_valve_loaded, { | |||||||
| 	paramtype = "light", | 	paramtype = "light", | ||||||
| 	paramtype2 = "facedir", | 	paramtype2 = "facedir", | ||||||
| 	selection_box = { | 	selection_box = { | ||||||
|              	type = "fixed", | 		type = "fixed", | ||||||
| 		fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | 		fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | ||||||
| 	}, | 	}, | ||||||
| 	collision_box = { | 	collision_box = { | ||||||
|              	type = "fixed", | 		type = "fixed", | ||||||
| 		fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | 		fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | ||||||
| 	}, | 	}, | ||||||
| 	groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, | 	groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, | ||||||
| @@ -301,6 +303,7 @@ minetest.register_node("pipeworks:grating", { | |||||||
| 	end, | 	end, | ||||||
| 	on_rotate = false | 	on_rotate = false | ||||||
| }) | }) | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:grating" | ||||||
|  |  | ||||||
| -- outlet spigot | -- outlet spigot | ||||||
|  |  | ||||||
| @@ -378,6 +381,8 @@ minetest.register_node(nodename_spigot_loaded, { | |||||||
| 	drop = "pipeworks:spigot", | 	drop = "pipeworks:spigot", | ||||||
| 	on_rotate = pipeworks.fix_after_rotation | 	on_rotate = pipeworks.fix_after_rotation | ||||||
| }) | }) | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:spigot" | ||||||
|  |  | ||||||
| -- new flow logic does not currently distinguish between these two visual states. | -- new flow logic does not currently distinguish between these two visual states. | ||||||
| -- register both so existing flowing spigots continue to work (even if the visual doesn't match the spigot's behaviour). | -- register both so existing flowing spigots continue to work (even if the visual doesn't match the spigot's behaviour). | ||||||
| new_flow_logic_register.directional_horizonal_rotate(nodename_spigot_empty, false) | new_flow_logic_register.directional_horizonal_rotate(nodename_spigot_empty, false) | ||||||
| @@ -441,6 +446,9 @@ minetest.register_node(nodename_panel_loaded, { | |||||||
| 	drop = "pipeworks:entry_panel_empty", | 	drop = "pipeworks:entry_panel_empty", | ||||||
| 	on_rotate = pipeworks.fix_after_rotation | 	on_rotate = pipeworks.fix_after_rotation | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:entry_panel_empty" | ||||||
|  |  | ||||||
| -- TODO: AFAIK the two panels have no visual difference, so are redundant under new flow logic - alias? | -- TODO: AFAIK the two panels have no visual difference, so are redundant under new flow logic - alias? | ||||||
| new_flow_logic_register.directional_horizonal_rotate(nodename_panel_empty, true) | new_flow_logic_register.directional_horizonal_rotate(nodename_panel_empty, true) | ||||||
| new_flow_logic_register.directional_horizonal_rotate(nodename_panel_loaded, true) | new_flow_logic_register.directional_horizonal_rotate(nodename_panel_loaded, true) | ||||||
| @@ -465,7 +473,7 @@ minetest.register_node(nodename_sensor_empty, { | |||||||
| 	end, | 	end, | ||||||
| 	on_construct = function(pos) | 	on_construct = function(pos) | ||||||
| 		if mesecon then | 		if mesecon then | ||||||
| 			mesecon.receptor_off(pos, rules)  | 			mesecon.receptor_off(pos, pipeworks.mesecons_rules) | ||||||
| 		end | 		end | ||||||
| 	end, | 	end, | ||||||
| 	selection_box = { | 	selection_box = { | ||||||
| @@ -504,7 +512,7 @@ minetest.register_node(nodename_sensor_loaded, { | |||||||
| 	end, | 	end, | ||||||
| 	on_construct = function(pos) | 	on_construct = function(pos) | ||||||
| 		if mesecon then | 		if mesecon then | ||||||
| 			mesecon.receptor_on(pos, rules)  | 			mesecon.receptor_on(pos, pipeworks.mesecons_rules) | ||||||
| 		end | 		end | ||||||
| 	end, | 	end, | ||||||
| 	selection_box = { | 	selection_box = { | ||||||
| @@ -525,6 +533,8 @@ minetest.register_node(nodename_sensor_loaded, { | |||||||
| 	mesecons = pipereceptor_on, | 	mesecons = pipereceptor_on, | ||||||
| 	on_rotate = pipeworks.fix_after_rotation | 	on_rotate = pipeworks.fix_after_rotation | ||||||
| }) | }) | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:flow_sensor_empty" | ||||||
|  |  | ||||||
| new_flow_logic_register.directional_horizonal_rotate(nodename_sensor_empty, true) | new_flow_logic_register.directional_horizonal_rotate(nodename_sensor_empty, true) | ||||||
| new_flow_logic_register.directional_horizonal_rotate(nodename_sensor_loaded, true) | new_flow_logic_register.directional_horizonal_rotate(nodename_sensor_loaded, true) | ||||||
| -- activate flow sensor at roughly half the pressure pumps drive pipes | -- activate flow sensor at roughly half the pressure pumps drive pipes | ||||||
| @@ -603,6 +613,7 @@ for fill = 0, 10 do | |||||||
| 		on_rotate = false | 		on_rotate = false | ||||||
| 	}) | 	}) | ||||||
| end | end | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:storage_tank_0" | ||||||
|  |  | ||||||
| -- fountainhead | -- fountainhead | ||||||
|  |  | ||||||
| @@ -626,7 +637,7 @@ minetest.register_node(nodename_fountain_empty, { | |||||||
| 	end, | 	end, | ||||||
| 	on_construct = function(pos) | 	on_construct = function(pos) | ||||||
| 		if mesecon then | 		if mesecon then | ||||||
| 			mesecon.receptor_on(pos, rules)  | 			mesecon.receptor_on(pos, pipeworks.mesecons_rules) | ||||||
| 		end | 		end | ||||||
| 	end, | 	end, | ||||||
| 	selection_box = { | 	selection_box = { | ||||||
| @@ -639,6 +650,7 @@ minetest.register_node(nodename_fountain_empty, { | |||||||
| 	}, | 	}, | ||||||
| 	on_rotate = false | 	on_rotate = false | ||||||
| }) | }) | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:fountainhead" | ||||||
|  |  | ||||||
| local nodename_fountain_loaded = "pipeworks:fountainhead_pouring" | local nodename_fountain_loaded = "pipeworks:fountainhead_pouring" | ||||||
| minetest.register_node(nodename_fountain_loaded, { | minetest.register_node(nodename_fountain_loaded, { | ||||||
| @@ -661,7 +673,7 @@ minetest.register_node(nodename_fountain_loaded, { | |||||||
| 	end, | 	end, | ||||||
| 	on_construct = function(pos) | 	on_construct = function(pos) | ||||||
| 		if mesecon then | 		if mesecon then | ||||||
| 			mesecon.receptor_on(pos, rules)  | 			mesecon.receptor_on(pos, pipeworks.mesecons_rules) | ||||||
| 		end | 		end | ||||||
| 	end, | 	end, | ||||||
| 	selection_box = { | 	selection_box = { | ||||||
| @@ -734,6 +746,7 @@ minetest.register_node(nodename_sp_loaded, { | |||||||
| 	check_for_pole = pipeworks.check_for_vert_pipe, | 	check_for_pole = pipeworks.check_for_vert_pipe, | ||||||
| 	check_for_horiz_pole = pipeworks.check_for_horiz_pipe | 	check_for_horiz_pole = pipeworks.check_for_horiz_pipe | ||||||
| }) | }) | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:straight_pipe_empty" | ||||||
|  |  | ||||||
| new_flow_logic_register.directional_horizonal_rotate(nodename_sp_empty, true) | new_flow_logic_register.directional_horizonal_rotate(nodename_sp_empty, true) | ||||||
| new_flow_logic_register.directional_horizonal_rotate(nodename_sp_loaded, true) | new_flow_logic_register.directional_horizonal_rotate(nodename_sp_loaded, true) | ||||||
|   | |||||||
| @@ -1,10 +1,6 @@ | |||||||
| local S = minetest.get_translator("pipeworks") | local S = minetest.get_translator("pipeworks") | ||||||
| local fs_helpers = pipeworks.fs_helpers | local fs_helpers = pipeworks.fs_helpers | ||||||
|  |  | ||||||
| local function delay(x) |  | ||||||
| 	return (function() return x end) |  | ||||||
| end |  | ||||||
|  |  | ||||||
| local function set_filter_infotext(data, meta) | local function set_filter_infotext(data, meta) | ||||||
| 	local infotext = S("@1 Filter-Injector", data.wise_desc) | 	local infotext = S("@1 Filter-Injector", data.wise_desc) | ||||||
| 	if meta:get_int("slotseq_mode") == 2 then | 	if meta:get_int("slotseq_mode") == 2 then | ||||||
| @@ -18,17 +14,20 @@ local function set_filter_formspec(data, meta) | |||||||
|  |  | ||||||
| 	local formspec | 	local formspec | ||||||
| 	if data.digiline then | 	if data.digiline then | ||||||
| 		formspec = "size[8,2.7]".. | 		formspec = | ||||||
| 			"item_image[0,0;1,1;pipeworks:"..data.name.."]".. | 			"size[8.5,3]".. | ||||||
| 			"label[1,0;"..minetest.formspec_escape(itemname).."]".. | 			"item_image[0.2,0;1,1;pipeworks:"..data.name.."]".. | ||||||
| 			"field[0.3,1.5;8.0,1;channel;"..S("Channel")..";${channel}]".. | 			"label[1.2,0.2;"..minetest.formspec_escape(itemname).."]".. | ||||||
| 			fs_helpers.cycling_button(meta, "button[0,2;4,1", "slotseq_mode", | 			"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]".. | ||||||
|  | 			"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]".. | ||||||
|  | 			fs_helpers.cycling_button(meta, "button[0.2,2.3;4.05,1", "slotseq_mode", | ||||||
| 				{S("Sequence slots by Priority"), | 				{S("Sequence slots by Priority"), | ||||||
| 				 S("Sequence slots Randomly"), | 				 S("Sequence slots Randomly"), | ||||||
| 				 S("Sequence slots by Rotation")}).. | 				 S("Sequence slots by Rotation")}).. | ||||||
| 			fs_helpers.cycling_button(meta, "button[4,2;4,1", "exmatch_mode", | 			fs_helpers.cycling_button(meta, "button[4.25,2.3;4.05,1", "exmatch_mode", | ||||||
| 				{S("Exact match - off"), | 				{S("Exact match - off"), | ||||||
| 				 S("Exact match - on")}) | 				 S("Exact match - on")}).. | ||||||
|  | 			"button_exit[6.3,1.3;2,1;close;"..S("Close").."]" | ||||||
| 	else | 	else | ||||||
| 		local exmatch_button = "" | 		local exmatch_button = "" | ||||||
| 		if data.stackwise then | 		if data.stackwise then | ||||||
| @@ -326,7 +325,8 @@ local function punch_filter(data, filtpos, filtnode, msg) | |||||||
| 				end | 				end | ||||||
| 				local pos = vector.add(frompos, vector.multiply(dir, 1.4)) | 				local pos = vector.add(frompos, vector.multiply(dir, 1.4)) | ||||||
| 				local start_pos = vector.add(frompos, dir) | 				local start_pos = vector.add(frompos, dir) | ||||||
| 				local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item, fakePlayer:get_player_name()) | 				pipeworks.tube_inject_item(pos, start_pos, dir, item, | ||||||
|  | 					fakePlayer:get_player_name()) | ||||||
| 				return true -- only fire one item, please | 				return true -- only fire one item, please | ||||||
| 			end | 			end | ||||||
| 		end | 		end | ||||||
| @@ -428,10 +428,14 @@ for _, data in ipairs({ | |||||||
| 		end | 		end | ||||||
|  |  | ||||||
| 		node.on_receive_fields = function(pos, formname, fields, sender) | 		node.on_receive_fields = function(pos, formname, fields, sender) | ||||||
| 			if not pipeworks.may_configure(pos, sender) then return end | 			if (fields.quit and not fields.key_enter_field) | ||||||
|  | 			or not pipeworks.may_configure(pos, sender) then | ||||||
|  | 				return | ||||||
|  | 			end | ||||||
|  |  | ||||||
| 			fs_helpers.on_receive_fields(pos, fields) | 			fs_helpers.on_receive_fields(pos, fields) | ||||||
|  |  | ||||||
| 			if fields.channel then | 			if fields.channel and (fields.key_enter_field == "channel" or fields.set_channel) then | ||||||
| 				minetest.get_meta(pos):set_string("channel", fields.channel) | 				minetest.get_meta(pos):set_string("channel", fields.channel) | ||||||
| 			end | 			end | ||||||
|  |  | ||||||
| @@ -475,6 +479,7 @@ for _, data in ipairs({ | |||||||
|  |  | ||||||
|  |  | ||||||
| 	minetest.register_node("pipeworks:"..data.name, node) | 	minetest.register_node("pipeworks:"..data.name, node) | ||||||
|  | 	pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:"..data.name | ||||||
| end | end | ||||||
|  |  | ||||||
| minetest.register_craft( { | minetest.register_craft( { | ||||||
|   | |||||||
							
								
								
									
										15
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								init.lua
									
									
									
									
									
								
							| @@ -5,8 +5,7 @@ | |||||||
| -- | -- | ||||||
|  |  | ||||||
| pipeworks = {} | pipeworks = {} | ||||||
|  | pipeworks.ui_cat_tube_list = {} | ||||||
| local DEBUG = false |  | ||||||
|  |  | ||||||
| pipeworks.worldpath = minetest.get_worldpath() | pipeworks.worldpath = minetest.get_worldpath() | ||||||
| pipeworks.modpath = minetest.get_modpath("pipeworks") | pipeworks.modpath = minetest.get_modpath("pipeworks") | ||||||
| @@ -150,4 +149,16 @@ end | |||||||
|  |  | ||||||
| minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty") | minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty") | ||||||
|  |  | ||||||
|  | -- Unified Inventory categories integration | ||||||
|  |  | ||||||
|  | if unified_inventory and unified_inventory.registered_categories then | ||||||
|  | 	if not unified_inventory.registered_categories["automation"] then | ||||||
|  | 		unified_inventory.register_category("automation", { | ||||||
|  | 			symbol = "pipeworks:lua_tube000000", | ||||||
|  | 			label = "Automation components" | ||||||
|  | 		}) | ||||||
|  | 	end | ||||||
|  | 	unified_inventory.add_category_items("automation", pipeworks.ui_cat_tube_list) | ||||||
|  | end | ||||||
|  |  | ||||||
| minetest.log("info", "Pipeworks loaded!") | minetest.log("info", "Pipeworks loaded!") | ||||||
|   | |||||||
| @@ -42,7 +42,7 @@ minetest.register_globalstep(function(dtime) | |||||||
| 		return | 		return | ||||||
| 	end | 	end | ||||||
| 	tube_item_count = {} | 	tube_item_count = {} | ||||||
| 	for id, entity in pairs(luaentity.entities) do | 	for _, entity in pairs(luaentity.entities) do | ||||||
| 		if entity.name == "pipeworks:tubed_item" then | 		if entity.name == "pipeworks:tubed_item" then | ||||||
| 			local h = minetest.hash_node_position(vector.round(entity._pos)) | 			local h = minetest.hash_node_position(vector.round(entity._pos)) | ||||||
| 			tube_item_count[h] = (tube_item_count[h] or 0) + 1 | 			tube_item_count[h] = (tube_item_count[h] or 0) + 1 | ||||||
| @@ -55,15 +55,22 @@ end) | |||||||
| -- tube overload mechanism: | -- tube overload mechanism: | ||||||
| -- when the tube's item count (tracked in the above tube_item_count table) | -- when the tube's item count (tracked in the above tube_item_count table) | ||||||
| -- exceeds the limit configured per tube, replace it with a broken one. | -- exceeds the limit configured per tube, replace it with a broken one. | ||||||
|  |  | ||||||
|  | function pipeworks.break_tube(pos) | ||||||
|  | 	local node = minetest.get_node(pos) | ||||||
|  | 	local meta = minetest.get_meta(pos) | ||||||
|  | 	meta:set_string("the_tube_was", minetest.serialize(node)) | ||||||
|  | 	minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) | ||||||
|  | 	pipeworks.scan_for_tube_objects(pos) | ||||||
|  | end | ||||||
|  |  | ||||||
| local crunch_tube = function(pos, cnode, cmeta) | local crunch_tube = function(pos, cnode, cmeta) | ||||||
| 	if enable_max_limit then | 	if enable_max_limit then | ||||||
| 		local h = minetest.hash_node_position(pos) | 		local h = minetest.hash_node_position(pos) | ||||||
| 		local itemcount = tube_item_count[h] or 0 | 		local itemcount = tube_item_count[h] or 0 | ||||||
| 		if itemcount > max_tube_limit then | 		if itemcount > max_tube_limit then | ||||||
| 			cmeta:set_string("the_tube_was", minetest.serialize(cnode)) |  | ||||||
| 			pipeworks.logger("Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")") | 			pipeworks.logger("Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")") | ||||||
| 			minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) | 			pipeworks.break_tube(pos) | ||||||
| 			pipeworks.scan_for_tube_objects(pos) |  | ||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
| end | end | ||||||
| @@ -194,6 +201,7 @@ minetest.register_entity("pipeworks:tubed_item", { | |||||||
|  |  | ||||||
| 	from_data = function(self, itemstring) | 	from_data = function(self, itemstring) | ||||||
| 		local stack = ItemStack(itemstring) | 		local stack = ItemStack(itemstring) | ||||||
|  | 		--[[ | ||||||
| 		local itemtable = stack:to_table() | 		local itemtable = stack:to_table() | ||||||
| 		local itemname = nil | 		local itemname = nil | ||||||
| 		if itemtable then | 		if itemtable then | ||||||
| @@ -205,6 +213,7 @@ minetest.register_entity("pipeworks:tubed_item", { | |||||||
| 			item_texture = minetest.registered_items[itemname].inventory_image | 			item_texture = minetest.registered_items[itemname].inventory_image | ||||||
| 			item_type = minetest.registered_items[itemname].type | 			item_type = minetest.registered_items[itemname].type | ||||||
| 		end | 		end | ||||||
|  | 		--]] | ||||||
| 		self.object:set_properties({ | 		self.object:set_properties({ | ||||||
| 			is_visible = true, | 			is_visible = true, | ||||||
| 			textures = {stack:get_name()} | 			textures = {stack:get_name()} | ||||||
| @@ -391,7 +400,7 @@ if minetest.get_modpath("mesecons_mvps") then | |||||||
| 		for _, n in ipairs(moved_nodes) do | 		for _, n in ipairs(moved_nodes) do | ||||||
| 			moved[minetest.hash_node_position(n.oldpos)] = vector.subtract(n.pos, n.oldpos) | 			moved[minetest.hash_node_position(n.oldpos)] = vector.subtract(n.pos, n.oldpos) | ||||||
| 		end | 		end | ||||||
| 		for id, entity in pairs(luaentity.entities) do | 		for _, entity in pairs(luaentity.entities) do | ||||||
| 			if entity.name == "pipeworks:tubed_item" then | 			if entity.name == "pipeworks:tubed_item" then | ||||||
| 				local pos = entity:get_pos() | 				local pos = entity:get_pos() | ||||||
| 				local rpos = vector.round(pos) | 				local rpos = vector.round(pos) | ||||||
|   | |||||||
| @@ -3,6 +3,10 @@ | |||||||
| # License: CC-by-SA 4.0 | # License: CC-by-SA 4.0 | ||||||
| # Author: Louis Royer <4259825-lroyer@users.noreply.gitlab.com> | # Author: Louis Royer <4259825-lroyer@users.noreply.gitlab.com> | ||||||
|  |  | ||||||
|  | ## generic interaction | ||||||
|  | Set=Fixer | ||||||
|  | Close=Fermer | ||||||
|  |  | ||||||
| ## digilines interfacing | ## digilines interfacing | ||||||
| Channel=Canal | Channel=Canal | ||||||
|  |  | ||||||
| @@ -86,11 +90,12 @@ Sorting pneumatic tube=Tuyau pneumatique triant | |||||||
|  |  | ||||||
| ## teleport tube | ## teleport tube | ||||||
| Receive=Reception | Receive=Reception | ||||||
| channels are public by default=Les canaux sont publics par défaut | Channels are public by default=Les canaux sont publics par défaut | ||||||
| use <player>:<channel> for fully private channels=Utilisez <joueur>:<canal> pour un canal entièrement privé | Use <player>:<channel> for fully private channels=Utilisez <joueur>:<canal> pour un canal entièrement privé | ||||||
| use <player>;<channel> for private receivers=Utilisez <joueur>;<canal> pour une réception privée | Use <player>;<channel> for private receivers=Utilisez <joueur>;<canal> pour une réception privée | ||||||
| Teleporting Pneumatic Tube Segment=Segment de tuyau pneumatique téléporteur | Teleporting Pneumatic Tube Segment=Segment de tuyau pneumatique téléporteur | ||||||
| unconfigured Teleportation Tube=Tuyau téléporteur non-configuré | Teleporting Tube=Tuyau pneumatique téléporteur | ||||||
|  | Unconfigured Teleportation Tube=Tuyau téléporteur non-configuré | ||||||
| Sorry, channel '@1' is reserved for exclusive use by @2=Désolé, le canal '@1' est réservé exclusivement à l’utilisateur @2. | Sorry, channel '@1' is reserved for exclusive use by @2=Désolé, le canal '@1' est réservé exclusivement à l’utilisateur @2. | ||||||
| Sorry, receiving from channel '@1' is reserved for @2=Désolé, la réception depuis le canal '@1' est réservée pour @2. | Sorry, receiving from channel '@1' is reserved for @2=Désolé, la réception depuis le canal '@1' est réservée pour @2. | ||||||
| Teleportation Tube @1 on '@2'=Tuyau de téléportation @1 sur '@2' | Teleportation Tube @1 on '@2'=Tuyau de téléportation @1 sur '@2' | ||||||
| @@ -102,7 +107,9 @@ Trash Can=Poubelle | |||||||
| Pneumatic tube segment (legacy)=Segment de tuyau pneumatique (obsolète) | Pneumatic tube segment (legacy)=Segment de tuyau pneumatique (obsolète) | ||||||
|  |  | ||||||
| ## vacuum tubes | ## vacuum tubes | ||||||
|  | Radius=Rayon | ||||||
| Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant | Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant | ||||||
|  | Adjustable Vacuuming Tube=Tuyau pneumatique aspirant réglable | ||||||
| Adjustable Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant réglable | Adjustable Vacuuming Pneumatic Tube Segment=Segment de tuyau pneumatique aspirant réglable | ||||||
| Adjustable Vacuuming Pneumatic Tube Segment (@1m)=Segment de tuyau pneumatique aspirant réglable (@1 m) | Adjustable Vacuuming Pneumatic Tube Segment (@1m)=Segment de tuyau pneumatique aspirant réglable (@1 m) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -2,6 +2,10 @@ | |||||||
| # License: CC-by-SA 4.0 | # License: CC-by-SA 4.0 | ||||||
| # Author: pevernow <3450354617@qq.com> | # Author: pevernow <3450354617@qq.com> | ||||||
|  |  | ||||||
|  | ## generic interaction | ||||||
|  | Set= | ||||||
|  | Cancel= | ||||||
|  |  | ||||||
| ## digilines interfacing | ## digilines interfacing | ||||||
| Channel=频道 | Channel=频道 | ||||||
|  |  | ||||||
| @@ -84,11 +88,12 @@ Sorting pneumatic tube=分类管道 | |||||||
|  |  | ||||||
| ## teleport tube | ## teleport tube | ||||||
| Receive=接收 | Receive=接收 | ||||||
| channels are public by default=频道默认为公开 | Channels are public by default=频道默认为公开 | ||||||
| use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道 | Use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道 | ||||||
| use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器 | Use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器 | ||||||
| Teleporting Pneumatic Tube Segment=传送管道 | Teleporting Pneumatic Tube Segment=传送管道 | ||||||
| unconfigured Teleportation Tube=未配置的传送管道 | Teleporting Tube= | ||||||
|  | Unconfigured Teleportation Tube=未配置的传送管道 | ||||||
| Sorry, channel '@1' is reserved for exclusive use by @2=抱歉,频道‘@1’保留供‘@2’专用 | Sorry, channel '@1' is reserved for exclusive use by @2=抱歉,频道‘@1’保留供‘@2’专用 | ||||||
| Sorry, receiving from channel '@1' is reserved for @2=抱歉,从频道'@1'接收的内容已保留给'@2' | Sorry, receiving from channel '@1' is reserved for @2=抱歉,从频道'@1'接收的内容已保留给'@2' | ||||||
| Teleportation Tube @1 on '@2'=传送管'@1'在'@2'上 | Teleportation Tube @1 on '@2'=传送管'@1'在'@2'上 | ||||||
| @@ -100,7 +105,9 @@ Trash Can=垃圾箱 | |||||||
| Pneumatic tube segment (legacy)=普通管道(旧式) | Pneumatic tube segment (legacy)=普通管道(旧式) | ||||||
|  |  | ||||||
| ## vacuum tubes | ## vacuum tubes | ||||||
|  | Radius= | ||||||
| Vacuuming Pneumatic Tube Segment=拾取管道 | Vacuuming Pneumatic Tube Segment=拾取管道 | ||||||
|  | Adjustable Vacuuming Tube= | ||||||
| Adjustable Vacuuming Pneumatic Tube Segment=高级拾取管道 | Adjustable Vacuuming Pneumatic Tube Segment=高级拾取管道 | ||||||
| Adjustable Vacuuming Pneumatic Tube Segment (@1m)=高级拾取管道(@1m) | Adjustable Vacuuming Pneumatic Tube Segment (@1m)=高级拾取管道(@1m) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,6 +3,10 @@ | |||||||
| # License: CC-by-SA 4.0 | # License: CC-by-SA 4.0 | ||||||
| # Author: | # Author: | ||||||
|  |  | ||||||
|  | ## generic interaction | ||||||
|  | Set= | ||||||
|  | Cancel= | ||||||
|  |  | ||||||
| ## digilines interfacing | ## digilines interfacing | ||||||
| Channel= | Channel= | ||||||
|  |  | ||||||
| @@ -86,11 +90,12 @@ Sorting pneumatic tube= | |||||||
|  |  | ||||||
| ## teleport tube | ## teleport tube | ||||||
| Receive= | Receive= | ||||||
| channels are public by default= | Channels are public by default= | ||||||
| use <player>:<channel> for fully private channels= | Use <player>:<channel> for fully private channels= | ||||||
| use <player>;<channel> for private receivers= | Use <player>;<channel> for private receivers= | ||||||
| Teleporting Pneumatic Tube Segment= | Teleporting Pneumatic Tube Segment= | ||||||
| unconfigured Teleportation Tube= | Teleporting Tube= | ||||||
|  | Unconfigured Teleportation Tube= | ||||||
| Sorry, channel '@1' is reserved for exclusive use by @2= | Sorry, channel '@1' is reserved for exclusive use by @2= | ||||||
| Sorry, receiving from channel '@1' is reserved for @2= | Sorry, receiving from channel '@1' is reserved for @2= | ||||||
| Teleportation Tube @1 on '@2'= | Teleportation Tube @1 on '@2'= | ||||||
| @@ -102,7 +107,9 @@ Trash Can= | |||||||
| Pneumatic tube segment (legacy)= | Pneumatic tube segment (legacy)= | ||||||
|  |  | ||||||
| ## vacuum tubes | ## vacuum tubes | ||||||
|  | Radius= | ||||||
| Vacuuming Pneumatic Tube Segment= | Vacuuming Pneumatic Tube Segment= | ||||||
|  | Adjustable Vacuuming Tube= | ||||||
| Adjustable Vacuuming Pneumatic Tube Segment= | Adjustable Vacuuming Pneumatic Tube Segment= | ||||||
| Adjustable Vacuuming Pneumatic Tube Segment (@1m)= | Adjustable Vacuuming Pneumatic Tube Segment (@1m)= | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										120
									
								
								lua_tube.lua
									
									
									
									
									
								
							
							
						
						
									
										120
									
								
								lua_tube.lua
									
									
									
									
									
								
							| @@ -813,82 +813,56 @@ local tiles_base = { | |||||||
| 	"pipeworks_mese_tube_plain_2.png", "pipeworks_mese_tube_plain_1.png", | 	"pipeworks_mese_tube_plain_2.png", "pipeworks_mese_tube_plain_1.png", | ||||||
| 	"pipeworks_mese_tube_plain_6.png", "pipeworks_mese_tube_plain_5.png"} | 	"pipeworks_mese_tube_plain_6.png", "pipeworks_mese_tube_plain_5.png"} | ||||||
|  |  | ||||||
|  | local tiles_on_off = { | ||||||
|  | 	R__0   = "^pipeworks_lua_tube_port_%s.png", | ||||||
|  | 	R_90  = "^(pipeworks_lua_tube_port_%s.png^[transformR90)", | ||||||
|  | 	R180 = "^(pipeworks_lua_tube_port_%s.png^[transformR180)", | ||||||
|  | 	R270 = "^(pipeworks_lua_tube_port_%s.png^[transformR270)" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes | ||||||
|  | 	and "clip" or true | ||||||
|  |  | ||||||
| for red    = 0, 1 do -- 0 = off  1 = on | for red    = 0, 1 do -- 0 = off  1 = on | ||||||
| for blue   = 0, 1 do | for blue   = 0, 1 do | ||||||
| for yellow = 0, 1 do | for yellow = 0, 1 do | ||||||
| for green  = 0, 1 do | for green  = 0, 1 do | ||||||
| for black  = 0, 1 do | for black  = 0, 1 do | ||||||
| for white  = 0, 1 do | for white  = 0, 1 do | ||||||
| 	local cid = tostring(white)..tostring(black)..tostring(green).. | 	local cid = white..black..green..yellow..blue..red | ||||||
| 			tostring(yellow)..tostring(blue)..tostring(red) |  | ||||||
| 	local node_name = BASENAME..cid | 	local node_name = BASENAME..cid | ||||||
|  |  | ||||||
| 	local tiles = table.copy(tiles_base) | 	local tiles = table.copy(tiles_base) | ||||||
| 	if red == 1 then | 	-- Red | ||||||
| 		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_on.png^[transformR90)" | 	tiles[1] = tiles[1]..tiles_on_off.R_90:format(red == 1 and "on" or "off"); | ||||||
| 		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_on.png^[transformR90)" | 	tiles[2] = tiles[2]..tiles_on_off.R_90:format(red == 1 and "on" or "off"); | ||||||
| 		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_on.png^[transformR270)" | 	tiles[5] = tiles[5]..tiles_on_off.R270:format(red == 1 and "on" or "off"); | ||||||
| 		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_on.png^[transformR90)" | 	tiles[6] = tiles[6]..tiles_on_off.R_90:format(red == 1 and "on" or "off"); | ||||||
| 	else | 	-- Blue | ||||||
| 		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_off.png^[transformR90)" | 	tiles[1] = tiles[1]..tiles_on_off.R270:format(blue == 1 and "on" or "off"); | ||||||
| 		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_off.png^[transformR90)" | 	tiles[2] = tiles[2]..tiles_on_off.R270:format(blue == 1 and "on" or "off"); | ||||||
| 		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_off.png^[transformR270)" | 	tiles[5] = tiles[5]..tiles_on_off.R_90:format(blue == 1 and "on" or "off"); | ||||||
| 		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_off.png^[transformR90)" | 	tiles[6] = tiles[6]..tiles_on_off.R270:format(blue == 1 and "on" or "off"); | ||||||
| 	end | 	-- Yellow | ||||||
| 	if blue == 1 then | 	tiles[1] = tiles[1]..tiles_on_off.R180:format(yellow == 1 and "on" or "off"); | ||||||
| 		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_on.png^[transformR270)" | 	tiles[2] = tiles[2]..tiles_on_off.R180:format(yellow == 1 and "on" or "off"); | ||||||
| 		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_on.png^[transformR270)" | 	tiles[5] = tiles[5]..tiles_on_off.R180:format(yellow == 1 and "on" or "off"); | ||||||
| 		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_on.png^[transformR90)" | 	tiles[6] = tiles[6]..tiles_on_off.R180:format(yellow == 1 and "on" or "off"); | ||||||
| 		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_on.png^[transformR270)" | 	-- Green | ||||||
| 	else | 	tiles[3] = tiles[3]..tiles_on_off.R__0:format(green == 1 and "on" or "off"); | ||||||
| 		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_off.png^[transformR270)" | 	tiles[4] = tiles[4]..tiles_on_off.R__0:format(green == 1 and "on" or "off"); | ||||||
| 		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_off.png^[transformR270)" | 	tiles[5] = tiles[5]..tiles_on_off.R__0:format(green == 1 and "on" or "off"); | ||||||
| 		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_off.png^[transformR90)" | 	tiles[6] = tiles[6]..tiles_on_off.R__0:format(green == 1 and "on" or "off"); | ||||||
| 		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_off.png^[transformR270)" | 	-- Black | ||||||
| 	end | 	tiles[1] = tiles[1]..tiles_on_off.R180:format(black == 1 and "on" or "off"); | ||||||
| 	if yellow == 1 then | 	tiles[2] = tiles[2]..tiles_on_off.R__0:format(black == 1 and "on" or "off"); | ||||||
| 		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_on.png^[transformR180)" | 	tiles[3] = tiles[3]..tiles_on_off.R_90:format(black == 1 and "on" or "off"); | ||||||
| 		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_on.png^[transformR180)" | 	tiles[4] = tiles[4]..tiles_on_off.R270:format(black == 1 and "on" or "off"); | ||||||
| 		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_on.png^[transformR180)" | 	-- White | ||||||
| 		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_on.png^[transformR180)" | 	tiles[1] = tiles[1]..tiles_on_off.R__0:format(white == 1 and "on" or "off"); | ||||||
| 	else | 	tiles[2] = tiles[2]..tiles_on_off.R180:format(white == 1 and "on" or "off"); | ||||||
| 		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_off.png^[transformR180)" | 	tiles[3] = tiles[3]..tiles_on_off.R270:format(white == 1 and "on" or "off"); | ||||||
| 		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_off.png^[transformR180)" | 	tiles[4] = tiles[4]..tiles_on_off.R_90:format(white == 1 and "on" or "off"); | ||||||
| 		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_off.png^[transformR180)" |  | ||||||
| 		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_off.png^[transformR180)" |  | ||||||
| 	end |  | ||||||
| 	if green == 1 then |  | ||||||
| 		tiles[3] = tiles[3].."^pipeworks_lua_tube_port_on.png" |  | ||||||
| 		tiles[4] = tiles[4].."^pipeworks_lua_tube_port_on.png" |  | ||||||
| 		tiles[5] = tiles[5].."^pipeworks_lua_tube_port_on.png" |  | ||||||
| 		tiles[6] = tiles[6].."^pipeworks_lua_tube_port_on.png" |  | ||||||
| 	else |  | ||||||
| 		tiles[3] = tiles[3].."^pipeworks_lua_tube_port_off.png" |  | ||||||
| 		tiles[4] = tiles[4].."^pipeworks_lua_tube_port_off.png" |  | ||||||
| 		tiles[5] = tiles[5].."^pipeworks_lua_tube_port_off.png" |  | ||||||
| 		tiles[6] = tiles[6].."^pipeworks_lua_tube_port_off.png" |  | ||||||
| 	end |  | ||||||
| 	if black == 1 then |  | ||||||
| 		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_on.png^[transformR180)" |  | ||||||
| 		tiles[2] = tiles[2].."^pipeworks_lua_tube_port_on.png" |  | ||||||
| 		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_on.png^[transformR90)" |  | ||||||
| 		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_on.png^[transformR270)" |  | ||||||
| 	else |  | ||||||
| 		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_off.png^[transformR180)" |  | ||||||
| 		tiles[2] = tiles[2].."^pipeworks_lua_tube_port_off.png" |  | ||||||
| 		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_off.png^[transformR90)" |  | ||||||
| 		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_off.png^[transformR270)" |  | ||||||
| 	end |  | ||||||
| 	if white == 1 then |  | ||||||
| 		tiles[1] = tiles[1].."^pipeworks_lua_tube_port_on.png" |  | ||||||
| 		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_on.png^[transformR180)" |  | ||||||
| 		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_on.png^[transformR270)" |  | ||||||
| 		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_on.png^[transformR90)" |  | ||||||
| 	else |  | ||||||
| 		tiles[1] = tiles[1].."^pipeworks_lua_tube_port_off.png" |  | ||||||
| 		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_off.png^[transformR180)" |  | ||||||
| 		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_off.png^[transformR270)" |  | ||||||
| 		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_off.png^[transformR90)" |  | ||||||
| 	end |  | ||||||
|  |  | ||||||
| 	local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1} | 	local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1} | ||||||
| 	if red + blue + yellow + green + black + white ~= 0 then | 	if red + blue + yellow + green + black + white ~= 0 then | ||||||
| @@ -933,6 +907,7 @@ for white  = 0, 1 do | |||||||
| 		description = "Lua controlled Tube", | 		description = "Lua controlled Tube", | ||||||
| 		drawtype = "nodebox", | 		drawtype = "nodebox", | ||||||
| 		tiles = tiles, | 		tiles = tiles, | ||||||
|  | 		use_texture_alpha = texture_alpha_mode, | ||||||
| 		paramtype = "light", | 		paramtype = "light", | ||||||
| 		is_ground_content = false, | 		is_ground_content = false, | ||||||
| 		groups = groups, | 		groups = groups, | ||||||
| @@ -969,7 +944,7 @@ for white  = 0, 1 do | |||||||
| 			can_go = function(pos, node, velocity, stack) | 			can_go = function(pos, node, velocity, stack) | ||||||
| 				local src = {name = nil} | 				local src = {name = nil} | ||||||
| 				-- add color of the incoming tube explicitly; referring to rules, in case they change later | 				-- add color of the incoming tube explicitly; referring to rules, in case they change later | ||||||
| 				for color, rule in pairs(rules) do | 				for _, rule in pairs(rules) do | ||||||
| 					if (-velocity.x == rule.x and -velocity.y == rule.y and -velocity.z == rule.z) then | 					if (-velocity.x == rule.x and -velocity.y == rule.y and -velocity.z == rule.z) then | ||||||
| 						src.name = rule.name | 						src.name = rule.name | ||||||
| 						break | 						break | ||||||
| @@ -993,7 +968,7 @@ for white  = 0, 1 do | |||||||
| 		on_blast = function(pos, intensity) | 		on_blast = function(pos, intensity) | ||||||
| 			if not intensity or intensity > 1 + 3^0.5 then | 			if not intensity or intensity > 1 + 3^0.5 then | ||||||
| 				minetest.remove_node(pos) | 				minetest.remove_node(pos) | ||||||
| 				return {string.format("%s_%s", name, dropname)} | 				return | ||||||
| 			end | 			end | ||||||
| 			minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) | 			minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) | ||||||
| 			pipeworks.scan_for_tube_objects(pos) | 			pipeworks.scan_for_tube_objects(pos) | ||||||
| @@ -1006,6 +981,8 @@ end | |||||||
| end | end | ||||||
| end | end | ||||||
|  |  | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = BASENAME.."000000" | ||||||
|  |  | ||||||
| ------------------------------------ | ------------------------------------ | ||||||
| -- Overheated Lua controlled Tube -- | -- Overheated Lua controlled Tube -- | ||||||
| ------------------------------------ | ------------------------------------ | ||||||
| @@ -1039,6 +1016,7 @@ tiles_burnt[4] = tiles_burnt[4].."^(pipeworks_lua_tube_port_burnt.png^[transform | |||||||
| minetest.register_node(BASENAME .. "_burnt", { | minetest.register_node(BASENAME .. "_burnt", { | ||||||
| 	drawtype = "nodebox", | 	drawtype = "nodebox", | ||||||
| 	tiles = tiles_burnt, | 	tiles = tiles_burnt, | ||||||
|  | 	use_texture_alpha = texture_alpha_mode, | ||||||
| 	is_burnt = true, | 	is_burnt = true, | ||||||
| 	paramtype = "light", | 	paramtype = "light", | ||||||
| 	is_ground_content = false, | 	is_ground_content = false, | ||||||
| @@ -1070,7 +1048,7 @@ minetest.register_node(BASENAME .. "_burnt", { | |||||||
| 	on_blast = function(pos, intensity) | 	on_blast = function(pos, intensity) | ||||||
| 		if not intensity or intensity > 1 + 3^0.5 then | 		if not intensity or intensity > 1 + 3^0.5 then | ||||||
| 			minetest.remove_node(pos) | 			minetest.remove_node(pos) | ||||||
| 			return {string.format("%s_%s", name, dropname)} | 			return | ||||||
| 		end | 		end | ||||||
| 		minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) | 		minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) | ||||||
| 		pipeworks.scan_for_tube_objects(pos) | 		pipeworks.scan_for_tube_objects(pos) | ||||||
|   | |||||||
| @@ -9,16 +9,16 @@ local filename = minetest.get_worldpath().."/luaentities" | |||||||
| local function read_file() | local function read_file() | ||||||
| 	local f = io.open(filename, "r") | 	local f = io.open(filename, "r") | ||||||
| 	if f == nil then return {} end | 	if f == nil then return {} end | ||||||
|     	local t = f:read("*all") | 	local t = f:read("*all") | ||||||
|     	f:close() | 	f:close() | ||||||
| 	if t == "" or t == nil then return {} end | 	if t == "" or t == nil then return {} end | ||||||
| 	return minetest.deserialize(t) or {} | 	return minetest.deserialize(t) or {} | ||||||
| end | end | ||||||
|  |  | ||||||
| local function write_file(tbl) | local function write_file(tbl) | ||||||
| 	local f = io.open(filename, "w") | 	local f = io.open(filename, "w") | ||||||
|     	f:write(minetest.serialize(tbl)) | 	f:write(minetest.serialize(tbl)) | ||||||
|     	f:close() | 	f:close() | ||||||
| end | end | ||||||
|  |  | ||||||
| local function read_entities() | local function read_entities() | ||||||
| @@ -318,19 +318,20 @@ end | |||||||
| function luaentity.get_objects_inside_radius(pos, radius) | function luaentity.get_objects_inside_radius(pos, radius) | ||||||
| 	local objects = {} | 	local objects = {} | ||||||
| 	local index = 1 | 	local index = 1 | ||||||
| 	for id, entity in pairs(luaentity.entities) do | 	for _, entity in pairs(luaentity.entities) do | ||||||
| 		if vector.distance(pos, entity:get_pos()) <= radius then | 		if vector.distance(pos, entity:get_pos()) <= radius then | ||||||
| 			objects[index] = entity | 			objects[index] = entity | ||||||
| 			index = index + 1 | 			index = index + 1 | ||||||
| 		end | 		end | ||||||
| 	end | 	end | ||||||
|  | 	return objects | ||||||
| end | end | ||||||
|  |  | ||||||
| local move_entities_globalstep_part2 = function(dtime) | local move_entities_globalstep_part2 = function(dtime) | ||||||
| 	if not luaentity.entities then | 	if not luaentity.entities then | ||||||
| 		luaentity.entities = read_entities() | 		luaentity.entities = read_entities() | ||||||
| 	end | 	end | ||||||
| 	for id, entity in pairs(luaentity.entities) do | 	for _, entity in pairs(luaentity.entities) do | ||||||
| 		local master = entity._attached_entities_master | 		local master = entity._attached_entities_master | ||||||
| 		local master_def = master and entity._attached_entities[master] | 		local master_def = master and entity._attached_entities[master] | ||||||
| 		local master_entity = master_def and master_def.entity | 		local master_entity = master_def and master_def.entity | ||||||
|   | |||||||
							
								
								
									
										2
									
								
								mod.conf
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								mod.conf
									
									
									
									
									
								
							| @@ -1,5 +1,5 @@ | |||||||
| name = pipeworks | name = pipeworks | ||||||
| description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them. | description = This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them. | ||||||
| depends = default, basic_materials, screwdriver | depends = default, basic_materials, screwdriver | ||||||
| optional_depends = mesecons, mesecons_mvps, digilines, signs_lib | optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory | ||||||
| min_minetest_version = 5.2.0 | min_minetest_version = 5.2.0 | ||||||
|   | |||||||
| @@ -11,7 +11,7 @@ local new_flow_logic_register = pipeworks.flowables.register | |||||||
| local polys = "" | local polys = "" | ||||||
| if pipeworks.enable_lowpoly then polys = "_lowpoly" end | if pipeworks.enable_lowpoly then polys = "_lowpoly" end | ||||||
|  |  | ||||||
| local vti = {4, 3, 2, 1, 6, 5} | --~ local vti = {4, 3, 2, 1, 6, 5} | ||||||
| local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}} | local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}} | ||||||
| for index, connects in ipairs(cconnects) do | for index, connects in ipairs(cconnects) do | ||||||
| 	local outsel = {} | 	local outsel = {} | ||||||
| @@ -30,10 +30,12 @@ for index, connects in ipairs(cconnects) do | |||||||
| 		table.insert(outsel, pipeworks.pipe_selectboxes[v]) | 		table.insert(outsel, pipeworks.pipe_selectboxes[v]) | ||||||
| 	end | 	end | ||||||
|  |  | ||||||
|  | 	--[[ | ||||||
| 	if #connects == 1 then | 	if #connects == 1 then | ||||||
| 		local v = connects[1] | 		local v = connects[1] | ||||||
| 		v = v-1 + 2*(v%2) -- Opposite side | 		v = v-1 + 2*(v%2) -- Opposite side | ||||||
| 	end | 	end | ||||||
|  | 	--]] | ||||||
|  |  | ||||||
| 	local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1} | 	local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1} | ||||||
| 	local pipedesc = S("Pipe Segment").." "..dump(connects) | 	local pipedesc = S("Pipe Segment").." "..dump(connects) | ||||||
| @@ -131,7 +133,7 @@ for index, connects in ipairs(cconnects) do | |||||||
| 	new_flow_logic_register.simple(emptypipe) | 	new_flow_logic_register.simple(emptypipe) | ||||||
| 	new_flow_logic_register.simple(fullpipe) | 	new_flow_logic_register.simple(fullpipe) | ||||||
| end | end | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:pipe_1_empty" | ||||||
|  |  | ||||||
|  |  | ||||||
| if REGISTER_COMPATIBILITY then | if REGISTER_COMPATIBILITY then | ||||||
|   | |||||||
| @@ -29,7 +29,7 @@ end | |||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..tostring(vec.y)..sep..tostring(vec.z)..")" end | --~ local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..tostring(vec.y)..sep..tostring(vec.z)..")" end | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -39,7 +39,7 @@ local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep.. | |||||||
| local check_for_liquids_v2 = function(pos, limit) | local check_for_liquids_v2 = function(pos, limit) | ||||||
| 	local coords = make_coords_offsets(pos, false) | 	local coords = make_coords_offsets(pos, false) | ||||||
| 	local total = 0 | 	local total = 0 | ||||||
| 	for index, tpos in ipairs(coords) do | 	for _, tpos in ipairs(coords) do | ||||||
| 		if total >= limit then break end | 		if total >= limit then break end | ||||||
| 		local name = minetest.get_node(tpos).name | 		local name = minetest.get_node(tpos).name | ||||||
| 		if name == "default:water_source" then | 		if name == "default:water_source" then | ||||||
| @@ -69,11 +69,13 @@ end | |||||||
|  |  | ||||||
|  |  | ||||||
| -- logging is unreliable when something is crashing... | -- logging is unreliable when something is crashing... | ||||||
|  | --[[ | ||||||
| local nilexplode = function(caller, label, value) | local nilexplode = function(caller, label, value) | ||||||
| 	if value == nil then | 	if value == nil then | ||||||
| 		error(caller..": "..label.." was nil") | 		error(caller..": "..label.." was nil") | ||||||
| 	end | 	end | ||||||
| end | end | ||||||
|  | --]] | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -151,7 +153,7 @@ local get_neighbour_positions = function(pos, node) | |||||||
|  |  | ||||||
| 	-- then, check each possible neighbour to see if they can be reached from this node. | 	-- then, check each possible neighbour to see if they can be reached from this node. | ||||||
| 	local connections = {} | 	local connections = {} | ||||||
| 	for index, offset in ipairs(candidates) do | 	for _, offset in ipairs(candidates) do | ||||||
| 		local npos = vector.add(pos, offset) | 		local npos = vector.add(pos, offset) | ||||||
| 		local neighbour = minetest.get_node(npos) | 		local neighbour = minetest.get_node(npos) | ||||||
| 		local nodename = neighbour.name | 		local nodename = neighbour.name | ||||||
| @@ -185,13 +187,12 @@ flowlogic.balance_pressure = function(pos, node, currentpressure) | |||||||
| 	-- local dname = "flowlogic.balance_pressure()@"..formatvec(pos).." " | 	-- local dname = "flowlogic.balance_pressure()@"..formatvec(pos).." " | ||||||
| 	-- check the pressure of all nearby flowable nodes, and average it out. | 	-- check the pressure of all nearby flowable nodes, and average it out. | ||||||
|  |  | ||||||
| 	-- pressure handles to average over |  | ||||||
| 	local connections = {} |  | ||||||
| 	-- unconditionally include self in nodes to average over. | 	-- unconditionally include self in nodes to average over. | ||||||
| 	-- result of averaging will be returned as new pressure for main flow logic callback | 	-- result of averaging will be returned as new pressure for main flow logic callback | ||||||
| 	local totalv = currentpressure | 	local totalv = currentpressure | ||||||
| 	local totalc = 1 | 	local totalc = 1 | ||||||
|  |  | ||||||
|  | 	-- pressure handles to average over | ||||||
| 	local connections = get_neighbour_positions(pos, node) | 	local connections = get_neighbour_positions(pos, node) | ||||||
|  |  | ||||||
| 	-- for each neighbour, add neighbour's pressure to the total to balance out | 	-- for each neighbour, add neighbour's pressure to the total to balance out | ||||||
| @@ -287,7 +288,7 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd | |||||||
| 	local upper = outputdef.upper | 	local upper = outputdef.upper | ||||||
| 	local lower = outputdef.lower | 	local lower = outputdef.lower | ||||||
| 	local result = currentpressure | 	local result = currentpressure | ||||||
| 	local threshold = nil | 	local threshold | ||||||
| 	if finitemode then threshold = lower else threshold = upper end | 	if finitemode then threshold = lower else threshold = upper end | ||||||
| 	if currentpressure > threshold then | 	if currentpressure > threshold then | ||||||
| 		local takenpressure = outputdef.outputfn(pos, node, currentpressure, finitemode) | 		local takenpressure = outputdef.outputfn(pos, node, currentpressure, finitemode) | ||||||
| @@ -316,7 +317,7 @@ flowlogic.run_transition = function(node, currentpressure) | |||||||
| 		local nodename_prev = simplesetdef[1].nodename | 		local nodename_prev = simplesetdef[1].nodename | ||||||
| 		local result_nodename = node.name | 		local result_nodename = node.name | ||||||
|  |  | ||||||
| 		for index, element in ipairs(simplesetdef) do | 		for _, element in ipairs(simplesetdef) do | ||||||
| 			-- find the highest element that is below the current pressure. | 			-- find the highest element that is below the current pressure. | ||||||
| 			local threshold = element.threshold | 			local threshold = element.threshold | ||||||
| 			if threshold > currentpressure then | 			if threshold > currentpressure then | ||||||
| @@ -338,7 +339,9 @@ flowlogic.run_transition = function(node, currentpressure) | |||||||
| 	end | 	end | ||||||
|  |  | ||||||
| 	if not found then | 	if not found then | ||||||
| 		pipeworks.logger("flowlogic.run_transition() BUG no transition definitions found! nodename="..nodename.." currentpressure="..tostring(currentpressure)) | 		pipeworks.logger("flowlogic.run_transition() BUG no transition " .. | ||||||
|  | 			"definitions found! node.name=" .. node.name .. | ||||||
|  | 			" currentpressure=" .. tostring(currentpressure)) | ||||||
| 	end | 	end | ||||||
|  |  | ||||||
| 	return result | 	return result | ||||||
|   | |||||||
| @@ -26,8 +26,8 @@ local insertbase = function(nodename) | |||||||
| end | end | ||||||
|  |  | ||||||
| local regwarning = function(kind, nodename) | local regwarning = function(kind, nodename) | ||||||
| 	local tail = "" | 	--~ local tail = "" | ||||||
| 	if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end | 	--~ if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end | ||||||
| 	--pipeworks.logger(kind.." flow logic registry requested for "..nodename..tail) | 	--pipeworks.logger(kind.." flow logic registry requested for "..nodename..tail) | ||||||
| end | end | ||||||
|  |  | ||||||
| @@ -106,7 +106,7 @@ register.directional_horizonal_rotate = function(nodename, doubleended) | |||||||
| 	end | 	end | ||||||
| 	local directionfn = function(node, direction) | 	local directionfn = function(node, direction) | ||||||
| 		local result = false | 		local result = false | ||||||
| 		for index, endvec in ipairs(getends(node)) do | 		for _, endvec in ipairs(getends(node)) do | ||||||
| 			if vector.equals(direction, endvec) then result = true end | 			if vector.equals(direction, endvec) then result = true end | ||||||
| 		end | 		end | ||||||
| 		return result | 		return result | ||||||
|   | |||||||
| @@ -10,6 +10,35 @@ minetest.register_craft( { | |||||||
| 	}, | 	}, | ||||||
| }) | }) | ||||||
|  |  | ||||||
|  | -- The hammers that can be used to break/repair tubes | ||||||
|  | local allowed_hammers = { | ||||||
|  | 	"anvil:hammer", | ||||||
|  | 	"cottages:hammer", | ||||||
|  | 	"glooptest:hammer_steel", | ||||||
|  | 	"glooptest:hammer_bronze", | ||||||
|  | 	"glooptest:hammer_diamond", | ||||||
|  | 	"glooptest:hammer_mese", | ||||||
|  | 	"glooptest:hammer_alatro", | ||||||
|  | 	"glooptest:hammer_arol" | ||||||
|  | } | ||||||
|  |  | ||||||
|  | -- Convert the above list to a format that's easier to look up | ||||||
|  | for _,hammer in ipairs(allowed_hammers) do | ||||||
|  | 	allowed_hammers[hammer] = true | ||||||
|  | end | ||||||
|  |  | ||||||
|  | -- Check if the player is holding a suitable hammer or not - if they are, apply wear to it | ||||||
|  | function pipeworks.check_and_wear_hammer(player) | ||||||
|  | 	local itemstack = player:get_wielded_item() | ||||||
|  | 	local wieldname = itemstack:get_name() | ||||||
|  | 	if allowed_hammers[wieldname] then | ||||||
|  | 		itemstack:add_wear(1000) | ||||||
|  | 		player:set_wielded_item(itemstack) | ||||||
|  | 		return true | ||||||
|  | 	end | ||||||
|  | 	return false | ||||||
|  | end | ||||||
|  |  | ||||||
| local nodecolor = 0xffff3030 | local nodecolor = 0xffff3030 | ||||||
|  |  | ||||||
| pipeworks.register_tube("pipeworks:broken_tube", { | pipeworks.register_tube("pipeworks:broken_tube", { | ||||||
| @@ -36,29 +65,27 @@ pipeworks.register_tube("pipeworks:broken_tube", { | |||||||
| 			local wieldname = itemstack:get_name() | 			local wieldname = itemstack:get_name() | ||||||
| 			local playername = puncher:get_player_name() | 			local playername = puncher:get_player_name() | ||||||
| 			local log_msg = playername.." struck a broken tube at "..minetest.pos_to_string(pos).."\n" | 			local log_msg = playername.." struck a broken tube at "..minetest.pos_to_string(pos).."\n" | ||||||
| 			if   wieldname == "anvil:hammer" | 			local meta = minetest.get_meta(pos) | ||||||
| 			  or wieldname == "cottages:hammer" | 			local was_node = minetest.deserialize(meta:get_string("the_tube_was")) | ||||||
| 			  or wieldname == "glooptest:hammer_steel" | 			if not was_node then | ||||||
| 			  or wieldname == "glooptest:hammer_bronze" | 				pipeworks.logger(log_msg.."            but it can't be repaired.") | ||||||
| 			  or wieldname == "glooptest:hammer_diamond" | 				return | ||||||
| 			  or wieldname == "glooptest:hammer_mese" |  | ||||||
| 			  or wieldname == "glooptest:hammer_alatro" |  | ||||||
| 			  or wieldname == "glooptest:hammer_arol" then |  | ||||||
| 				local meta = minetest.get_meta(pos) |  | ||||||
| 				local was_node = minetest.deserialize(meta:get_string("the_tube_was")) |  | ||||||
| 				if was_node and was_node ~= "" then |  | ||||||
| 					pipeworks.logger(log_msg.."            with "..wieldname.." to repair it.") |  | ||||||
| 					minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 }) |  | ||||||
| 					pipeworks.scan_for_tube_objects(pos) |  | ||||||
| 					itemstack:add_wear(1000) |  | ||||||
| 					puncher:set_wielded_item(itemstack) |  | ||||||
| 					return itemstack |  | ||||||
| 				else |  | ||||||
| 					pipeworks.logger(log_msg.."            but it can't be repaired.") |  | ||||||
| 				end |  | ||||||
| 			else |  | ||||||
| 				pipeworks.logger(log_msg.."            with "..wieldname.." but that tool is too weak.") |  | ||||||
| 			end | 			end | ||||||
|  | 			if not pipeworks.check_and_wear_hammer(puncher) then | ||||||
|  | 				if wieldname == "" then | ||||||
|  | 					pipeworks.logger(log_msg.."            by hand. It's not very effective.") | ||||||
|  | 					if minetest.settings:get_bool("enable_damage") then | ||||||
|  | 						minetest.chat_send_player(playername,S("Broken tubes may be a bit sharp. Perhaps try with a hammer?")) | ||||||
|  | 						puncher:set_hp(puncher:get_hp()-1) | ||||||
|  | 					end | ||||||
|  | 				else | ||||||
|  | 					pipeworks.logger(log_msg.."            with "..wieldname.." but that tool is too weak.") | ||||||
|  | 				end | ||||||
|  | 				return | ||||||
|  | 			end | ||||||
|  | 			pipeworks.logger(log_msg.."            with "..wieldname.." to repair it.") | ||||||
|  | 			minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 }) | ||||||
|  | 			pipeworks.scan_for_tube_objects(pos) | ||||||
| 		end | 		end | ||||||
| 	} | 	} | ||||||
| }) | }) | ||||||
| @@ -165,6 +192,7 @@ if pipeworks.enable_one_way_tube then | |||||||
| 		check_for_pole = pipeworks.check_for_vert_tube, | 		check_for_pole = pipeworks.check_for_vert_tube, | ||||||
| 		check_for_horiz_pole = pipeworks.check_for_horiz_tube | 		check_for_horiz_pole = pipeworks.check_for_horiz_tube | ||||||
| 	}) | 	}) | ||||||
|  | 	pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:one_way_tube" | ||||||
| 	minetest.register_craft({ | 	minetest.register_craft({ | ||||||
| 		output = "pipeworks:one_way_tube 2", | 		output = "pipeworks:one_way_tube 2", | ||||||
| 		recipe = { | 		recipe = { | ||||||
|   | |||||||
| @@ -1,4 +1,16 @@ | |||||||
| local S = minetest.get_translator("pipeworks") | local S = minetest.get_translator("pipeworks") | ||||||
|  |  | ||||||
|  | -- the minetest.after() calls below can sometimes trigger after a tube | ||||||
|  | -- breaks, at which point item_exit() is no longer valid, so we have to make | ||||||
|  | -- sure that there even IS a callback to run, first. | ||||||
|  |  | ||||||
|  | local function after_break(pos) | ||||||
|  | 	local name = minetest.get_node(pos).name | ||||||
|  | 	if minetest.registered_nodes[name].item_exit then | ||||||
|  | 		minetest.registered_nodes[name].item_exit(pos) | ||||||
|  | 	end | ||||||
|  | end | ||||||
|  |  | ||||||
| if pipeworks.enable_detector_tube then | if pipeworks.enable_detector_tube then | ||||||
| 	local detector_tube_step = 5 * tonumber(minetest.settings:get("dedicated_server_step")) | 	local detector_tube_step = 5 * tonumber(minetest.settings:get("dedicated_server_step")) | ||||||
| 	pipeworks.register_tube("pipeworks:detector_tube_on", { | 	pipeworks.register_tube("pipeworks:detector_tube_on", { | ||||||
| @@ -8,11 +20,10 @@ if pipeworks.enable_detector_tube then | |||||||
| 			node_def = { | 			node_def = { | ||||||
| 				tube = {can_go = function(pos, node, velocity, stack) | 				tube = {can_go = function(pos, node, velocity, stack) | ||||||
| 						 local meta = minetest.get_meta(pos) | 						 local meta = minetest.get_meta(pos) | ||||||
| 						 local name = minetest.get_node(pos).name |  | ||||||
| 						 local nitems = meta:get_int("nitems")+1 | 						 local nitems = meta:get_int("nitems")+1 | ||||||
| 						 meta:set_int("nitems", nitems) | 						 meta:set_int("nitems", nitems) | ||||||
| 						 local saved_pos = vector.new(pos) | 						 local saved_pos = vector.new(pos) | ||||||
| 						 minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos) | 						 minetest.after(detector_tube_step, after_break, saved_pos) | ||||||
| 						 return pipeworks.notvel(pipeworks.meseadjlist,velocity) | 						 return pipeworks.notvel(pipeworks.meseadjlist,velocity) | ||||||
| 					end}, | 					end}, | ||||||
| 				groups = {mesecon = 2, not_in_creative_inventory = 1}, | 				groups = {mesecon = 2, not_in_creative_inventory = 1}, | ||||||
| @@ -34,9 +45,7 @@ if pipeworks.enable_detector_tube then | |||||||
| 				on_construct = function(pos) | 				on_construct = function(pos) | ||||||
| 					 local meta = minetest.get_meta(pos) | 					 local meta = minetest.get_meta(pos) | ||||||
| 					 meta:set_int("nitems", 1) | 					 meta:set_int("nitems", 1) | ||||||
| 					 local name = minetest.get_node(pos).name | 					 minetest.after(detector_tube_step, after_break, pos) | ||||||
| 					 local saved_pos = vector.new(pos) |  | ||||||
| 					 minetest.after(detector_tube_step, minetest.registered_nodes[name].item_exit, saved_pos) |  | ||||||
| 				end, | 				end, | ||||||
| 			}, | 			}, | ||||||
| 	}) | 	}) | ||||||
| @@ -87,13 +96,20 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then | |||||||
| 				on_construct = function(pos) | 				on_construct = function(pos) | ||||||
| 					local meta = minetest.get_meta(pos) | 					local meta = minetest.get_meta(pos) | ||||||
| 					meta:set_string("formspec", | 					meta:set_string("formspec", | ||||||
| 						"size[8.6,2.2]".. | 						"size[8.5,2.2]".. | ||||||
| 						"field[0.6,0.6;8,1;channel;"..S("Channel")..";${channel}]".. | 						"image[0.2,0;1,1;pipeworks_digiline_detector_tube_inv.png]".. | ||||||
| 						"image[0.3,1.3;1,1;pipeworks_digiline_detector_tube_inv.png]".. | 						"label[1.2,0.2;"..S("Digiline Detecting Tube").."]".. | ||||||
| 						"label[1.6,1.2;"..S("Digiline Detecting Tube").."]" | 						"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]".. | ||||||
|  | 						"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]".. | ||||||
|  | 						"button_exit[6.3,1.3;2,1;close;"..S("Close").."]" | ||||||
| 					) | 					) | ||||||
| 				end, | 				end, | ||||||
| 				on_receive_fields = function(pos, formname, fields, sender) | 				on_receive_fields = function(pos, formname, fields, sender) | ||||||
|  | 					if (fields.quit and not fields.key_enter_field) | ||||||
|  | 					or (fields.key_enter_field ~= "channel" and not fields.set_channel) | ||||||
|  | 					or not pipeworks.may_configure(pos, sender) then | ||||||
|  | 						return | ||||||
|  | 					end | ||||||
| 					if fields.channel then | 					if fields.channel then | ||||||
| 						minetest.get_meta(pos):set_string("channel", fields.channel) | 						minetest.get_meta(pos):set_string("channel", fields.channel) | ||||||
| 					end | 					end | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ end | |||||||
| local function migrate_tube_db() | local function migrate_tube_db() | ||||||
| 		local tmp_db = {} | 		local tmp_db = {} | ||||||
| 		tp_tube_db.version = nil | 		tp_tube_db.version = nil | ||||||
| 		for key, val in pairs(tp_tube_db) do | 		for _, val in pairs(tp_tube_db) do | ||||||
| 			if(val.channel ~= "") then -- skip unconfigured tubes | 			if(val.channel ~= "") then -- skip unconfigured tubes | ||||||
| 				tmp_db[hash(val)] = val | 				tmp_db[hash(val)] = val | ||||||
| 			end | 			end | ||||||
| @@ -127,16 +127,22 @@ end | |||||||
| local function update_meta(meta, can_receive) | local function update_meta(meta, can_receive) | ||||||
| 	meta:set_int("can_receive", can_receive and 1 or 0) | 	meta:set_int("can_receive", can_receive and 1 or 0) | ||||||
| 	local cr_state = can_receive and "on" or "off" | 	local cr_state = can_receive and "on" or "off" | ||||||
| 	meta:set_string("formspec","size[8.6,2.2]".. | 	local itext = S("Channels are public by default").."\n".. | ||||||
| 			"field[0.6,0.6;7,1;channel;"..S("Channel")..";${channel}]".. | 		S("Use <player>:<channel> for fully private channels").."\n".. | ||||||
| 			"label[7.3,0;"..S("Receive").."]".. | 		S("Use <player>\\;<channel> for private receivers") | ||||||
| 			"image_button[7.3,0.3;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]".. |  | ||||||
| 			"image[0.3,1.3;1,1;pipeworks_teleport_tube_inv.png]".. | 	meta:set_string("formspec", | ||||||
| 			"label[1.6,1.2;"..S("channels are public by default").."]" .. | 		"size[8.5,3.5]".. | ||||||
| 			"label[1.6,1.5;"..S("use <player>:<channel> for fully private channels").."]" .. | 		"image[0.2,o;1,1;pipeworks_teleport_tube_inv.png]".. | ||||||
| 			"label[1.6,1.8;"..S("use <player>\\;<channel> for private receivers").."]" .. | 		"label[1.2,0.2;"..S("Teleporting Tube").."]".. | ||||||
| 			default.gui_bg.. | 		"field[0.5,1.6;4.6,1;channel;"..S("Channel")..";${channel}]".. | ||||||
| 			default.gui_bg_img) | 		"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]".. | ||||||
|  | 		"label[7.0,0;"..S("Receive").."]".. | ||||||
|  | 		"image_button[7.0,0.5;1,0.6;pipeworks_button_" .. cr_state .. ".png;cr" .. (can_receive and 0 or 1) .. ";;;false;pipeworks_button_interm.png]".. | ||||||
|  | 		"button_exit[6.3,1.3;2,1;close;"..S("Close").."]".. | ||||||
|  | 		"label[0.2,2.3;"..itext.."]".. | ||||||
|  | 		default.gui_bg.. | ||||||
|  | 		default.gui_bg_img) | ||||||
| end | end | ||||||
|  |  | ||||||
| pipeworks.register_tube("pipeworks:teleport_tube", { | pipeworks.register_tube("pipeworks:teleport_tube", { | ||||||
| @@ -170,10 +176,11 @@ pipeworks.register_tube("pipeworks:teleport_tube", { | |||||||
| 		on_construct = function(pos) | 		on_construct = function(pos) | ||||||
| 			local meta = minetest.get_meta(pos) | 			local meta = minetest.get_meta(pos) | ||||||
| 			update_meta(meta, true) | 			update_meta(meta, true) | ||||||
| 			meta:set_string("infotext", S("unconfigured Teleportation Tube")) | 			meta:set_string("infotext", S("Unconfigured Teleportation Tube")) | ||||||
| 		end, | 		end, | ||||||
| 		on_receive_fields = function(pos,formname,fields,sender) | 		on_receive_fields = function(pos,formname,fields,sender) | ||||||
| 			if not fields.channel -- ignore escaping or clientside manipulation of the form | 			if not fields.channel -- ignore escaping or clientside manipulation of the form | ||||||
|  | 			or (fields.quit and not fields.key_enter_field) | ||||||
| 			or not pipeworks.may_configure(pos, sender) then | 			or not pipeworks.may_configure(pos, sender) then | ||||||
| 				return | 				return | ||||||
| 			end | 			end | ||||||
| @@ -207,7 +214,7 @@ pipeworks.register_tube("pipeworks:teleport_tube", { | |||||||
|  |  | ||||||
| 			-- was the channel changed? | 			-- was the channel changed? | ||||||
| 			local channel = meta:get_string("channel") | 			local channel = meta:get_string("channel") | ||||||
| 			if new_channel ~= channel then | 			if new_channel ~= channel and (fields.key_enter_field == "channel" or fields.set_channel) then | ||||||
| 				channel = new_channel | 				channel = new_channel | ||||||
| 				meta:set_string("channel", channel) | 				meta:set_string("channel", channel) | ||||||
| 				dirty = true | 				dirty = true | ||||||
| @@ -233,7 +240,7 @@ pipeworks.register_tube("pipeworks:teleport_tube", { | |||||||
| 				else | 				else | ||||||
| 					-- remove empty channel tubes, to not have to search through them | 					-- remove empty channel tubes, to not have to search through them | ||||||
| 					remove_tube(pos) | 					remove_tube(pos) | ||||||
| 					meta:set_string("infotext", S("unconfigured Teleportation Tube")) | 					meta:set_string("infotext", S("Unconfigured Teleportation Tube")) | ||||||
| 				end | 				end | ||||||
| 			end | 			end | ||||||
| 		end, | 		end, | ||||||
|   | |||||||
| @@ -40,6 +40,7 @@ minetest.register_node("pipeworks:trashcan", { | |||||||
| 		minetest.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack("")) | 		minetest.get_meta(pos):get_inventory():set_stack(listname, index, ItemStack("")) | ||||||
| 	end, | 	end, | ||||||
| }) | }) | ||||||
|  | pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:trashcan" | ||||||
|  |  | ||||||
| minetest.register_craft({ | minetest.register_craft({ | ||||||
| 	output = "pipeworks:trashcan", | 	output = "pipeworks:trashcan", | ||||||
|   | |||||||
| @@ -26,6 +26,11 @@ local texture_mt = { | |||||||
| 	end | 	end | ||||||
| } | } | ||||||
|  |  | ||||||
|  | -- This will remove any semi-transparent pixels | ||||||
|  | -- because that is still buggy in Minetest, force this as default | ||||||
|  | local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes | ||||||
|  | 	and "clip" or true | ||||||
|  |  | ||||||
| local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style) | local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, ends, short, inv, special, connects, style) | ||||||
| 	noctrs = noctrs or default_noctrs | 	noctrs = noctrs or default_noctrs | ||||||
| 	setmetatable(noctrs, texture_mt) | 	setmetatable(noctrs, texture_mt) | ||||||
| @@ -82,6 +87,7 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e | |||||||
| 		description = tubedesc, | 		description = tubedesc, | ||||||
| 		drawtype = "nodebox", | 		drawtype = "nodebox", | ||||||
| 		tiles = outimgs, | 		tiles = outimgs, | ||||||
|  | 		use_texture_alpha = texture_alpha_mode, | ||||||
| 		sunlight_propagates = true, | 		sunlight_propagates = true, | ||||||
| 		inventory_image = iimg, | 		inventory_image = iimg, | ||||||
| 		wield_image = iimg, | 		wield_image = iimg, | ||||||
| @@ -107,6 +113,18 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e | |||||||
| 			connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}, | 			connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}, | ||||||
| 			priority = 50 | 			priority = 50 | ||||||
| 		}, | 		}, | ||||||
|  | 		on_punch = function(pos, node, player, pointed) | ||||||
|  | 			local playername = player:get_player_name() | ||||||
|  | 			if minetest.is_protected(pos, playername) and not minetest.check_player_privs(playername, {protection_bypass=true}) then | ||||||
|  | 				return minetest.node_punch(pos, node, player, pointed) | ||||||
|  | 			end | ||||||
|  | 			if pipeworks.check_and_wear_hammer(player) then | ||||||
|  | 				local wieldname = player:get_wielded_item():get_name() | ||||||
|  | 				pipeworks.logger(string.format("%s struck a tube at %s with %s to break it.", playername, minetest.pos_to_string(pos), wieldname)) | ||||||
|  | 				pipeworks.break_tube(pos) | ||||||
|  | 			end | ||||||
|  | 			return minetest.node_punch(pos, node, player, pointed) | ||||||
|  | 		end, | ||||||
| 		after_place_node = pipeworks.after_place, | 		after_place_node = pipeworks.after_place, | ||||||
| 		after_dig_node = pipeworks.after_dig, | 		after_dig_node = pipeworks.after_dig, | ||||||
| 		on_rotate = false, | 		on_rotate = false, | ||||||
| @@ -182,6 +200,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, | |||||||
| 		end | 		end | ||||||
| 		end | 		end | ||||||
| 		end | 		end | ||||||
|  | 		pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = name.."_000000" | ||||||
| 	else | 	else | ||||||
| 		-- 6d tubes: uses only 10 nodes instead of 64, but the textures must be rotated | 		-- 6d tubes: uses only 10 nodes instead of 64, but the textures must be rotated | ||||||
| 		local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}} | 		local cconnects = {{}, {1}, {1, 2}, {1, 3}, {1, 3, 5}, {1, 2, 3}, {1, 2, 3, 5}, {1, 2, 3, 4}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5, 6}} | ||||||
| @@ -204,6 +223,7 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv, | |||||||
| 				tube = {connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}}, | 				tube = {connect_sides = {front = 1, back = 1, left = 1, right = 1, top = 1, bottom = 1}}, | ||||||
| 				drop = name.."_1", | 				drop = name.."_1", | ||||||
| 			}) | 			}) | ||||||
|  | 			pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = name.."_1" | ||||||
| 			table.insert(tubenodes, cname) | 			table.insert(tubenodes, cname) | ||||||
| 			for xm = 0, 1 do | 			for xm = 0, 1 do | ||||||
| 			for xp = 0, 1 do | 			for xp = 0, 1 do | ||||||
|   | |||||||
| @@ -40,22 +40,31 @@ if pipeworks.enable_mese_sand_tube then | |||||||
| 				on_construct = function(pos) | 				on_construct = function(pos) | ||||||
| 					local meta = minetest.get_meta(pos) | 					local meta = minetest.get_meta(pos) | ||||||
| 					meta:set_int("dist", 0) | 					meta:set_int("dist", 0) | ||||||
| 					meta:set_string("formspec", "size[2.1,0.8]".. | 					meta:set_string("formspec", | ||||||
| 							"image[0,0;1,1;pipeworks_mese_sand_tube_inv.png]".. | 						"size[6.0,2.2]".. | ||||||
| 							"field[1.3,0.4;1,1;dist;radius;${dist}]".. | 						"image[0.2,0;1,1;pipeworks_mese_sand_tube_inv.png]".. | ||||||
| 							default.gui_bg.. | 						"label[1.2,0.2;"..S("Adjustable Vacuuming Tube").."]".. | ||||||
| 							default.gui_bg_img) | 						"field[0.5,1.6;2.1,1;dist;"..S("Radius")..";${dist}]".. | ||||||
|  | 						"button[2.3,1.3;1.5,1;set_dist;"..S("Set").."]".. | ||||||
|  | 						"button_exit[3.8,1.3;2,1;close;"..S("Close").."]".. | ||||||
|  | 						default.gui_bg.. | ||||||
|  | 						default.gui_bg_img) | ||||||
| 					meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment")) | 					meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment")) | ||||||
| 				end, | 				end, | ||||||
| 				on_receive_fields = function(pos,formname,fields,sender) | 				on_receive_fields = function(pos,formname,fields,sender) | ||||||
| 					if not pipeworks.may_configure(pos, sender) then return end | 					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 | ||||||
|  |  | ||||||
| 					local meta = minetest.get_meta(pos) | 					local meta = minetest.get_meta(pos) | ||||||
| 					local dist = tonumber(fields.dist) | 					local dist = tonumber(fields.dist) | ||||||
| 					if dist then | 					if dist then | ||||||
| 						dist = math.max(0, dist) | 						dist = math.max(0, dist) | ||||||
| 						dist = math.min(8, dist) | 						dist = math.min(8, dist) | ||||||
| 						meta:set_int("dist", dist) | 						meta:set_int("dist", dist) | ||||||
| 						meta:set_string("infotext", (S("Adjustable Vacuuming Pneumatic Tube Segment (@1m)", dist))) | 						meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment (@1m)", dist)) | ||||||
| 					end | 					end | ||||||
| 				end, | 				end, | ||||||
| 			}, | 			}, | ||||||
|   | |||||||
							
								
								
									
										11
									
								
								wielder.lua
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								wielder.lua
									
									
									
									
									
								
							| @@ -1,17 +1,13 @@ | |||||||
| local S = minetest.get_translator("pipeworks") | local S = minetest.get_translator("pipeworks") | ||||||
| local assumed_eye_pos = vector.new(0, 1.5, 0) | local assumed_eye_pos = vector.new(0, 1.5, 0) | ||||||
|  |  | ||||||
| local function vector_copy(v) |  | ||||||
| 	return { x = v.x, y = v.y, z = v.z } |  | ||||||
| end |  | ||||||
|  |  | ||||||
| local function delay(x) | local function delay(x) | ||||||
| 	return (function() return x end) | 	return (function() return x end) | ||||||
| end | end | ||||||
|  |  | ||||||
| local function set_wielder_formspec(data, meta) | local function set_wielder_formspec(data, meta) | ||||||
| 	meta:set_string("formspec", | 	meta:set_string("formspec", | ||||||
| 			"invsize[8,"..(6+data.wield_inv_height)..";]".. | 			"size[8,"..(6+data.wield_inv_height)..";]".. | ||||||
| 			"item_image[0,0;1,1;"..data.name_base.."_off]".. | 			"item_image[0,0;1,1;"..data.name_base.."_off]".. | ||||||
| 			"label[1,0;"..minetest.formspec_escape(data.description).."]".. | 			"label[1,0;"..minetest.formspec_escape(data.description).."]".. | ||||||
| 			"list[current_name;"..minetest.formspec_escape(data.wield_inv_name)..";"..((8-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]".. | 			"list[current_name;"..minetest.formspec_escape(data.wield_inv_name)..";"..((8-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]".. | ||||||
| @@ -353,7 +349,7 @@ if pipeworks.enable_node_breaker then | |||||||
| 							{pos=pointed_thing.under, gain=sound.gain}) | 							{pos=pointed_thing.under, gain=sound.gain}) | ||||||
| 					end | 					end | ||||||
| 					wieldstack = virtplayer:get_wielded_item() | 					wieldstack = virtplayer:get_wielded_item() | ||||||
| 				else | 				--~ else | ||||||
| 					--pipeworks.logger(dname.."couldn't dig node!") | 					--pipeworks.logger(dname.."couldn't dig node!") | ||||||
| 				end | 				end | ||||||
| 			end | 			end | ||||||
| @@ -375,6 +371,7 @@ if pipeworks.enable_node_breaker then | |||||||
| 		eject_drops = true, | 		eject_drops = true, | ||||||
| 	} | 	} | ||||||
| 	register_wielder(data) | 	register_wielder(data) | ||||||
|  | 	pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:nodebreaker_off" | ||||||
| 	minetest.register_craft({ | 	minetest.register_craft({ | ||||||
| 		output = "pipeworks:nodebreaker_off", | 		output = "pipeworks:nodebreaker_off", | ||||||
| 		recipe = { | 		recipe = { | ||||||
| @@ -426,6 +423,7 @@ if pipeworks.enable_deployer then | |||||||
| 		end, | 		end, | ||||||
| 		eject_drops = false, | 		eject_drops = false, | ||||||
| 	}) | 	}) | ||||||
|  | 	pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:deployer_off" | ||||||
| 	minetest.register_craft({ | 	minetest.register_craft({ | ||||||
| 		output = "pipeworks:deployer_off", | 		output = "pipeworks:deployer_off", | ||||||
| 		recipe = { | 		recipe = { | ||||||
| @@ -461,6 +459,7 @@ if pipeworks.enable_dispenser then | |||||||
| 		end, | 		end, | ||||||
| 		eject_drops = false, | 		eject_drops = false, | ||||||
| 	}) | 	}) | ||||||
|  | 	pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:dispenser_off" | ||||||
| 	minetest.register_craft({ | 	minetest.register_craft({ | ||||||
| 		output = "pipeworks:dispenser_off", | 		output = "pipeworks:dispenser_off", | ||||||
| 		recipe = { | 		recipe = { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user