mirror of
				https://github.com/mt-mods/pipeworks.git
				synced 2025-11-04 10:45:30 +01:00 
			
		
		
		
	Compare commits
	
		
			117 Commits
		
	
	
		
			2019-06-07
			...
			503c1190ed
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 503c1190ed | |||
| 
						 | 
					75894355d4 | ||
| 5bba517b03 | |||
| 
						 | 
					7b15bdbd1f | ||
| 
						 | 
					90425fde95 | ||
| 
						 | 
					1349ff8dd8 | ||
| 
						 | 
					3b31b6f9c0 | ||
| 
						 | 
					4fce320d9c | ||
| 
						 | 
					55ded7e569 | ||
| 
						 | 
					e3d94cb3a8 | ||
| 
						 | 
					97903327a5 | ||
| 
						 | 
					37eef73695 | ||
| 
						 | 
					3092ce771f | ||
| 
						 | 
					96ccd29dd2 | ||
| 
						 | 
					8e0b25fb2c | ||
| 
						 | 
					8a29f8844c | ||
| 
						 | 
					5aa0501872 | ||
| 66070dd801 | |||
| 
						 | 
					5618003be3 | ||
| 
						 | 
					06fd754216 | ||
| 
						 | 
					794cae675e | ||
| 
						 | 
					7d3a61e595 | ||
| 
						 | 
					a70115ab8d | ||
| 
						 | 
					23fe215721 | ||
| 
						 | 
					8f067db7cd | ||
| 
						 | 
					e082ea473b | ||
| 7ee74133e1 | |||
| 
						 | 
					cec6049dd1 | ||
| 
						 | 
					047718b3c3 | ||
| 
						 | 
					01f4ea066c | ||
| 
						 | 
					7ba685344c | ||
| 
						 | 
					c39d40e940 | ||
| 
						 | 
					48b082e014 | ||
| c01bd7b888 | |||
| 
						 | 
					2670fd88a9 | ||
| 
						 | 
					3536004667 | ||
| 
						 | 
					b53a1ee477 | ||
| 
						 | 
					29bac67d3a | ||
| e2fdcc4fb2 | |||
| 
						 | 
					db6d1bd9c1 | ||
| 
						 | 
					79dc5f5c7d | ||
| 
						 | 
					01d44056a2 | ||
| 
						 | 
					c7d44272e6 | ||
| 
						 | 
					5837d62979 | ||
| e4db1e885e | |||
| 
						 | 
					fc6efb450c | ||
| 
						 | 
					828c50e85d | ||
| 
						 | 
					4add40705f | ||
| 
						 | 
					a6e4f2dceb | ||
| 
						 | 
					7ad991ce40 | ||
| f7839444cd | |||
| 
						 | 
					d2954c5277 | ||
| 93f5fb3d87 | |||
| 
						 | 
					9ad6e5d07a | ||
| 
						 | 
					31e1255245 | ||
| a535bebd2e | |||
| 
						 | 
					a735d1a155 | ||
| be2776fc46 | |||
| 
						 | 
					a2c0dd1130 | ||
| 
						 | 
					f0ef43823c | ||
| 
						 | 
					17a602a5a1 | ||
| 
						 | 
					2294a23582 | ||
| 
						 | 
					b2d2ccbcba | ||
| ee03959a65 | |||
| 
						 | 
					8322f256c5 | ||
| 
						 | 
					ba7eb19317 | ||
| 4dd30df37a | |||
| 
						 | 
					065c953eba | ||
| 946da11206 | |||
| 
						 | 
					9a63d17e4a | ||
| 
						 | 
					d814357ddf | ||
| 
						 | 
					c2fe5fe956 | ||
| 
						 | 
					9dbaa5f4f6 | ||
| 77c8026400 | |||
| 
						 | 
					d93396600f | ||
| 
						 | 
					c966a8a57d | ||
| 70b521c721 | |||
| 
						 | 
					61b061f669 | ||
| 
						 | 
					fe91d5eb46 | ||
| 
						 | 
					eb1064ca6d | ||
| 
						 | 
					f54e25ec52 | ||
| 6d795b7d34 | |||
| 
						 | 
					dedb0dd54e | ||
| 
						 | 
					477a024034 | ||
| 92249b7941 | |||
| 
						 | 
					34cb0e7682 | ||
| 
						 | 
					505fc7cc49 | ||
| e04fb691ad | |||
| 
						 | 
					cb58a646cf | ||
| 
						 | 
					e3135c53f0 | ||
| ac80224371 | |||
| 
						 | 
					366d57f4da | ||
| 
						 | 
					c79e68a80c | ||
| 
						 | 
					9338c109a6 | ||
| 
						 | 
					63bee98948 | ||
| 
						 | 
					ee6c9991b9 | ||
| 34262ed8d5 | |||
| 
						 | 
					9eefe9c7bb | ||
| 
						 | 
					8281e3d068 | ||
| 
						 | 
					ed282b0298 | ||
| 
						 | 
					5410ea74f2 | ||
| 
						 | 
					4602290bc5 | ||
| 
						 | 
					64fb90f3e5 | ||
| 5cfe8d893f | |||
| 
						 | 
					99cb3a5d9d | ||
| 
						 | 
					728d4e179a | ||
| 
						 | 
					760e9e383c | ||
| 
						 | 
					62bc13078f | ||
| 
						 | 
					84d7104c66 | ||
| 
						 | 
					2ca825f991 | ||
| 
						 | 
					0fa88b7054 | ||
| 
						 | 
					8f03c0e684 | ||
| 975e20f704 | |||
| 
						 | 
					75cfac34e6 | ||
| 
						 | 
					d5fe933456 | ||
| 2693e2ecbb | |||
| 
						 | 
					c93df73a5c | 
							
								
								
									
										13
									
								
								.github/workflows/luacheck.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.github/workflows/luacheck.yml
									
									
									
									
										vendored
									
									
										Normal file
									
								
							@@ -0,0 +1,13 @@
 | 
				
			|||||||
 | 
					name: luacheck
 | 
				
			||||||
 | 
					on: [push, pull_request]
 | 
				
			||||||
 | 
					jobs:
 | 
				
			||||||
 | 
					  build:
 | 
				
			||||||
 | 
					    runs-on: ubuntu-latest
 | 
				
			||||||
 | 
					    steps:
 | 
				
			||||||
 | 
					    - uses: actions/checkout@master
 | 
				
			||||||
 | 
					    - name: apt
 | 
				
			||||||
 | 
					      run: sudo apt-get install -y luarocks
 | 
				
			||||||
 | 
					    - name: luacheck install
 | 
				
			||||||
 | 
					      run: luarocks install --local luacheck
 | 
				
			||||||
 | 
					    - name: luacheck run
 | 
				
			||||||
 | 
					      run: $HOME/.luarocks/bin/luacheck ./
 | 
				
			||||||
							
								
								
									
										25
									
								
								.luacheckrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								.luacheckrc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
				
			|||||||
 | 
					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",
 | 
				
			||||||
 | 
						"i3",
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										2
									
								
								README
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								README
									
									
									
									
									
								
							@@ -1,7 +1,7 @@
 | 
				
			|||||||
This mod uses nodeboxes to supply a complete set of 3D pipes and tubes, 
 | 
					This mod uses nodeboxes to supply a complete set of 3D pipes and tubes, 
 | 
				
			||||||
along devices that work with them.
 | 
					along devices that work with them.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
See https://gitlab.com/VanessaE/pipeworks/wikis/ for detailed information about usage of this mod.
 | 
					See https://github.com/mt-mods/pipeworks/wiki/ for detailed information about usage of this mod.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Unlike the previous version of this mod, these pipes are rounded, and when 
 | 
					Unlike the previous version of this mod, these pipes are rounded, and when 
 | 
				
			||||||
placed, they'll automatically join together as needed.  Pipes can go vertically 
 | 
					placed, they'll automatically join together as needed.  Pipes can go vertically 
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										120
									
								
								autocrafter.lua
									
									
									
									
									
								
							
							
						
						
									
										120
									
								
								autocrafter.lua
									
									
									
									
									
								
							@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
local autocrafterCache = {}  -- caches some recipe data to avoid to call the slow function minetest.get_craft_result() every second
 | 
					local autocrafterCache = {}  -- caches some recipe data to avoid to call the slow function minetest.get_craft_result() every second
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local craft_time = 1
 | 
					local craft_time = 1
 | 
				
			||||||
@@ -16,7 +17,7 @@ end
 | 
				
			|||||||
local function get_item_info(stack)
 | 
					local function get_item_info(stack)
 | 
				
			||||||
	local name = stack:get_name()
 | 
						local name = stack:get_name()
 | 
				
			||||||
	local def = minetest.registered_items[name]
 | 
						local def = minetest.registered_items[name]
 | 
				
			||||||
	local description = def and def.description or "Unknown item"
 | 
						local description = def and def.description or S("Unknown item")
 | 
				
			||||||
	return description, name
 | 
						return description, name
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -46,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
 | 
				
			||||||
@@ -66,13 +67,16 @@ local function run_autocrafter(pos, elapsed)
 | 
				
			|||||||
	local inventory = meta:get_inventory()
 | 
						local inventory = meta:get_inventory()
 | 
				
			||||||
	local craft = get_craft(pos, inventory)
 | 
						local craft = get_craft(pos, inventory)
 | 
				
			||||||
	local output_item = craft.output.item
 | 
						local output_item = craft.output.item
 | 
				
			||||||
 | 
						-- NALC: existence de limitgroup ?
 | 
				
			||||||
 | 
						local limitcraft = minetest.get_item_group(output_item:get_name(), "limitcraft") or 0
 | 
				
			||||||
	-- only use crafts that have an actual result
 | 
						-- only use crafts that have an actual result
 | 
				
			||||||
	if output_item:is_empty() then
 | 
						-- NALC: ou si l'item n'est pas dans le group limitcraft
 | 
				
			||||||
		meta:set_string("infotext", "unconfigured Autocrafter: unknown recipe")
 | 
						if output_item:is_empty() or limitcraft > 0 then
 | 
				
			||||||
 | 
							meta:set_string("infotext", S("unconfigured Autocrafter: unknown recipe"))
 | 
				
			||||||
		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
 | 
				
			||||||
@@ -101,11 +105,10 @@ local function after_recipe_change(pos, inventory)
 | 
				
			|||||||
	if inventory:is_empty("recipe") then
 | 
						if inventory:is_empty("recipe") then
 | 
				
			||||||
		minetest.get_node_timer(pos):stop()
 | 
							minetest.get_node_timer(pos):stop()
 | 
				
			||||||
		autocrafterCache[minetest.hash_node_position(pos)] = nil
 | 
							autocrafterCache[minetest.hash_node_position(pos)] = nil
 | 
				
			||||||
		meta:set_string("infotext", "unconfigured Autocrafter")
 | 
							meta:set_string("infotext", S("unconfigured Autocrafter"))
 | 
				
			||||||
		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)
 | 
				
			||||||
@@ -126,7 +129,7 @@ local function after_recipe_change(pos, inventory)
 | 
				
			|||||||
	craft = craft or get_craft(pos, inventory, hash)
 | 
						craft = craft or get_craft(pos, inventory, hash)
 | 
				
			||||||
	local output_item = craft.output.item
 | 
						local output_item = craft.output.item
 | 
				
			||||||
	local description, name = get_item_info(output_item)
 | 
						local description, name = get_item_info(output_item)
 | 
				
			||||||
	meta:set_string("infotext", string.format("'%s' Autocrafter (%s)", description, name))
 | 
						meta:set_string("infotext", S("'@1' Autocrafter (@2)", description, name))
 | 
				
			||||||
	inventory:set_stack("output", 1, output_item)
 | 
						inventory:set_stack("output", 1, output_item)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	after_inventory_change(pos)
 | 
						after_inventory_change(pos)
 | 
				
			||||||
@@ -172,26 +175,47 @@ end
 | 
				
			|||||||
local function update_meta(meta, enabled)
 | 
					local function update_meta(meta, enabled)
 | 
				
			||||||
	local state = enabled and "on" or "off"
 | 
						local state = enabled and "on" or "off"
 | 
				
			||||||
	meta:set_int("enabled", enabled and 1 or 0)
 | 
						meta:set_int("enabled", enabled and 1 or 0)
 | 
				
			||||||
	local fs = 	"size[8,12]"..
 | 
						local list_backgrounds = ""
 | 
				
			||||||
			"list[context;recipe;0,0;3,3;]"..
 | 
						if minetest.get_modpath("i3") then
 | 
				
			||||||
			"image[3,1;1,1;gui_hb_bg.png^[colorize:#141318:255]"..
 | 
							list_backgrounds = "style_type[box;colors=#666]"
 | 
				
			||||||
			"list[context;output;3,1;1,1;]"..
 | 
							for i=0, 2 do
 | 
				
			||||||
			"image_button[3,2;1,0.6;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" ..
 | 
								for j=0, 2 do
 | 
				
			||||||
			"list[context;src;0,4.5;8,3;]"..
 | 
									list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 0.22+(j*1.25) ..";1,1;]"
 | 
				
			||||||
			"list[context;dst;4,0;4,3;]"..
 | 
								end
 | 
				
			||||||
			default.gui_bg..
 | 
							end
 | 
				
			||||||
			default.gui_bg_img..
 | 
							for i=0, 3 do
 | 
				
			||||||
			default.gui_slots..
 | 
								for j=0, 2 do
 | 
				
			||||||
			default.get_hotbar_bg(0,8) ..
 | 
									list_backgrounds = list_backgrounds .. "box[".. 5.28+(i*1.25) ..",".. 0.22+(j*1.25) ..";1,1;]"
 | 
				
			||||||
			"list[current_player;main;0,8;8,4;]" ..
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
							for i=0, 7 do
 | 
				
			||||||
 | 
								for j=0, 2 do
 | 
				
			||||||
 | 
									list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 5+(j*1.25) ..";1,1;]"
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						local size = "10.2,14"
 | 
				
			||||||
 | 
						local fs =
 | 
				
			||||||
 | 
							"formspec_version[2]"..
 | 
				
			||||||
 | 
							"size["..size.."]"..
 | 
				
			||||||
 | 
							pipeworks.fs_helpers.get_prepends(size)..
 | 
				
			||||||
 | 
							list_backgrounds..
 | 
				
			||||||
 | 
							"list[context;recipe;0.22,0.22;3,3;]"..
 | 
				
			||||||
 | 
							"image[4,1.45;1,1;[combine:16x16^[noalpha^[colorize:#141318:255]"..
 | 
				
			||||||
 | 
							"list[context;output;4,1.45;1,1;]"..
 | 
				
			||||||
 | 
							"image_button[4,2.6;1,0.6;pipeworks_button_" .. state .. ".png;" .. state .. ";;;false;pipeworks_button_interm.png]" ..
 | 
				
			||||||
 | 
							"list[context;dst;5.28,0.22;4,3;]"..
 | 
				
			||||||
 | 
							"list[context;src;0.22,5;8,3;]"..
 | 
				
			||||||
 | 
							pipeworks.fs_helpers.get_inv(9)..
 | 
				
			||||||
		"listring[current_player;main]"..
 | 
							"listring[current_player;main]"..
 | 
				
			||||||
		"listring[context;src]" ..
 | 
							"listring[context;src]" ..
 | 
				
			||||||
		"listring[current_player;main]"..
 | 
							"listring[current_player;main]"..
 | 
				
			||||||
		"listring[context;dst]" ..
 | 
							"listring[context;dst]" ..
 | 
				
			||||||
		"listring[current_player;main]"
 | 
							"listring[current_player;main]"
 | 
				
			||||||
	if minetest.get_modpath("digilines") then
 | 
						if minetest.get_modpath("digilines") then
 | 
				
			||||||
		fs = fs.."field[1,3.5;4,1;channel;Channel;${channel}]"
 | 
							fs = fs.."field[0.22,4.1;4.5,0.75;channel;"..S("Channel")..";${channel}]"..
 | 
				
			||||||
		fs = fs.."button_exit[5,3.2;2,1;save;Save]"
 | 
								"button[5,4.1;1.5,0.75;set_channel;"..S("Set").."]"..
 | 
				
			||||||
 | 
								"button_exit[6.8,4.1;2,0.75;close;"..S("Close").."]"
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	meta:set_string("formspec",fs)
 | 
						meta:set_string("formspec",fs)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -200,13 +224,13 @@ local function update_meta(meta, enabled)
 | 
				
			|||||||
	-- this might be more written code, but actually executes less
 | 
						-- this might be more written code, but actually executes less
 | 
				
			||||||
	local output = meta:get_inventory():get_stack("output", 1)
 | 
						local output = meta:get_inventory():get_stack("output", 1)
 | 
				
			||||||
	if output:is_empty() then -- doesn't matter if paused or not
 | 
						if output:is_empty() then -- doesn't matter if paused or not
 | 
				
			||||||
		meta:set_string("infotext", "unconfigured Autocrafter")
 | 
							meta:set_string("infotext", S("unconfigured Autocrafter"))
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local description, name = get_item_info(output)
 | 
						local description, name = get_item_info(output)
 | 
				
			||||||
	local infotext = enabled and string.format("'%s' Autocrafter (%s)", description, name)
 | 
						local infotext = enabled and S("'@1' Autocrafter (@2)", description, name)
 | 
				
			||||||
				or string.format("paused '%s' Autocrafter", description)
 | 
									or S("paused '@1' Autocrafter", description)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	meta:set_string("infotext", infotext)
 | 
						meta:set_string("infotext", infotext)
 | 
				
			||||||
	return enabled
 | 
						return enabled
 | 
				
			||||||
@@ -226,7 +250,7 @@ local function upgrade_autocrafter(pos, meta)
 | 
				
			|||||||
		update_meta(meta, true)
 | 
							update_meta(meta, true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if meta:get_string("virtual_items") == "1" then -- we are version 2
 | 
							if meta:get_string("virtual_items") == "1" then -- we are version 2
 | 
				
			||||||
			-- we allready dropped stuff, so lets remove the metadatasetting (we are not being called again for this node)
 | 
								-- we already dropped stuff, so lets remove the metadatasetting (we are not being called again for this node)
 | 
				
			||||||
			meta:set_string("virtual_items", "")
 | 
								meta:set_string("virtual_items", "")
 | 
				
			||||||
		else -- we are version 1
 | 
							else -- we are version 1
 | 
				
			||||||
			local recipe = inv:get_list("recipe")
 | 
								local recipe = inv:get_list("recipe")
 | 
				
			||||||
@@ -248,10 +272,10 @@ local function upgrade_autocrafter(pos, meta)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_node("pipeworks:autocrafter", {
 | 
					minetest.register_node("pipeworks:autocrafter", {
 | 
				
			||||||
	description = "Autocrafter",
 | 
						description = S("Autocrafter"),
 | 
				
			||||||
	drawtype = "normal",
 | 
						drawtype = "normal",
 | 
				
			||||||
	tiles = {"pipeworks_autocrafter.png"},
 | 
						tiles = {"pipeworks_autocrafter.png"},
 | 
				
			||||||
	groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1},
 | 
						groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 1},
 | 
				
			||||||
	tube = {insert_object = function(pos, node, stack, direction)
 | 
						tube = {insert_object = function(pos, node, stack, direction)
 | 
				
			||||||
			local meta = minetest.get_meta(pos)
 | 
								local meta = minetest.get_meta(pos)
 | 
				
			||||||
			local inv = meta:get_inventory()
 | 
								local inv = meta:get_inventory()
 | 
				
			||||||
@@ -276,7 +300,9 @@ minetest.register_node("pipeworks:autocrafter", {
 | 
				
			|||||||
		update_meta(meta, false)
 | 
							update_meta(meta, false)
 | 
				
			||||||
	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 not pipeworks.may_configure(pos, sender) then
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
		local meta = minetest.get_meta(pos)
 | 
							local meta = minetest.get_meta(pos)
 | 
				
			||||||
		if fields.on then
 | 
							if fields.on then
 | 
				
			||||||
			update_meta(meta, false)
 | 
								update_meta(meta, false)
 | 
				
			||||||
@@ -285,8 +311,9 @@ minetest.register_node("pipeworks:autocrafter", {
 | 
				
			|||||||
			if update_meta(meta, true) then
 | 
								if update_meta(meta, true) then
 | 
				
			||||||
				start_crafter(pos)
 | 
									start_crafter(pos)
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		elseif fields.save then
 | 
							end
 | 
				
			||||||
			meta:set_string("channel",fields.channel)
 | 
							if fields.channel then
 | 
				
			||||||
 | 
								meta:set_string("channel", fields.channel)
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
	can_dig = function(pos, player)
 | 
						can_dig = function(pos, player)
 | 
				
			||||||
@@ -388,6 +415,27 @@ minetest.register_node("pipeworks:autocrafter", {
 | 
				
			|||||||
						end
 | 
											end
 | 
				
			||||||
					end
 | 
										end
 | 
				
			||||||
					after_recipe_change(pos,inv)
 | 
										after_recipe_change(pos,inv)
 | 
				
			||||||
 | 
									elseif msg == "get_recipe" then
 | 
				
			||||||
 | 
										local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
										local inv = meta:get_inventory()
 | 
				
			||||||
 | 
										local recipe = {}
 | 
				
			||||||
 | 
										for y=0,2,1 do
 | 
				
			||||||
 | 
											local row = {}
 | 
				
			||||||
 | 
											for x=1,3,1 do
 | 
				
			||||||
 | 
												local slot = y*3+x
 | 
				
			||||||
 | 
												table.insert(row, inv:get_stack("recipe",slot):get_name())
 | 
				
			||||||
 | 
											end
 | 
				
			||||||
 | 
											table.insert(recipe, row)
 | 
				
			||||||
 | 
										end
 | 
				
			||||||
 | 
										local setchan = meta:get_string("channel")
 | 
				
			||||||
 | 
										local output = inv:get_stack("output", 1)
 | 
				
			||||||
 | 
										digiline:receptor_send(pos, digiline.rules.default, setchan, {
 | 
				
			||||||
 | 
											recipe = recipe,
 | 
				
			||||||
 | 
											result = {
 | 
				
			||||||
 | 
												name = output:get_name(),
 | 
				
			||||||
 | 
												count = output:get_count(),
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
										  })
 | 
				
			||||||
				elseif msg == "off" then
 | 
									elseif msg == "off" then
 | 
				
			||||||
					update_meta(meta, false)
 | 
										update_meta(meta, false)
 | 
				
			||||||
					minetest.get_node_timer(pos):stop()
 | 
										minetest.get_node_timer(pos):stop()
 | 
				
			||||||
@@ -402,12 +450,4 @@ minetest.register_node("pipeworks:autocrafter", {
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:autocrafter"
 | 
				
			||||||
minetest.register_craft( {
 | 
					 | 
				
			||||||
	output = "pipeworks:autocrafter 2",
 | 
					 | 
				
			||||||
	recipe = {
 | 
					 | 
				
			||||||
	        { "default:steel_ingot", "default:mese_crystal", "default:steel_ingot" },
 | 
					 | 
				
			||||||
	        { "basic_materials:plastic_sheet", "default:steel_ingot", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
	        { "default:steel_ingot", "default:mese_crystal", "default:steel_ingot" }
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,34 +53,35 @@ local function tube_autoroute(pos)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	-- xm = 1, xp = 2, ym = 3, yp = 4, zm = 5, zp = 6
 | 
						-- xm = 1, xp = 2, ym = 3, yp = 4, zm = 5, zp = 6
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local positions = {}
 | 
						local adjlist = {} -- this will be used in item_transport
 | 
				
			||||||
	local nodes = {}
 | 
					
 | 
				
			||||||
	for i, adj in ipairs(adjustments) do
 | 
						for i, adj in ipairs(adjustments) do
 | 
				
			||||||
		positions[i] = vector.add(pos, adj)
 | 
							local position = vector.add(pos, adj)
 | 
				
			||||||
		nodes[i] = minetest.get_node(positions[i])
 | 
							local node = minetest.get_node(position)
 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for i, node in ipairs(nodes) do
 | 
					 | 
				
			||||||
		local idef = minetest.registered_nodes[node.name]
 | 
							local idef = minetest.registered_nodes[node.name]
 | 
				
			||||||
		-- handle the tubes themselves
 | 
							-- handle the tubes themselves
 | 
				
			||||||
		if is_tube(node.name) then
 | 
							if is_tube(node.name) then
 | 
				
			||||||
			active[i] = 1
 | 
								active[i] = 1
 | 
				
			||||||
 | 
								table.insert(adjlist, adj)
 | 
				
			||||||
		-- handle new style connectors
 | 
							-- handle new style connectors
 | 
				
			||||||
		elseif idef and idef.tube and idef.tube.connect_sides then
 | 
							elseif idef and idef.tube and idef.tube.connect_sides then
 | 
				
			||||||
			local dir = adjustments[i]
 | 
								if idef.tube.connect_sides[nodeside(node, vector.multiply(adj, -1))] then
 | 
				
			||||||
			if idef.tube.connect_sides[nodeside(node, vector.multiply(dir, -1))] then
 | 
					 | 
				
			||||||
				active[i] = 1
 | 
									active[i] = 1
 | 
				
			||||||
 | 
									table.insert(adjlist, adj)
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						minetest.get_meta(pos):set_string("adjlist", minetest.serialize(adjlist))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	-- all sides checked, now figure which tube to use.
 | 
						-- all sides checked, now figure which tube to use.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local nodedef = minetest.registered_nodes[nctr.name]
 | 
						local nodedef = minetest.registered_nodes[nctr.name]
 | 
				
			||||||
	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
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										67
									
								
								common.lua
									
									
									
									
									
								
							
							
						
						
									
										67
									
								
								common.lua
									
									
									
									
									
								
							@@ -86,10 +86,9 @@ function pipeworks.table_contains(tbl, element)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function pipeworks.table_extend(tbl, tbl2)
 | 
					function pipeworks.table_extend(tbl, tbl2)
 | 
				
			||||||
	local index = #tbl + 1
 | 
						local oldlength = #tbl
 | 
				
			||||||
	for _, elt in ipairs(tbl2) do
 | 
						for i = 1,#tbl2 do
 | 
				
			||||||
		tbl[index] = elt
 | 
							tbl[oldlength + i] = tbl2[i]
 | 
				
			||||||
		index = index + 1
 | 
					 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -115,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])
 | 
				
			||||||
@@ -144,6 +143,55 @@ function fs_helpers.cycling_button(meta, base, meta_name, values)
 | 
				
			|||||||
	return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text)..(addopts and ";"..addopts or "").."]"
 | 
						return base..";"..(texture_name and texture_name..";" or "")..field..";"..minetest.formspec_escape(text)..(addopts and ";"..addopts or "").."]"
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function fs_helpers.get_inv(y)
 | 
				
			||||||
 | 
						local fs = {}
 | 
				
			||||||
 | 
						if minetest.get_modpath("i3") then
 | 
				
			||||||
 | 
							local inv_x = i3.settings.legacy_inventory and 0.75 or 0.22
 | 
				
			||||||
 | 
							local inv_y = (y + 0.4) or 6.9
 | 
				
			||||||
 | 
							local size, spacing = 1, 0.1
 | 
				
			||||||
 | 
							local hotbar_len = i3.settings.hotbar_len
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							table.insert(fs, "style_type[box;colors=#77777710,#77777710,#777,#777]")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for i = 0, hotbar_len - 1 do
 | 
				
			||||||
 | 
								table.insert(fs, "box["..(i * size + inv_x + (i * spacing))..","..inv_y..";"..size..","..size..";]")
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]")
 | 
				
			||||||
 | 
							table.insert(fs, "list[current_player;main;"..inv_x..","..inv_y..";"..hotbar_len..",1;]")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							table.insert(fs, "style_type[box;colors=#666]")
 | 
				
			||||||
 | 
							for i=0, 2 do
 | 
				
			||||||
 | 
								for j=0, (i3.settings.legacy_inventory and 7 or 8) do
 | 
				
			||||||
 | 
									table.insert(fs, "box["..0.2+(j*0.1)+(j*size)..","..(inv_y+size+spacing+0.05)+(i*0.1)+(i*size)..";"..size..","..size..";]")
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							table.insert(fs, "style_type[list;size="..size..";spacing="..spacing.."]")
 | 
				
			||||||
 | 
							table.insert(fs, "list[current_player;main;"..inv_x..","..(inv_y + 1.15)..";"..hotbar_len..","..(i3.settings.inv_size / hotbar_len)..";"..hotbar_len.."]")
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							table.insert(fs, "list[current_player;main;0.22,"..y..";8,4;]")
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return table.concat(fs, "")
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function fs_helpers.get_prepends(size)
 | 
				
			||||||
 | 
						local prepend = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if minetest.get_modpath("i3") then
 | 
				
			||||||
 | 
							prepend = {
 | 
				
			||||||
 | 
								"no_prepend[]",
 | 
				
			||||||
 | 
								"bgcolor[black;neither]",
 | 
				
			||||||
 | 
								"background9[0,0;"..size..";i3_bg_full.png;false;10]",
 | 
				
			||||||
 | 
								"style_type[button;border=false;bgimg=[combine:16x16^[noalpha^[colorize:#6b6b6b]",
 | 
				
			||||||
 | 
								"listcolors[#0000;#ffffff20]"
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return table.concat(prepend, "")
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
---------
 | 
					---------
 | 
				
			||||||
-- Env --
 | 
					-- Env --
 | 
				
			||||||
---------
 | 
					---------
 | 
				
			||||||
@@ -184,7 +232,7 @@ function pipeworks.create_fake_player(def, is_dynamic)
 | 
				
			|||||||
		is_player = delay(true),
 | 
							is_player = delay(true),
 | 
				
			||||||
		is_fake_player = true,
 | 
							is_fake_player = true,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		_formspec = def.formspec or default.gui_survival_form,
 | 
							_formspec = def.formspec or "",
 | 
				
			||||||
		_hp = def.hp or 20,
 | 
							_hp = def.hp or 20,
 | 
				
			||||||
		_breath = 11,
 | 
							_breath = 11,
 | 
				
			||||||
		_pos = def.position and table.copy(def.position) or vector.new(),
 | 
							_pos = def.position and table.copy(def.position) or vector.new(),
 | 
				
			||||||
@@ -224,7 +272,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
 | 
				
			||||||
@@ -243,17 +291,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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,7 +11,10 @@ local tube_entry = "^pipeworks_tube_connection_wooden.png"
 | 
				
			|||||||
-- Chest Locals
 | 
					-- Chest Locals
 | 
				
			||||||
local open_chests = {}
 | 
					local open_chests = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function get_chest_formspec(pos)
 | 
					local get_chest_formspec
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if minetest.get_modpath("default") then
 | 
				
			||||||
 | 
						function get_chest_formspec(pos)
 | 
				
			||||||
		local spos = pos.x .. "," .. pos.y .. "," .. pos.z
 | 
							local spos = pos.x .. "," .. pos.y .. "," .. pos.z
 | 
				
			||||||
		local formspec =
 | 
							local formspec =
 | 
				
			||||||
			"size[8,9]" ..
 | 
								"size[8,9]" ..
 | 
				
			||||||
@@ -38,6 +41,42 @@ local function get_chest_formspec(pos)
 | 
				
			|||||||
			)..pipeworks.button_label
 | 
								)..pipeworks.button_label
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return formspec
 | 
							return formspec
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
						local function get_hotbar_bg(x,y)
 | 
				
			||||||
 | 
							local out = ""
 | 
				
			||||||
 | 
							for i=0,7,1 do
 | 
				
			||||||
 | 
								out = out .."image["..x+i..","..y..";1,1;gui_hb_bg.png]"
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
							return out
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						function get_chest_formspec(pos)
 | 
				
			||||||
 | 
							local spos = pos.x .. "," .. pos.y .. "," .. pos.z
 | 
				
			||||||
 | 
							local formspec =
 | 
				
			||||||
 | 
								"size[10,9]" ..
 | 
				
			||||||
 | 
								"background9[8,8;8,9;hades_chests_chestui.png;true;8]"..
 | 
				
			||||||
 | 
								"list[nodemeta:" .. spos .. ";main;0,0.3;10,4;]" ..
 | 
				
			||||||
 | 
								"list[current_player;main;0,4.85;10,1;]" ..
 | 
				
			||||||
 | 
								"list[current_player;main;0,6.08;10,3;10]" ..
 | 
				
			||||||
 | 
								"listring[nodemeta:" .. spos .. ";main]" ..
 | 
				
			||||||
 | 
								"listring[current_player;main]" ..
 | 
				
			||||||
 | 
								get_hotbar_bg(0,4.85)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							-- Pipeworks Switch
 | 
				
			||||||
 | 
							formspec = formspec ..
 | 
				
			||||||
 | 
								fs_helpers.cycling_button(
 | 
				
			||||||
 | 
									minetest.get_meta(pos),
 | 
				
			||||||
 | 
									pipeworks.button_base,
 | 
				
			||||||
 | 
									"splitstacks",
 | 
				
			||||||
 | 
									{
 | 
				
			||||||
 | 
										pipeworks.button_off,
 | 
				
			||||||
 | 
										pipeworks.button_on
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								)..pipeworks.button_label
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return formspec
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function chest_lid_obstructed(pos)
 | 
					local function chest_lid_obstructed(pos)
 | 
				
			||||||
@@ -65,22 +104,22 @@ 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
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
				minetest.after(0.2, function()
 | 
									minetest.after(0.2, function()
 | 
				
			||||||
 | 
										if minetest.get_modpath("default") then
 | 
				
			||||||
						minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 })
 | 
											minetest.swap_node(pos, { name = "default:" .. swap, param2 = node.param2 })
 | 
				
			||||||
 | 
										end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					-- Pipeworks notification
 | 
										-- Pipeworks notification
 | 
				
			||||||
					pipeworks.after_place(pos)
 | 
										pipeworks.after_place(pos)
 | 
				
			||||||
				end)
 | 
									end)
 | 
				
			||||||
				minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10})
 | 
									minetest.sound_play(sound, {gain = 0.3, pos = pos, max_hear_distance = 10})
 | 
				
			||||||
			end
 | 
								elseif pipeworks.may_configure(pos, player) then
 | 
				
			||||||
 | 
					 | 
				
			||||||
				-- Pipeworks Switch
 | 
									-- Pipeworks Switch
 | 
				
			||||||
			if pipeworks.may_configure(pos, player) and not fields.quit then
 | 
					 | 
				
			||||||
				fs_helpers.on_receive_fields(pos, fields)
 | 
									fs_helpers.on_receive_fields(pos, fields)
 | 
				
			||||||
				minetest.show_formspec(player:get_player_name(), "pipeworks:chest_formspec", get_chest_formspec(pos))
 | 
									minetest.show_formspec(player:get_player_name(), "pipeworks:chest_formspec", get_chest_formspec(pos))
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
@@ -90,10 +129,18 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
 | 
				
			|||||||
end)
 | 
					end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Original Definitions
 | 
					-- Original Definitions
 | 
				
			||||||
local old_chest_def = table.copy(minetest.registered_items["default:chest"])
 | 
					local old_chest_def, old_chest_open_def, old_chest_locked_def, old_chest_locked_open_def
 | 
				
			||||||
local old_chest_open_def = table.copy(minetest.registered_items["default:chest_open"])
 | 
					if minetest.get_modpath("default") then
 | 
				
			||||||
local old_chest_locked_def = table.copy(minetest.registered_items["default:chest_locked"])
 | 
						old_chest_def = table.copy(minetest.registered_items["default:chest"])
 | 
				
			||||||
local old_chest_locked_open_def = table.copy(minetest.registered_items["default:chest_locked_open"])
 | 
						old_chest_open_def = table.copy(minetest.registered_items["default:chest_open"])
 | 
				
			||||||
 | 
						old_chest_locked_def = table.copy(minetest.registered_items["default:chest_locked"])
 | 
				
			||||||
 | 
						old_chest_locked_open_def = table.copy(minetest.registered_items["default:chest_locked_open"])
 | 
				
			||||||
 | 
					elseif minetest.get_modpath("hades_chests") then
 | 
				
			||||||
 | 
						old_chest_def = table.copy(minetest.registered_items["hades_chests:chest"])
 | 
				
			||||||
 | 
						old_chest_open_def = table.copy(minetest.registered_items["hades_chests:chest"])
 | 
				
			||||||
 | 
						old_chest_locked_def = table.copy(minetest.registered_items["hades_chests:chest_locked"])
 | 
				
			||||||
 | 
						old_chest_locked_open_def = table.copy(minetest.registered_items["hades_chests:chest_locked"])
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Override Construction
 | 
					-- Override Construction
 | 
				
			||||||
local override_protected, override, override_open, override_protected_open
 | 
					local override_protected, override, override_open, override_protected_open
 | 
				
			||||||
@@ -118,10 +165,12 @@ override_protected = {
 | 
				
			|||||||
		minetest.sound_play(old_chest_locked_def.sound_open, {gain = 0.3,
 | 
							minetest.sound_play(old_chest_locked_def.sound_open, {gain = 0.3,
 | 
				
			||||||
				pos = pos, max_hear_distance = 10})
 | 
									pos = pos, max_hear_distance = 10})
 | 
				
			||||||
		if not chest_lid_obstructed(pos) then
 | 
							if not chest_lid_obstructed(pos) then
 | 
				
			||||||
 | 
								if minetest.get_modpath("default") then
 | 
				
			||||||
				minetest.swap_node(pos,
 | 
									minetest.swap_node(pos,
 | 
				
			||||||
						{ name = "default:" .. "chest_locked" .. "_open",
 | 
											{ name = "default:" .. "chest_locked" .. "_open",
 | 
				
			||||||
						param2 = node.param2 })
 | 
											param2 = node.param2 })
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
		minetest.after(0.2, minetest.show_formspec,
 | 
							minetest.after(0.2, minetest.show_formspec,
 | 
				
			||||||
				clicker:get_player_name(),
 | 
									clicker:get_player_name(),
 | 
				
			||||||
				"pipeworks:chest_formspec", get_chest_formspec(pos))
 | 
									"pipeworks:chest_formspec", get_chest_formspec(pos))
 | 
				
			||||||
@@ -162,10 +211,12 @@ override = {
 | 
				
			|||||||
		minetest.sound_play(old_chest_def.sound_open, {gain = 0.3, pos = pos,
 | 
							minetest.sound_play(old_chest_def.sound_open, {gain = 0.3, pos = pos,
 | 
				
			||||||
				max_hear_distance = 10})
 | 
									max_hear_distance = 10})
 | 
				
			||||||
		if not chest_lid_obstructed(pos) then
 | 
							if not chest_lid_obstructed(pos) then
 | 
				
			||||||
 | 
								if minetest.get_modpath("default") then
 | 
				
			||||||
				minetest.swap_node(pos, {
 | 
									minetest.swap_node(pos, {
 | 
				
			||||||
						name = "default:" .. "chest" .. "_open",
 | 
											name = "default:" .. "chest" .. "_open",
 | 
				
			||||||
						param2 = node.param2 })
 | 
											param2 = node.param2 })
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
		minetest.after(0.2, minetest.show_formspec,
 | 
							minetest.after(0.2, minetest.show_formspec,
 | 
				
			||||||
				clicker:get_player_name(),
 | 
									clicker:get_player_name(),
 | 
				
			||||||
				"pipeworks:chest_formspec", get_chest_formspec(pos))
 | 
									"pipeworks:chest_formspec", get_chest_formspec(pos))
 | 
				
			||||||
@@ -232,14 +283,21 @@ 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Override with the new modifications.
 | 
					-- Override with the new modifications.
 | 
				
			||||||
minetest.override_item("default:chest", override)
 | 
					if minetest.get_modpath("default") then
 | 
				
			||||||
minetest.override_item("default:chest_open", override_open)
 | 
						minetest.override_item("default:chest", override)
 | 
				
			||||||
minetest.override_item("default:chest_locked", override_protected)
 | 
						minetest.override_item("default:chest_open", override_open)
 | 
				
			||||||
minetest.override_item("default:chest_locked_open", override_protected_open)
 | 
						minetest.override_item("default:chest_locked", override_protected)
 | 
				
			||||||
 | 
					  minetest.override_item("default:chest_locked_open", override_protected_open)
 | 
				
			||||||
 | 
					elseif minetest.get_modpath("hades_chests") then
 | 
				
			||||||
 | 
						minetest.override_item("hades_chests:chest", override)
 | 
				
			||||||
 | 
						--minetest.override_item("hades_chests:chest_open", override_open)
 | 
				
			||||||
 | 
						minetest.override_item("hades_chests:chest_locked", override_protected)
 | 
				
			||||||
 | 
					  --minetest.override_item("hades_chests:chest_locked_open", override_protected_open)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,277 +1,28 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
-- this file is basically a modified copy of
 | 
					-- this file is basically a modified copy of
 | 
				
			||||||
-- minetest_game/mods/default/furnaces.lua
 | 
					-- minetest_game/mods/default/furnaces.lua
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local fs_helpers = pipeworks.fs_helpers
 | 
					local def--, def_active
 | 
				
			||||||
 | 
					if minetest.get_modpath("default") then
 | 
				
			||||||
tube_entry = "^pipeworks_tube_connection_stony.png"
 | 
						def = table.copy(minetest.registered_nodes["default:furnace"])
 | 
				
			||||||
 | 
						--def_active = table.copy(minetest.registered_nodes["default:furnace_active"])
 | 
				
			||||||
local function active_formspec(fuel_percent, item_percent, pos, meta)
 | 
					elseif minetest.get_modpath("hades_furnaces") then
 | 
				
			||||||
	local formspec =
 | 
						def = table.copy(minetest.registered_nodes["hades_furnaces:furnace"])
 | 
				
			||||||
		"size[8,8.5]"..
 | 
						--def_active = table.copy(minetest.registered_nodes["hades_furnaces:furnace_active"])
 | 
				
			||||||
		default.gui_bg..
 | 
					 | 
				
			||||||
		default.gui_bg_img..
 | 
					 | 
				
			||||||
		default.gui_slots..
 | 
					 | 
				
			||||||
		"list[current_name;src;2.75,0.5;1,1;]"..
 | 
					 | 
				
			||||||
		"list[current_name;fuel;2.75,2.5;1,1;]"..
 | 
					 | 
				
			||||||
		"image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:"..
 | 
					 | 
				
			||||||
		(100-fuel_percent)..":default_furnace_fire_fg.png]"..
 | 
					 | 
				
			||||||
		"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[lowpart:"..
 | 
					 | 
				
			||||||
		(item_percent)..":gui_furnace_arrow_fg.png^[transformR270]"..
 | 
					 | 
				
			||||||
		"list[current_name;dst;4.75,0.96;2,2;]"..
 | 
					 | 
				
			||||||
		"list[current_player;main;0,4.25;8,1;]"..
 | 
					 | 
				
			||||||
		"list[current_player;main;0,5.5;8,3;8]"..
 | 
					 | 
				
			||||||
		"listring[current_name;dst]"..
 | 
					 | 
				
			||||||
		"listring[current_player;main]"..
 | 
					 | 
				
			||||||
		"listring[current_name;src]"..
 | 
					 | 
				
			||||||
		"listring[current_player;main]"..
 | 
					 | 
				
			||||||
		"listring[current_name;fuel]"..
 | 
					 | 
				
			||||||
		"listring[current_player;main]"..
 | 
					 | 
				
			||||||
		default.get_hotbar_bg(0, 4.25) ..
 | 
					 | 
				
			||||||
			fs_helpers.cycling_button(
 | 
					 | 
				
			||||||
				meta,
 | 
					 | 
				
			||||||
				"image_button[0,3.5;1,0.6",
 | 
					 | 
				
			||||||
				"split_material_stacks",
 | 
					 | 
				
			||||||
				{
 | 
					 | 
				
			||||||
					pipeworks.button_off,
 | 
					 | 
				
			||||||
					pipeworks.button_on
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			).."label[0.9,3.51;Allow splitting incoming material (not fuel) stacks from tubes]"
 | 
					 | 
				
			||||||
	return formspec
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function inactive_formspec(pos, meta)
 | 
					local tube_entry = "^pipeworks_tube_connection_stony.png"
 | 
				
			||||||
	local formspec = "size[8,8.5]"..
 | 
					 | 
				
			||||||
	default.gui_bg..
 | 
					 | 
				
			||||||
	default.gui_bg_img..
 | 
					 | 
				
			||||||
	default.gui_slots..
 | 
					 | 
				
			||||||
	"list[current_name;src;2.75,0.5;1,1;]"..
 | 
					 | 
				
			||||||
	"list[current_name;fuel;2.75,2.5;1,1;]"..
 | 
					 | 
				
			||||||
	"image[2.75,1.5;1,1;default_furnace_fire_bg.png]"..
 | 
					 | 
				
			||||||
	"image[3.75,1.5;1,1;gui_furnace_arrow_bg.png^[transformR270]"..
 | 
					 | 
				
			||||||
	"list[current_name;dst;4.75,0.96;2,2;]"..
 | 
					 | 
				
			||||||
	"list[current_player;main;0,4.25;8,1;]"..
 | 
					 | 
				
			||||||
	"list[current_player;main;0,5.5;8,3;8]"..
 | 
					 | 
				
			||||||
	"listring[current_name;dst]"..
 | 
					 | 
				
			||||||
	"listring[current_player;main]"..
 | 
					 | 
				
			||||||
	"listring[current_name;src]"..
 | 
					 | 
				
			||||||
	"listring[current_player;main]"..
 | 
					 | 
				
			||||||
	"listring[current_name;fuel]"..
 | 
					 | 
				
			||||||
	"listring[current_player;main]"..
 | 
					 | 
				
			||||||
	default.get_hotbar_bg(0, 4.25) ..
 | 
					 | 
				
			||||||
		fs_helpers.cycling_button(
 | 
					 | 
				
			||||||
			meta,
 | 
					 | 
				
			||||||
			"image_button[0,3.5;1,0.6",
 | 
					 | 
				
			||||||
			"split_material_stacks",
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				pipeworks.button_off,
 | 
					 | 
				
			||||||
				pipeworks.button_on
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		).."label[0.9,3.51;Allow splitting incoming material (not fuel) stacks from tubes]"
 | 
					 | 
				
			||||||
	return formspec
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
--
 | 
					local groups = def.groups
 | 
				
			||||||
-- Node callback functions that are the same for active and inactive furnace
 | 
					groups["tubedevice"] = 1
 | 
				
			||||||
--
 | 
					groups["tubedevice_receiver"] = 1
 | 
				
			||||||
 | 
					local groups_active = table.copy(groups)
 | 
				
			||||||
local function can_dig(pos, player)
 | 
					groups_active["not_in_creative_inventory"] = 1
 | 
				
			||||||
	local meta = minetest.get_meta(pos);
 | 
					 | 
				
			||||||
	local inv = meta:get_inventory()
 | 
					 | 
				
			||||||
	return inv:is_empty("fuel") and inv:is_empty("dst") and inv:is_empty("src")
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
 | 
					 | 
				
			||||||
	if minetest.is_protected(pos, player:get_player_name()) then
 | 
					 | 
				
			||||||
		return 0
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	local meta = minetest.get_meta(pos)
 | 
					 | 
				
			||||||
	local inv = meta:get_inventory()
 | 
					 | 
				
			||||||
	if listname == "fuel" then
 | 
					 | 
				
			||||||
		if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then
 | 
					 | 
				
			||||||
			if inv:is_empty("src") then
 | 
					 | 
				
			||||||
				meta:set_string("infotext", "Furnace is empty")
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
			return stack:get_count()
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			return 0
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	elseif listname == "src" then
 | 
					 | 
				
			||||||
		return stack:get_count()
 | 
					 | 
				
			||||||
	elseif listname == "dst" then
 | 
					 | 
				
			||||||
		return 0
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player)
 | 
					 | 
				
			||||||
	local meta = minetest.get_meta(pos)
 | 
					 | 
				
			||||||
	local inv = meta:get_inventory()
 | 
					 | 
				
			||||||
	local stack = inv:get_stack(from_list, from_index)
 | 
					 | 
				
			||||||
	return allow_metadata_inventory_put(pos, to_list, to_index, stack, player)
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
 | 
					 | 
				
			||||||
	if minetest.is_protected(pos, player:get_player_name()) then
 | 
					 | 
				
			||||||
		return 0
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	return stack:get_count()
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
local function swap_node(pos, name)
 | 
					 | 
				
			||||||
	local node = minetest.get_node(pos)
 | 
					 | 
				
			||||||
	if node.name == name then
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	node.name = name
 | 
					 | 
				
			||||||
	minetest.swap_node(pos, node)
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
local function furnace_node_timer(pos, elapsed)
 | 
					 | 
				
			||||||
	--
 | 
					 | 
				
			||||||
	-- Inizialize metadata
 | 
					 | 
				
			||||||
	--
 | 
					 | 
				
			||||||
	local meta = minetest.get_meta(pos)
 | 
					 | 
				
			||||||
	local fuel_time = meta:get_float("fuel_time") or 0
 | 
					 | 
				
			||||||
	local src_time = meta:get_float("src_time") or 0
 | 
					 | 
				
			||||||
	local fuel_totaltime = meta:get_float("fuel_totaltime") or 0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	local inv = meta:get_inventory()
 | 
					 | 
				
			||||||
	local srclist, fuellist
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	local cookable, cooked
 | 
					 | 
				
			||||||
	local fuel
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	local update = true
 | 
					 | 
				
			||||||
	while update do
 | 
					 | 
				
			||||||
		update = false
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		srclist = inv:get_list("src")
 | 
					 | 
				
			||||||
		fuellist = inv:get_list("fuel")
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		--
 | 
					 | 
				
			||||||
		-- Cooking
 | 
					 | 
				
			||||||
		--
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		-- Check if we have cookable content
 | 
					 | 
				
			||||||
		local aftercooked
 | 
					 | 
				
			||||||
		cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist})
 | 
					 | 
				
			||||||
		cookable = cooked.time ~= 0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		-- Check if we have enough fuel to burn
 | 
					 | 
				
			||||||
		if fuel_time < fuel_totaltime then
 | 
					 | 
				
			||||||
			-- The furnace is currently active and has enough fuel
 | 
					 | 
				
			||||||
			fuel_time = fuel_time + elapsed
 | 
					 | 
				
			||||||
			-- If there is a cookable item then check if it is ready yet
 | 
					 | 
				
			||||||
			if cookable then
 | 
					 | 
				
			||||||
				src_time = src_time + elapsed
 | 
					 | 
				
			||||||
				if src_time >= cooked.time then
 | 
					 | 
				
			||||||
					-- Place result in dst list if possible
 | 
					 | 
				
			||||||
					if inv:room_for_item("dst", cooked.item) then
 | 
					 | 
				
			||||||
						inv:add_item("dst", cooked.item)
 | 
					 | 
				
			||||||
						inv:set_stack("src", 1, aftercooked.items[1])
 | 
					 | 
				
			||||||
						src_time = src_time - cooked.time
 | 
					 | 
				
			||||||
						update = true
 | 
					 | 
				
			||||||
					end
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			-- Furnace ran out of fuel
 | 
					 | 
				
			||||||
			if cookable then
 | 
					 | 
				
			||||||
				-- We need to get new fuel
 | 
					 | 
				
			||||||
				local afterfuel
 | 
					 | 
				
			||||||
				fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
				if fuel.time == 0 then
 | 
					 | 
				
			||||||
					-- No valid fuel in fuel list
 | 
					 | 
				
			||||||
					fuel_totaltime = 0
 | 
					 | 
				
			||||||
					src_time = 0
 | 
					 | 
				
			||||||
				else
 | 
					 | 
				
			||||||
					-- Take fuel from fuel list
 | 
					 | 
				
			||||||
					inv:set_stack("fuel", 1, afterfuel.items[1])
 | 
					 | 
				
			||||||
					update = true
 | 
					 | 
				
			||||||
					fuel_totaltime = fuel.time + (fuel_time - fuel_totaltime)
 | 
					 | 
				
			||||||
					src_time = src_time + elapsed
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				-- We don't need to get new fuel since there is no cookable item
 | 
					 | 
				
			||||||
				fuel_totaltime = 0
 | 
					 | 
				
			||||||
				src_time = 0
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
			fuel_time = 0
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		elapsed = 0
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if fuel and fuel_totaltime > fuel.time then
 | 
					 | 
				
			||||||
		fuel_totaltime = fuel.time
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	if srclist[1]:is_empty() then
 | 
					 | 
				
			||||||
		src_time = 0
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	--
 | 
					 | 
				
			||||||
	-- Update formspec, infotext and node
 | 
					 | 
				
			||||||
	--
 | 
					 | 
				
			||||||
	local formspec = inactive_formspec(pos, meta)
 | 
					 | 
				
			||||||
	local item_state
 | 
					 | 
				
			||||||
	local item_percent = 0
 | 
					 | 
				
			||||||
	if cookable then
 | 
					 | 
				
			||||||
		item_percent = math.floor(src_time / cooked.time * 100)
 | 
					 | 
				
			||||||
		if item_percent > 100 then
 | 
					 | 
				
			||||||
			item_state = "100% (output full)"
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			item_state = item_percent .. "%"
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		if srclist[1]:is_empty() then
 | 
					 | 
				
			||||||
			item_state = "Empty"
 | 
					 | 
				
			||||||
		else
 | 
					 | 
				
			||||||
			item_state = "Not cookable"
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	local fuel_state = "Empty"
 | 
					 | 
				
			||||||
	local active = "inactive "
 | 
					 | 
				
			||||||
	local result = false
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if fuel_totaltime ~= 0 then
 | 
					 | 
				
			||||||
		active = "active "
 | 
					 | 
				
			||||||
		local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100)
 | 
					 | 
				
			||||||
		fuel_state = fuel_percent .. "%"
 | 
					 | 
				
			||||||
		formspec = active_formspec(fuel_percent, item_percent, pos, meta)
 | 
					 | 
				
			||||||
		swap_node(pos, "default:furnace_active")
 | 
					 | 
				
			||||||
		-- make sure timer restarts automatically
 | 
					 | 
				
			||||||
		result = true
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		if not fuellist[1]:is_empty() then
 | 
					 | 
				
			||||||
			fuel_state = "0%"
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
		swap_node(pos, "default:furnace")
 | 
					 | 
				
			||||||
		-- stop timer on the inactive furnace
 | 
					 | 
				
			||||||
		minetest.get_node_timer(pos):stop()
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	local infotext = "Furnace " .. active .. "(Item: " .. item_state .. "; Fuel: " .. fuel_state .. ")"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	--
 | 
					 | 
				
			||||||
	-- Set meta values
 | 
					 | 
				
			||||||
	--
 | 
					 | 
				
			||||||
	meta:set_float("fuel_totaltime", fuel_totaltime)
 | 
					 | 
				
			||||||
	meta:set_float("fuel_time", fuel_time)
 | 
					 | 
				
			||||||
	meta:set_float("src_time", src_time)
 | 
					 | 
				
			||||||
	meta:set_string("formspec", formspec)
 | 
					 | 
				
			||||||
	meta:set_string("infotext", infotext)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	return result
 | 
					 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
--
 | 
					--
 | 
				
			||||||
-- Node definitions
 | 
					-- Node definitions
 | 
				
			||||||
--
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_node(":default:furnace", {
 | 
					local override = {
 | 
				
			||||||
	description = "Furnace",
 | 
					 | 
				
			||||||
	tiles = {
 | 
						tiles = {
 | 
				
			||||||
		"default_furnace_top.png"..tube_entry,
 | 
							"default_furnace_top.png"..tube_entry,
 | 
				
			||||||
		"default_furnace_bottom.png"..tube_entry,
 | 
							"default_furnace_bottom.png"..tube_entry,
 | 
				
			||||||
@@ -280,7 +31,7 @@ minetest.register_node(":default:furnace", {
 | 
				
			|||||||
		"default_furnace_side.png"..tube_entry,
 | 
							"default_furnace_side.png"..tube_entry,
 | 
				
			||||||
		"default_furnace_front.png"
 | 
							"default_furnace_front.png"
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1},
 | 
						groups = groups,
 | 
				
			||||||
	tube = {
 | 
						tube = {
 | 
				
			||||||
		insert_object = function(pos, node, stack, direction)
 | 
							insert_object = function(pos, node, stack, direction)
 | 
				
			||||||
			local meta = minetest.get_meta(pos)
 | 
								local meta = minetest.get_meta(pos)
 | 
				
			||||||
@@ -310,57 +61,13 @@ minetest.register_node(":default:furnace", {
 | 
				
			|||||||
		input_inventory = "dst",
 | 
							input_inventory = "dst",
 | 
				
			||||||
		connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
 | 
							connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
					 | 
				
			||||||
	legacy_facedir_simple = true,
 | 
					 | 
				
			||||||
	is_ground_content = false,
 | 
					 | 
				
			||||||
	sounds = default.node_sound_stone_defaults(),
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	can_dig = can_dig,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	on_timer = furnace_node_timer,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	on_construct = function(pos)
 | 
					 | 
				
			||||||
		local meta = minetest.get_meta(pos)
 | 
					 | 
				
			||||||
		meta:set_string("formspec", inactive_formspec(pos, meta))
 | 
					 | 
				
			||||||
		local inv = meta:get_inventory()
 | 
					 | 
				
			||||||
		inv:set_size('src', 1)
 | 
					 | 
				
			||||||
		inv:set_size('fuel', 1)
 | 
					 | 
				
			||||||
		inv:set_size('dst', 4)
 | 
					 | 
				
			||||||
	end,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	on_metadata_inventory_move = function(pos)
 | 
					 | 
				
			||||||
		minetest.get_node_timer(pos):start(1.0)
 | 
					 | 
				
			||||||
	end,
 | 
					 | 
				
			||||||
	on_metadata_inventory_put = function(pos)
 | 
					 | 
				
			||||||
		-- start timer function, it will sort out whether furnace can burn or not.
 | 
					 | 
				
			||||||
		minetest.get_node_timer(pos):start(1.0)
 | 
					 | 
				
			||||||
	end,
 | 
					 | 
				
			||||||
	on_blast = function(pos)
 | 
					 | 
				
			||||||
		local drops = {}
 | 
					 | 
				
			||||||
		default.get_inventory_drops(pos, "src", drops)
 | 
					 | 
				
			||||||
		default.get_inventory_drops(pos, "fuel", drops)
 | 
					 | 
				
			||||||
		default.get_inventory_drops(pos, "dst", drops)
 | 
					 | 
				
			||||||
		drops[#drops+1] = "default:furnace"
 | 
					 | 
				
			||||||
		minetest.remove_node(pos)
 | 
					 | 
				
			||||||
		return drops
 | 
					 | 
				
			||||||
	end,
 | 
					 | 
				
			||||||
	allow_metadata_inventory_put = allow_metadata_inventory_put,
 | 
					 | 
				
			||||||
	allow_metadata_inventory_move = allow_metadata_inventory_move,
 | 
					 | 
				
			||||||
	allow_metadata_inventory_take = allow_metadata_inventory_take,
 | 
					 | 
				
			||||||
	on_receive_fields = function(pos, formname, fields, sender)
 | 
					 | 
				
			||||||
		if not pipeworks.may_configure(pos, sender) then return end
 | 
					 | 
				
			||||||
		fs_helpers.on_receive_fields(pos, fields)
 | 
					 | 
				
			||||||
		local meta = minetest.get_meta(pos)
 | 
					 | 
				
			||||||
		local formspec = inactive_formspec(pos, meta)
 | 
					 | 
				
			||||||
		meta:set_string("formspec", formspec)
 | 
					 | 
				
			||||||
	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 = pipeworks.on_rotate
 | 
						on_rotate = pipeworks.on_rotate
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_node(":default:furnace_active", {
 | 
					local override_active = {
 | 
				
			||||||
	description = "Furnace",
 | 
					 | 
				
			||||||
	tiles = {
 | 
						tiles = {
 | 
				
			||||||
		"default_furnace_top.png"..tube_entry,
 | 
							"default_furnace_top.png"..tube_entry,
 | 
				
			||||||
		"default_furnace_bottom.png"..tube_entry,
 | 
							"default_furnace_bottom.png"..tube_entry,
 | 
				
			||||||
@@ -378,7 +85,7 @@ minetest.register_node(":default:furnace_active", {
 | 
				
			|||||||
			},
 | 
								},
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	groups = {cracky = 2, tubedevice = 1, tubedevice_receiver = 1, not_in_creative_inventory = 1},
 | 
						groups = groups_active,
 | 
				
			||||||
	tube = {
 | 
						tube = {
 | 
				
			||||||
		insert_object = function(pos,node,stack,direction)
 | 
							insert_object = function(pos,node,stack,direction)
 | 
				
			||||||
			local meta = minetest.get_meta(pos)
 | 
								local meta = minetest.get_meta(pos)
 | 
				
			||||||
@@ -399,37 +106,23 @@ minetest.register_node(":default:furnace_active", {
 | 
				
			|||||||
			if direction.y == 1 then
 | 
								if direction.y == 1 then
 | 
				
			||||||
				return inv:room_for_item("fuel", stack)
 | 
									return inv:room_for_item("fuel", stack)
 | 
				
			||||||
			else
 | 
								else
 | 
				
			||||||
				if meta:get_int("split_material_stacks") == 1 then
 | 
					 | 
				
			||||||
					stack = stack:peek_item(1)
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
				return inv:room_for_item("src", stack)
 | 
									return inv:room_for_item("src", stack)
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end,
 | 
							end,
 | 
				
			||||||
		input_inventory = "dst",
 | 
							input_inventory = "dst",
 | 
				
			||||||
		connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
 | 
							connect_sides = {left = 1, right = 1, back = 1, front = 1, bottom = 1, top = 1}
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
					 | 
				
			||||||
	light_source = 8,
 | 
					 | 
				
			||||||
	drop = "default:furnace",
 | 
					 | 
				
			||||||
	legacy_facedir_simple = true,
 | 
					 | 
				
			||||||
	is_ground_content = false,
 | 
					 | 
				
			||||||
	sounds = default.node_sound_stone_defaults(),
 | 
					 | 
				
			||||||
	on_timer = furnace_node_timer,
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	can_dig = can_dig,
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	allow_metadata_inventory_put = allow_metadata_inventory_put,
 | 
					 | 
				
			||||||
	allow_metadata_inventory_move = allow_metadata_inventory_move,
 | 
					 | 
				
			||||||
	allow_metadata_inventory_take = allow_metadata_inventory_take,
 | 
					 | 
				
			||||||
	on_receive_fields = function(pos, formname, fields, sender)
 | 
					 | 
				
			||||||
		if not pipeworks.may_configure(pos, sender) then return end
 | 
					 | 
				
			||||||
		fs_helpers.on_receive_fields(pos, fields)
 | 
					 | 
				
			||||||
		local meta = minetest.get_meta(pos)
 | 
					 | 
				
			||||||
		local formspec = active_formspec(0, 0, pos, meta)
 | 
					 | 
				
			||||||
		meta:set_string("formspec", formspec)
 | 
					 | 
				
			||||||
	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 = pipeworks.on_rotate
 | 
						on_rotate = pipeworks.on_rotate
 | 
				
			||||||
})
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if minetest.get_modpath("default") then
 | 
				
			||||||
 | 
						minetest.override_item("default:furnace", override)
 | 
				
			||||||
 | 
						minetest.override_item("default:furnace_active", override_active)
 | 
				
			||||||
 | 
					elseif minetest.get_modpath("hades_furnaces") then
 | 
				
			||||||
 | 
						minetest.override_item("hades_furnaces:furnace", override)
 | 
				
			||||||
 | 
						minetest.override_item("hades_furnaces:furnace_active", override_active)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										302
									
								
								crafts.lua
									
									
									
									
									
								
							
							
						
						
									
										302
									
								
								crafts.lua
									
									
									
									
									
								
							@@ -1,11 +1,78 @@
 | 
				
			|||||||
 | 
					local materials = {
 | 
				
			||||||
 | 
						stone = "default:stone",
 | 
				
			||||||
 | 
						desert_stone = "default:desert_stone",
 | 
				
			||||||
 | 
						desert_sand = "default:desert_sand",
 | 
				
			||||||
 | 
						chest = "default:chest",
 | 
				
			||||||
 | 
						copper_ingot = "default:copper_ingot",
 | 
				
			||||||
 | 
						steel_ingot = "default:steel_ingot",
 | 
				
			||||||
 | 
						gold_ingot = "default:gold_ingot",
 | 
				
			||||||
 | 
						mese = "default:mese",
 | 
				
			||||||
 | 
						mese_crystal = "default:mese_crystal",
 | 
				
			||||||
 | 
						mese_crystal_fragment = "default:mese_crystal_fragment",
 | 
				
			||||||
 | 
						teleporter = "default:mese",
 | 
				
			||||||
 | 
						glass = "default:glass",
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if minetest.get_modpath("mcl_core") then
 | 
				
			||||||
 | 
						materials = {
 | 
				
			||||||
 | 
							stone = "mcl_core:stone",
 | 
				
			||||||
 | 
							desert_stone = "mcl_core:sandstone2",
 | 
				
			||||||
 | 
							desert_sand = "mcl_core:sand",
 | 
				
			||||||
 | 
							chest = "mcl_chests:chest_small",
 | 
				
			||||||
 | 
							steel_ingot = "mcl_core:iron_ingot",
 | 
				
			||||||
 | 
							gold_ingot = "mcl_core:gold_ingot",
 | 
				
			||||||
 | 
							mese = "default:mese",
 | 
				
			||||||
 | 
							mese_crystal = "default:mese_crystal",
 | 
				
			||||||
 | 
							mese_crystal_fragment = "mesecons:redstone",
 | 
				
			||||||
 | 
							teleporter = "default:mese",
 | 
				
			||||||
 | 
							-- Use iron where no equivalent
 | 
				
			||||||
 | 
							copper_ingot = "mcl_core:iron_ingot",
 | 
				
			||||||
 | 
							glass = "default:glass",
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then
 | 
				
			||||||
 | 
						materials = {
 | 
				
			||||||
 | 
							stone = "fl_stone:stone",
 | 
				
			||||||
 | 
							desert_stone = "fl_stone:desert_stone",
 | 
				
			||||||
 | 
							desert_sand = "fl_stone:desert_sand",
 | 
				
			||||||
 | 
							chest = "fl_storage:wood_chest",
 | 
				
			||||||
 | 
							steel_ingot = "fl_ores:iron_ingot",
 | 
				
			||||||
 | 
							gold_ingot = "fl_ores:gold_ingot",
 | 
				
			||||||
 | 
							mese = "fl_ores:iron_ingot",
 | 
				
			||||||
 | 
							mese_crystal = "fl_ores:iron_ingot",
 | 
				
			||||||
 | 
							mese_crystal_fragment = "fl_ores:iron_ingot",
 | 
				
			||||||
 | 
							teleporter = "fl_ores:iron_ingot",
 | 
				
			||||||
 | 
							copper_ingot = "fl_ores:copper_ingot",
 | 
				
			||||||
 | 
							glass = "fl_glass:framed_glass",
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					elseif minetest.get_modpath("hades_core") then
 | 
				
			||||||
 | 
						materials = {
 | 
				
			||||||
 | 
							stone = "hades_core:stone",
 | 
				
			||||||
 | 
							desert_stone = "hades_core:stone_baked",
 | 
				
			||||||
 | 
							desert_sand = "hades_core:volcanic_sand",
 | 
				
			||||||
 | 
							chest = "hades_chests:chest";
 | 
				
			||||||
 | 
							steel_ingot = "hades_core:steel_ingot",
 | 
				
			||||||
 | 
							gold_ingot = "hades_core:gold_ingot",
 | 
				
			||||||
 | 
							mese = "hades_core:mese",
 | 
				
			||||||
 | 
							mese_crystal = "hades_core:mese_crystal",
 | 
				
			||||||
 | 
							mese_crystal_fragment = "hades_core:mese_crystal_fragment",
 | 
				
			||||||
 | 
							teleporter = "hades_materials:teleporter_device",
 | 
				
			||||||
 | 
							copper_ingot = "hades_core:copper_ingot",
 | 
				
			||||||
 | 
							tin_ingot = "hades_core:tin_ingot",
 | 
				
			||||||
 | 
							glass = "hades_core:glass",
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					  if minetest.get_modpath("hades_default") then
 | 
				
			||||||
 | 
							materials.desert_sand = "hades_default:desert_sand"
 | 
				
			||||||
 | 
					  end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Crafting recipes for pipes
 | 
					-- Crafting recipes for pipes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_craft( {
 | 
					minetest.register_craft( {
 | 
				
			||||||
	output = "pipeworks:pipe_1_empty 12",
 | 
						output = "pipeworks:pipe_1_empty 12",
 | 
				
			||||||
	recipe = {
 | 
						recipe = {
 | 
				
			||||||
                { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
								{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
 | 
				
			||||||
			{ "", "", "" },
 | 
								{ "", "", "" },
 | 
				
			||||||
                { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
 | 
								{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -25,12 +92,12 @@ minetest.register_craft( {
 | 
				
			|||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_craft( {
 | 
					minetest.register_craft( {
 | 
				
			||||||
	output = "pipeworks:entry_panel_empty 2",
 | 
					output = "pipeworks:entry_panel_empty 2",
 | 
				
			||||||
	recipe = {
 | 
					recipe = {
 | 
				
			||||||
		{ "", "default:steel_ingot", "" },
 | 
						{ "", materials.steel_ingot, "" },
 | 
				
			||||||
	{ "", "pipeworks:pipe_1_empty", "" },
 | 
						{ "", "pipeworks:pipe_1_empty", "" },
 | 
				
			||||||
		{ "", "default:steel_ingot", "" },
 | 
						{ "", materials.steel_ingot, "" },
 | 
				
			||||||
	},
 | 
					},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Various ancillary pipe devices
 | 
					-- Various ancillary pipe devices
 | 
				
			||||||
@@ -38,9 +105,9 @@ minetest.register_craft( {
 | 
				
			|||||||
minetest.register_craft( {
 | 
					minetest.register_craft( {
 | 
				
			||||||
	output = "pipeworks:pump_off 2",
 | 
						output = "pipeworks:pump_off 2",
 | 
				
			||||||
	recipe = {
 | 
						recipe = {
 | 
				
			||||||
                { "default:stone", "default:steel_ingot", "default:stone" },
 | 
								{ materials.stone, materials.steel_ingot, materials.stone },
 | 
				
			||||||
                { "default:copper_ingot", "default:mese_crystal_fragment", "default:copper_ingot" },
 | 
								{ materials.copper_ingot, materials.mese_crystal_fragment, materials.copper_ingot },
 | 
				
			||||||
                { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
 | 
								{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -48,26 +115,26 @@ minetest.register_craft( {
 | 
				
			|||||||
	output = "pipeworks:valve_off_empty 2",
 | 
						output = "pipeworks:valve_off_empty 2",
 | 
				
			||||||
	recipe = {
 | 
						recipe = {
 | 
				
			||||||
			{ "", "group:stick", "" },
 | 
								{ "", "group:stick", "" },
 | 
				
			||||||
                { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
								{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
 | 
				
			||||||
                { "", "default:steel_ingot", "" }
 | 
								{ "", materials.steel_ingot, "" }
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_craft( {
 | 
					minetest.register_craft( {
 | 
				
			||||||
	output = "pipeworks:storage_tank_0 2",
 | 
						output = "pipeworks:storage_tank_0 2",
 | 
				
			||||||
	recipe = {
 | 
						recipe = {
 | 
				
			||||||
                { "", "default:steel_ingot", "default:steel_ingot" },
 | 
								{ "", materials.steel_ingot, materials.steel_ingot },
 | 
				
			||||||
                { "default:steel_ingot", "default:glass", "default:steel_ingot" },
 | 
								{ materials.steel_ingot, materials.glass, materials.steel_ingot },
 | 
				
			||||||
                { "default:steel_ingot", "default:steel_ingot", "" }
 | 
								{ materials.steel_ingot, materials.steel_ingot, "" }
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_craft( {
 | 
					minetest.register_craft( {
 | 
				
			||||||
	output = "pipeworks:grating 2",
 | 
						output = "pipeworks:grating 2",
 | 
				
			||||||
	recipe = {
 | 
						recipe = {
 | 
				
			||||||
                { "default:steel_ingot", "", "default:steel_ingot" },
 | 
								{ materials.steel_ingot, "", materials.steel_ingot },
 | 
				
			||||||
			{ "", "pipeworks:pipe_1_empty", "" },
 | 
								{ "", "pipeworks:pipe_1_empty", "" },
 | 
				
			||||||
                { "default:steel_ingot", "", "default:steel_ingot" }
 | 
								{ materials.steel_ingot, "", materials.steel_ingot }
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -85,3 +152,204 @@ minetest.register_craft( {
 | 
				
			|||||||
			{ "pipeworks:pipe_1_empty" }
 | 
								{ "pipeworks:pipe_1_empty" }
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- injectors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					minetest.register_craft( {
 | 
				
			||||||
 | 
						output = "pipeworks:filter 2",
 | 
				
			||||||
 | 
						recipe = {
 | 
				
			||||||
 | 
								{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ "group:stick", materials.mese_crystal, "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					minetest.register_craft( {
 | 
				
			||||||
 | 
						output = "pipeworks:mese_filter 2",
 | 
				
			||||||
 | 
						recipe = {
 | 
				
			||||||
 | 
								{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ "group:stick", materials.mese, "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if minetest.get_modpath("digilines") then
 | 
				
			||||||
 | 
						minetest.register_craft( {
 | 
				
			||||||
 | 
							output = "pipeworks:digiline_filter 2",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ "group:stick", "digilines:wire_std_00000000", "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ materials.steel_ingot, materials.steel_ingot, "basic_materials:plastic_sheet" }
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- other
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					minetest.register_craft( {
 | 
				
			||||||
 | 
						output = "pipeworks:autocrafter 2",
 | 
				
			||||||
 | 
						recipe = {
 | 
				
			||||||
 | 
								{ materials.steel_ingot, materials.mese_crystal, materials.steel_ingot },
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", materials.steel_ingot, "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ materials.steel_ingot, materials.mese_crystal, materials.steel_ingot }
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					minetest.register_craft( {
 | 
				
			||||||
 | 
						output = "pipeworks:steel_block_embedded_tube 1",
 | 
				
			||||||
 | 
						recipe = {
 | 
				
			||||||
 | 
							{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
 | 
				
			||||||
 | 
							{ materials.steel_ingot, "pipeworks:tube_1", materials.steel_ingot },
 | 
				
			||||||
 | 
							{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot }
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					minetest.register_craft( {
 | 
				
			||||||
 | 
						output = "pipeworks:steel_pane_embedded_tube 1",
 | 
				
			||||||
 | 
						recipe = {
 | 
				
			||||||
 | 
							{ "", materials.steel_ingot, "" },
 | 
				
			||||||
 | 
							{ "", "pipeworks:tube_1", "" },
 | 
				
			||||||
 | 
							{ "", materials.steel_ingot, "" }
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					minetest.register_craft({
 | 
				
			||||||
 | 
						output = "pipeworks:trashcan",
 | 
				
			||||||
 | 
						recipe = {
 | 
				
			||||||
 | 
							{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
							{ materials.steel_ingot, "", materials.steel_ingot },
 | 
				
			||||||
 | 
							{ materials.steel_ingot, materials.steel_ingot, materials.steel_ingot },
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					minetest.register_craft( {
 | 
				
			||||||
 | 
						output = "pipeworks:teleport_tube_1 2",
 | 
				
			||||||
 | 
						recipe = {
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ materials.desert_stone, materials.teleporter, materials.desert_stone },
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
				
			||||||
 | 
						},
 | 
				
			||||||
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if pipeworks.enable_priority_tube then
 | 
				
			||||||
 | 
						minetest.register_craft( {
 | 
				
			||||||
 | 
							output = "pipeworks:priority_tube_1 6",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ materials.gold_ingot, "", materials.gold_ingot },
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if pipeworks.enable_accelerator_tube then
 | 
				
			||||||
 | 
						minetest.register_craft( {
 | 
				
			||||||
 | 
							output = "pipeworks:accelerator_tube_1 2",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ materials.mese_crystal_fragment, materials.steel_ingot, materials.mese_crystal_fragment },
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if pipeworks.enable_crossing_tube then
 | 
				
			||||||
 | 
						minetest.register_craft( {
 | 
				
			||||||
 | 
							output = "pipeworks:crossing_tube_1 5",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								{ "", "pipeworks:tube_1", "" },
 | 
				
			||||||
 | 
								{ "pipeworks:tube_1", "pipeworks:tube_1", "pipeworks:tube_1" },
 | 
				
			||||||
 | 
								{ "", "pipeworks:tube_1", "" }
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if pipeworks.enable_one_way_tube then
 | 
				
			||||||
 | 
						minetest.register_craft({
 | 
				
			||||||
 | 
							output = "pipeworks:one_way_tube 2",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ "group:stick", materials.mese_crystal, "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if pipeworks.enable_mese_tube then
 | 
				
			||||||
 | 
						minetest.register_craft( {
 | 
				
			||||||
 | 
							output = "pipeworks:mese_tube_000000 2",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{ "", materials.mese_crystal, "" },
 | 
				
			||||||
 | 
								{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						minetest.register_craft( {
 | 
				
			||||||
 | 
							type = "shapeless",
 | 
				
			||||||
 | 
							output = "pipeworks:mese_tube_000000",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								"pipeworks:tube_1",
 | 
				
			||||||
 | 
								materials.mese_crystal_fragment,
 | 
				
			||||||
 | 
								materials.mese_crystal_fragment,
 | 
				
			||||||
 | 
								materials.mese_crystal_fragment,
 | 
				
			||||||
 | 
								materials.mese_crystal_fragment,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if pipeworks.enable_mese_sand_tube then
 | 
				
			||||||
 | 
						minetest.register_craft( {
 | 
				
			||||||
 | 
							output = "pipeworks:mese_sand_tube_1 2",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
				
			||||||
 | 
								{"group:sand",				 materials.mese_crystal,	   "group:sand" },
 | 
				
			||||||
 | 
								{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						minetest.register_craft( {
 | 
				
			||||||
 | 
							type = "shapeless",
 | 
				
			||||||
 | 
							output = "pipeworks:mese_sand_tube_1",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								"pipeworks:sand_tube_1",
 | 
				
			||||||
 | 
								materials.mese_crystal_fragment,
 | 
				
			||||||
 | 
								materials.mese_crystal_fragment,
 | 
				
			||||||
 | 
								materials.mese_crystal_fragment,
 | 
				
			||||||
 | 
								materials.mese_crystal_fragment,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if pipeworks.enable_deployer then
 | 
				
			||||||
 | 
						minetest.register_craft({
 | 
				
			||||||
 | 
							output = "pipeworks:deployer_off",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								{ "group:wood",	materials.chest,	"group:wood"	},
 | 
				
			||||||
 | 
								{ materials.stone, "mesecons:piston",  materials.stone },
 | 
				
			||||||
 | 
								{ materials.stone, "mesecons:mesecon", materials.stone },
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if pipeworks.enable_dispenser then
 | 
				
			||||||
 | 
						minetest.register_craft({
 | 
				
			||||||
 | 
							output = "pipeworks:dispenser_off",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								{ materials.desert_sand, materials.chest,	materials.desert_sand },
 | 
				
			||||||
 | 
								{ materials.stone,	   "mesecons:piston",  materials.stone	   },
 | 
				
			||||||
 | 
								{ materials.stone,	   "mesecons:mesecon", materials.stone	  },
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if pipeworks.enable_node_breaker then
 | 
				
			||||||
 | 
						minetest.register_craft({
 | 
				
			||||||
 | 
							output = "pipeworks:nodebreaker_off",
 | 
				
			||||||
 | 
							recipe = {
 | 
				
			||||||
 | 
								{ "basic_materials:gear_steel", "basic_materials:gear_steel",   "basic_materials:gear_steel"	},
 | 
				
			||||||
 | 
								{ materials.stone, "mesecons:piston",   materials.stone },
 | 
				
			||||||
 | 
								{ "group:wood",	"mesecons:mesecon",  "group:wood" },
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,18 +1,24 @@
 | 
				
			|||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local straight = function(pos, node, velocity, stack) return {velocity} end
 | 
					local straight = function(pos, node, velocity, stack) return {velocity} end
 | 
				
			||||||
 | 
					local steel_tex = "[combine:16x16^[noalpha^[colorize:#D3D3D3"
 | 
				
			||||||
 | 
					if minetest.get_modpath("default") then steel_tex = "default_steel_block.png" end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_node("pipeworks:steel_block_embedded_tube", {
 | 
					minetest.register_node("pipeworks:steel_block_embedded_tube", {
 | 
				
			||||||
	description = "Airtight steelblock embedded tube",
 | 
						description = S("Airtight steelblock embedded tube"),
 | 
				
			||||||
	tiles = {
 | 
						tiles = {
 | 
				
			||||||
		"default_steel_block.png", "default_steel_block.png",
 | 
							steel_tex, steel_tex,
 | 
				
			||||||
		"default_steel_block.png", "default_steel_block.png",
 | 
							steel_tex, steel_tex,
 | 
				
			||||||
		"default_steel_block.png^pipeworks_tube_connection_metallic.png",
 | 
							steel_tex .. "^pipeworks_tube_connection_metallic.png",
 | 
				
			||||||
		"default_steel_block.png^pipeworks_tube_connection_metallic.png",
 | 
							steel_tex .. "^pipeworks_tube_connection_metallic.png",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
	groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1},
 | 
						groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2},
 | 
				
			||||||
	legacy_facedir_simple = true,
 | 
						legacy_facedir_simple = true,
 | 
				
			||||||
	sounds = default.node_sound_stone_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_stone_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	tube = {
 | 
						tube = {
 | 
				
			||||||
		connect_sides = {front = 1, back = 1,},
 | 
							connect_sides = {front = 1, back = 1,},
 | 
				
			||||||
		priority = 50,
 | 
							priority = 50,
 | 
				
			||||||
@@ -26,15 +32,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( {
 | 
					 | 
				
			||||||
	output = "pipeworks:steel_block_embedded_tube 1",
 | 
					 | 
				
			||||||
	recipe = {
 | 
					 | 
				
			||||||
		{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
					 | 
				
			||||||
		{ "default:steel_ingot", "pipeworks:tube_1", "default:steel_ingot" },
 | 
					 | 
				
			||||||
		{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
local pane_box = {
 | 
					local pane_box = {
 | 
				
			||||||
	type = "fixed",
 | 
						type = "fixed",
 | 
				
			||||||
@@ -43,24 +41,32 @@ 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 = "Airtight panel embedded tube ",
 | 
						description = S("Airtight panel embedded tube"),
 | 
				
			||||||
	tiles = {
 | 
						tiles = {
 | 
				
			||||||
		"pipeworks_pane_embedded_tube_sides.png^[transformR90",
 | 
							pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png^[transformR90"),
 | 
				
			||||||
		"pipeworks_pane_embedded_tube_sides.png^[transformR90",
 | 
							pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png^[transformR90"),
 | 
				
			||||||
		"pipeworks_pane_embedded_tube_sides.png",
 | 
							pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png"),
 | 
				
			||||||
		"pipeworks_pane_embedded_tube_sides.png",
 | 
							pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_sides.png"),
 | 
				
			||||||
		"pipeworks_pane_embedded_tube_ends.png", "pipeworks_pane_embedded_tube_ends.png",
 | 
							pipeworks.make_tube_tile("pipeworks_pane_embedded_tube_ends.png"),
 | 
				
			||||||
 | 
							pipeworks.make_tube_tile("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,
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
	groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1},
 | 
						groups = {cracky=1, oddly_breakable_by_hand = 1, tubedevice = 1, dig_glass = 2},
 | 
				
			||||||
	legacy_facedir_simple = true,
 | 
						legacy_facedir_simple = true,
 | 
				
			||||||
	sounds = default.node_sound_stone_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_stone_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	tube = {
 | 
						tube = {
 | 
				
			||||||
		connect_sides = {front = 1, back = 1,},
 | 
							connect_sides = {front = 1, back = 1,},
 | 
				
			||||||
		priority = 50,
 | 
							priority = 50,
 | 
				
			||||||
@@ -74,12 +80,4 @@ 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( {
 | 
					 | 
				
			||||||
	output = "pipeworks:steel_pane_embedded_tube 1",
 | 
					 | 
				
			||||||
	recipe = {
 | 
					 | 
				
			||||||
		{ "", "default:steel_ingot", "" },
 | 
					 | 
				
			||||||
		{ "", "pipeworks:tube_1", "" },
 | 
					 | 
				
			||||||
		{ "", "default:steel_ingot", "" }
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,6 +27,8 @@ local settings = {
 | 
				
			|||||||
	enable_cyclic_mode = true,
 | 
						enable_cyclic_mode = true,
 | 
				
			||||||
	drop_on_routing_fail = false,
 | 
						drop_on_routing_fail = false,
 | 
				
			||||||
	delete_item_on_clearobject = true,
 | 
						delete_item_on_clearobject = true,
 | 
				
			||||||
 | 
						use_real_entities = true,
 | 
				
			||||||
 | 
						entity_update_interval = 0,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pipeworks.toggles = {}
 | 
					pipeworks.toggles = {}
 | 
				
			||||||
@@ -62,10 +64,9 @@ pipeworks.toggles.finite_water = nil
 | 
				
			|||||||
for name, value in pairs(settings) do
 | 
					for name, value in pairs(settings) do
 | 
				
			||||||
	local setting_type = type(value)
 | 
						local setting_type = type(value)
 | 
				
			||||||
	if setting_type == "boolean" then
 | 
						if setting_type == "boolean" then
 | 
				
			||||||
		pipeworks[name] = minetest.settings:get_bool(prefix..name)
 | 
							pipeworks[name] = minetest.settings:get_bool(prefix..name, value)
 | 
				
			||||||
		if pipeworks[name] == nil then
 | 
						elseif setting_type == "number" then
 | 
				
			||||||
			pipeworks[name] = value
 | 
							pipeworks[name] = tonumber(minetest.settings:get(prefix..name) or value)
 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		pipeworks[name] = value
 | 
							pipeworks[name] = value
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +0,0 @@
 | 
				
			|||||||
default
 | 
					 | 
				
			||||||
basic_materials
 | 
					 | 
				
			||||||
screwdriver
 | 
					 | 
				
			||||||
mesecons?
 | 
					 | 
				
			||||||
mesecons_mvps?
 | 
					 | 
				
			||||||
digilines?
 | 
					 | 
				
			||||||
@@ -1 +0,0 @@
 | 
				
			|||||||
This mod uses mesh nodes and nodeboxes to supply a complete set of 3D pipes and tubes, along with devices that work with them.
 | 
					 | 
				
			||||||
							
								
								
									
										193
									
								
								devices.lua
									
									
									
									
									
								
							
							
						
						
									
										193
									
								
								devices.lua
									
									
									
									
									
								
							@@ -1,5 +1,8 @@
 | 
				
			|||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
local new_flow_logic_register = pipeworks.flowables.register
 | 
					local new_flow_logic_register = pipeworks.flowables.register
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local polys = ""
 | 
					local polys = ""
 | 
				
			||||||
if pipeworks.enable_lowpoly then polys = "_lowpoly" end
 | 
					if pipeworks.enable_lowpoly then polys = "_lowpoly" end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -9,7 +12,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)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -27,7 +30,9 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing)
 | 
				
			|||||||
		if (not placer:get_player_control().sneak)
 | 
							if (not placer:get_player_control().sneak)
 | 
				
			||||||
		  and minetest.registered_nodes[node.name]
 | 
							  and minetest.registered_nodes[node.name]
 | 
				
			||||||
		  and minetest.registered_nodes[node.name].on_rightclick then
 | 
							  and minetest.registered_nodes[node.name].on_rightclick then
 | 
				
			||||||
			minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under, node, placer, itemstack)
 | 
								minetest.registered_nodes[node.name].on_rightclick(pointed_thing.under,
 | 
				
			||||||
 | 
									node, placer, itemstack, pointed_thing)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			local pitch = placer:get_look_pitch()
 | 
								local pitch = placer:get_look_pitch()
 | 
				
			||||||
@@ -35,9 +40,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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -104,6 +107,7 @@ if minetest.get_modpath("mesecons") then
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--[[
 | 
				
			||||||
local pipes_devicelist = {
 | 
					local pipes_devicelist = {
 | 
				
			||||||
	"pump",
 | 
						"pump",
 | 
				
			||||||
	"valve",
 | 
						"valve",
 | 
				
			||||||
@@ -119,30 +123,34 @@ 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, dig_generic = 4}
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1}
 | 
							dgroups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4}
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local pumpname = "pipeworks:pump_"..states[s]
 | 
						local pumpname = "pipeworks:pump_"..states[s]
 | 
				
			||||||
	minetest.register_node(pumpname, {
 | 
						minetest.register_node(pumpname, {
 | 
				
			||||||
		description = "Pump/Intake Module",
 | 
							description = S("Pump/Intake Module"),
 | 
				
			||||||
		drawtype = "mesh",
 | 
							drawtype = "mesh",
 | 
				
			||||||
		mesh = "pipeworks_pump"..polys..".obj",
 | 
							mesh = "pipeworks_pump"..polys..".obj",
 | 
				
			||||||
		tiles = { "pipeworks_pump_"..states[s]..".png" },
 | 
							tiles = { "pipeworks_pump_"..states[s]..".png" },
 | 
				
			||||||
 | 
							use_texture_alpha = texture_alpha_mode and "clip" or true,
 | 
				
			||||||
		paramtype = "light",
 | 
							paramtype = "light",
 | 
				
			||||||
		paramtype2 = "facedir",
 | 
							paramtype2 = "facedir",
 | 
				
			||||||
		groups = dgroups,
 | 
							groups = dgroups,
 | 
				
			||||||
		sounds = default.node_sound_wood_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		walkable = true,
 | 
							walkable = true,
 | 
				
			||||||
		pipe_connections = { top = 1 },
 | 
							pipe_connections = { top = 1 },
 | 
				
			||||||
		after_place_node = function(pos)
 | 
							after_place_node = function(pos)
 | 
				
			||||||
@@ -164,7 +172,7 @@ for s in ipairs(states) do
 | 
				
			|||||||
			local fdir = node.param2
 | 
								local fdir = node.param2
 | 
				
			||||||
			minetest.swap_node(pos, { name = "pipeworks:pump_"..states[3-s], param2 = fdir })
 | 
								minetest.swap_node(pos, { name = "pipeworks:pump_"..states[3-s], param2 = fdir })
 | 
				
			||||||
		end,
 | 
							end,
 | 
				
			||||||
		on_rotate = screwdriver.rotate_simple
 | 
							on_rotate = screwdriver and screwdriver.rotate_simple or nil
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	-- FIXME: this currently assumes that pumps can only rotate around the fixed axis pointing Y+.
 | 
						-- FIXME: this currently assumes that pumps can only rotate around the fixed axis pointing Y+.
 | 
				
			||||||
@@ -178,7 +186,7 @@ for s in ipairs(states) do
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	local nodename_valve_empty = "pipeworks:valve_"..states[s].."_empty"
 | 
						local nodename_valve_empty = "pipeworks:valve_"..states[s].."_empty"
 | 
				
			||||||
	minetest.register_node(nodename_valve_empty, {
 | 
						minetest.register_node(nodename_valve_empty, {
 | 
				
			||||||
		description = "Valve",
 | 
							description = S("Valve"),
 | 
				
			||||||
		drawtype = "mesh",
 | 
							drawtype = "mesh",
 | 
				
			||||||
		mesh = "pipeworks_valve_"..states[s]..polys..".obj",
 | 
							mesh = "pipeworks_valve_"..states[s]..polys..".obj",
 | 
				
			||||||
		tiles = { "pipeworks_valve.png" },
 | 
							tiles = { "pipeworks_valve.png" },
 | 
				
			||||||
@@ -194,7 +202,9 @@ for s in ipairs(states) do
 | 
				
			|||||||
			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,
 | 
				
			||||||
		sounds = default.node_sound_wood_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		walkable = true,
 | 
							walkable = true,
 | 
				
			||||||
		on_place = pipeworks.rotate_on_place,
 | 
							on_place = pipeworks.rotate_on_place,
 | 
				
			||||||
		after_dig_node = function(pos)
 | 
							after_dig_node = function(pos)
 | 
				
			||||||
@@ -221,10 +231,12 @@ 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, {
 | 
				
			||||||
	description = "Valve",
 | 
						description = S("Valve"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_valve_on"..polys..".obj",
 | 
						mesh = "pipeworks_valve_on"..polys..".obj",
 | 
				
			||||||
	tiles = { "pipeworks_valve.png" },
 | 
						tiles = { "pipeworks_valve.png" },
 | 
				
			||||||
@@ -239,8 +251,10 @@ minetest.register_node(nodename_valve_loaded, {
 | 
				
			|||||||
		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, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	on_place = pipeworks.rotate_on_place,
 | 
						on_place = pipeworks.rotate_on_place,
 | 
				
			||||||
	after_dig_node = function(pos)
 | 
						after_dig_node = function(pos)
 | 
				
			||||||
@@ -272,7 +286,7 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_valve_loaded, true
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- FIXME: should this do anything useful in the new flow logic?
 | 
					-- FIXME: should this do anything useful in the new flow logic?
 | 
				
			||||||
minetest.register_node("pipeworks:grating", {
 | 
					minetest.register_node("pipeworks:grating", {
 | 
				
			||||||
	description = "Decorative grating",
 | 
						description = S("Decorative grating"),
 | 
				
			||||||
	tiles = {
 | 
						tiles = {
 | 
				
			||||||
		"pipeworks_grating_top.png",
 | 
							"pipeworks_grating_top.png",
 | 
				
			||||||
		"pipeworks_grating_sides.png",
 | 
							"pipeworks_grating_sides.png",
 | 
				
			||||||
@@ -281,6 +295,7 @@ minetest.register_node("pipeworks:grating", {
 | 
				
			|||||||
		"pipeworks_grating_sides.png",
 | 
							"pipeworks_grating_sides.png",
 | 
				
			||||||
		"pipeworks_grating_sides.png"
 | 
							"pipeworks_grating_sides.png"
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						use_texture_alpha = texture_alpha_mode and "clip" or true,
 | 
				
			||||||
	drawtype = "nodebox",
 | 
						drawtype = "nodebox",
 | 
				
			||||||
	node_box = {
 | 
						node_box = {
 | 
				
			||||||
		type = "fixed",
 | 
							type = "fixed",
 | 
				
			||||||
@@ -288,8 +303,10 @@ minetest.register_node("pipeworks:grating", {
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
	sunlight_propagates = true,
 | 
						sunlight_propagates = true,
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	groups = {snappy=3, pipe=1},
 | 
						groups = {snappy=3, pipe=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	pipe_connections = { top = 1 },
 | 
						pipe_connections = { top = 1 },
 | 
				
			||||||
	after_place_node = function(pos)
 | 
						after_place_node = function(pos)
 | 
				
			||||||
@@ -300,20 +317,23 @@ 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local nodename_spigot_empty = "pipeworks:spigot"
 | 
					local nodename_spigot_empty = "pipeworks:spigot"
 | 
				
			||||||
minetest.register_node(nodename_spigot_empty, {
 | 
					minetest.register_node(nodename_spigot_empty, {
 | 
				
			||||||
	description = "Spigot outlet",
 | 
						description = S("Spigot outlet"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_spigot"..polys..".obj",
 | 
						mesh = "pipeworks_spigot"..polys..".obj",
 | 
				
			||||||
	tiles = { "pipeworks_spigot.png" },
 | 
						tiles = { "pipeworks_spigot.png" },
 | 
				
			||||||
	sunlight_propagates = true,
 | 
						sunlight_propagates = true,
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
	groups = {snappy=3, pipe=1},
 | 
						groups = {snappy=3, pipe=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	pipe_connections = { left=1, right=1, front=1, back=1,
 | 
						pipe_connections = { left=1, right=1, front=1, back=1,
 | 
				
			||||||
						 left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 },
 | 
											 left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 },
 | 
				
			||||||
@@ -336,26 +356,21 @@ minetest.register_node(nodename_spigot_empty, {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
local nodename_spigot_loaded = "pipeworks:spigot_pouring"
 | 
					local nodename_spigot_loaded = "pipeworks:spigot_pouring"
 | 
				
			||||||
minetest.register_node(nodename_spigot_loaded, {
 | 
					minetest.register_node(nodename_spigot_loaded, {
 | 
				
			||||||
	description = "Spigot outlet",
 | 
						description = S("Spigot outlet"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_spigot_pouring"..polys..".obj",
 | 
						mesh = "pipeworks_spigot_pouring"..polys..".obj",
 | 
				
			||||||
	tiles = {
 | 
						tiles = {
 | 
				
			||||||
		{
 | 
							minetest.registered_nodes[pipeworks.liquids.water.source].tiles[1],
 | 
				
			||||||
			name = "default_water_flowing_animated.png",
 | 
					 | 
				
			||||||
			animation = {
 | 
					 | 
				
			||||||
				type = "vertical_frames",
 | 
					 | 
				
			||||||
				aspect_w = 16,
 | 
					 | 
				
			||||||
				aspect_h = 16,
 | 
					 | 
				
			||||||
				length = 0.8,
 | 
					 | 
				
			||||||
			},
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
		{ name = "pipeworks_spigot.png" }
 | 
							{ name = "pipeworks_spigot.png" }
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
 | 
						use_texture_alpha = texture_alpha_mode and "blend" or true,
 | 
				
			||||||
	sunlight_propagates = true,
 | 
						sunlight_propagates = true,
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
						groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	pipe_connections = { left=1, right=1, front=1, back=1,
 | 
						pipe_connections = { left=1, right=1, front=1, back=1,
 | 
				
			||||||
						 left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 },
 | 
											 left_param2 = 3, right_param2 = 1, front_param2 = 2, back_param2 = 0 },
 | 
				
			||||||
@@ -377,6 +392,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)
 | 
				
			||||||
@@ -402,14 +419,16 @@ local panel_cbox = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
local nodename_panel_empty = "pipeworks:entry_panel_empty"
 | 
					local nodename_panel_empty = "pipeworks:entry_panel_empty"
 | 
				
			||||||
minetest.register_node(nodename_panel_empty, {
 | 
					minetest.register_node(nodename_panel_empty, {
 | 
				
			||||||
	description = "Airtight Pipe entry/exit",
 | 
						description = S("Airtight Pipe entry/exit"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_entry_panel"..polys..".obj",
 | 
						mesh = "pipeworks_entry_panel"..polys..".obj",
 | 
				
			||||||
	tiles = { "pipeworks_entry_panel.png" },
 | 
						tiles = { "pipeworks_entry_panel.png" },
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
	groups = {snappy=3, pipe=1},
 | 
						groups = {snappy=3, pipe=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	on_place = pipeworks.rotate_on_place,
 | 
						on_place = pipeworks.rotate_on_place,
 | 
				
			||||||
	after_dig_node = function(pos)
 | 
						after_dig_node = function(pos)
 | 
				
			||||||
@@ -422,14 +441,16 @@ minetest.register_node(nodename_panel_empty, {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
local nodename_panel_loaded = "pipeworks:entry_panel_loaded"
 | 
					local nodename_panel_loaded = "pipeworks:entry_panel_loaded"
 | 
				
			||||||
minetest.register_node(nodename_panel_loaded, {
 | 
					minetest.register_node(nodename_panel_loaded, {
 | 
				
			||||||
	description = "Airtight Pipe entry/exit",
 | 
						description = S("Airtight Pipe entry/exit"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_entry_panel"..polys..".obj",
 | 
						mesh = "pipeworks_entry_panel"..polys..".obj",
 | 
				
			||||||
	tiles = { "pipeworks_entry_panel.png" },
 | 
						tiles = { "pipeworks_entry_panel.png" },
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
						groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	on_place = pipeworks.rotate_on_place,
 | 
						on_place = pipeworks.rotate_on_place,
 | 
				
			||||||
	after_dig_node = function(pos)
 | 
						after_dig_node = function(pos)
 | 
				
			||||||
@@ -440,6 +461,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)
 | 
				
			||||||
@@ -448,15 +472,17 @@ new_flow_logic_register.directional_horizonal_rotate(nodename_panel_loaded, true
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
local nodename_sensor_empty = "pipeworks:flow_sensor_empty"
 | 
					local nodename_sensor_empty = "pipeworks:flow_sensor_empty"
 | 
				
			||||||
minetest.register_node(nodename_sensor_empty, {
 | 
					minetest.register_node(nodename_sensor_empty, {
 | 
				
			||||||
	description = "Flow Sensor",
 | 
						description = S("Flow Sensor"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_flow_sensor"..polys..".obj",
 | 
						mesh = "pipeworks_flow_sensor"..polys..".obj",
 | 
				
			||||||
	tiles = { "pipeworks_flow_sensor_off.png" },
 | 
						tiles = { "pipeworks_flow_sensor_off.png" },
 | 
				
			||||||
	sunlight_propagates = true,
 | 
						sunlight_propagates = true,
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
	groups = {snappy=3, pipe=1},
 | 
						groups = {snappy=3, pipe=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	on_place = pipeworks.rotate_on_place,
 | 
						on_place = pipeworks.rotate_on_place,
 | 
				
			||||||
	after_dig_node = function(pos)
 | 
						after_dig_node = function(pos)
 | 
				
			||||||
@@ -464,7 +490,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 = {
 | 
				
			||||||
@@ -487,15 +513,17 @@ minetest.register_node(nodename_sensor_empty, {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
local nodename_sensor_loaded = "pipeworks:flow_sensor_loaded"
 | 
					local nodename_sensor_loaded = "pipeworks:flow_sensor_loaded"
 | 
				
			||||||
minetest.register_node(nodename_sensor_loaded, {
 | 
					minetest.register_node(nodename_sensor_loaded, {
 | 
				
			||||||
	description = "Flow sensor (on)",
 | 
						description = S("Flow sensor (on)"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_flow_sensor"..polys..".obj",
 | 
						mesh = "pipeworks_flow_sensor"..polys..".obj",
 | 
				
			||||||
	tiles = { "pipeworks_flow_sensor_on.png" },
 | 
						tiles = { "pipeworks_flow_sensor_on.png" },
 | 
				
			||||||
	sunlight_propagates = true,
 | 
						sunlight_propagates = true,
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
						groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	on_place = pipeworks.rotate_on_place,
 | 
						on_place = pipeworks.rotate_on_place,
 | 
				
			||||||
	after_dig_node = function(pos)
 | 
						after_dig_node = function(pos)
 | 
				
			||||||
@@ -503,7 +531,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 = {
 | 
				
			||||||
@@ -524,6 +552,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
 | 
				
			||||||
@@ -536,18 +566,18 @@ new_flow_logic_register.transition_simple_set(sensor_pressure_set, { mesecons=pi
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-- TODO flow-logic-stub: these don't currently do anything under the new flow logic.
 | 
					-- TODO flow-logic-stub: these don't currently do anything under the new flow logic.
 | 
				
			||||||
for fill = 0, 10 do
 | 
					for fill = 0, 10 do
 | 
				
			||||||
	local filldesc="empty"
 | 
						local filldesc=S("empty")
 | 
				
			||||||
	local sgroups = {snappy=3, pipe=1, tankfill=fill+1}
 | 
						local sgroups = {snappy=3, pipe=1, tankfill=fill+1, dig_generic = 4}
 | 
				
			||||||
	local image = nil
 | 
						local image = nil
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if fill ~= 0 then
 | 
						if fill ~= 0 then
 | 
				
			||||||
		filldesc=fill.."0% full"
 | 
							filldesc=S("@1% full", 10*fill)
 | 
				
			||||||
		sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1}
 | 
							sgroups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4}
 | 
				
			||||||
		image = "pipeworks_storage_tank_fittings.png"
 | 
							image = "pipeworks_storage_tank_fittings.png"
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	minetest.register_node("pipeworks:expansion_tank_"..fill, {
 | 
						minetest.register_node("pipeworks:expansion_tank_"..fill, {
 | 
				
			||||||
		description = "Expansion Tank ("..filldesc..")... You hacker, you.",
 | 
							description = S("Expansion Tank (@1)", filldesc),
 | 
				
			||||||
		tiles = {
 | 
							tiles = {
 | 
				
			||||||
			"pipeworks_storage_tank_fittings.png",
 | 
								"pipeworks_storage_tank_fittings.png",
 | 
				
			||||||
			"pipeworks_storage_tank_fittings.png",
 | 
								"pipeworks_storage_tank_fittings.png",
 | 
				
			||||||
@@ -559,8 +589,10 @@ for fill = 0, 10 do
 | 
				
			|||||||
		inventory_image = image,
 | 
							inventory_image = image,
 | 
				
			||||||
		paramtype = "light",
 | 
							paramtype = "light",
 | 
				
			||||||
		paramtype2 = "facedir",
 | 
							paramtype2 = "facedir",
 | 
				
			||||||
		groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1},
 | 
							groups = {snappy=3, pipe=1, tankfill=fill+1, not_in_creative_inventory=1, dig_generic = 4},
 | 
				
			||||||
		sounds = default.node_sound_wood_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		walkable = true,
 | 
							walkable = true,
 | 
				
			||||||
		drop = "pipeworks:storage_tank_0",
 | 
							drop = "pipeworks:storage_tank_0",
 | 
				
			||||||
		pipe_connections = { top = 1, bottom = 1},
 | 
							pipe_connections = { top = 1, bottom = 1},
 | 
				
			||||||
@@ -575,7 +607,7 @@ for fill = 0, 10 do
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	minetest.register_node("pipeworks:storage_tank_"..fill, {
 | 
						minetest.register_node("pipeworks:storage_tank_"..fill, {
 | 
				
			||||||
		description = "Fluid Storage Tank ("..filldesc..")",
 | 
							description = S("Fluid Storage Tank (@1)", filldesc),
 | 
				
			||||||
		tiles = {
 | 
							tiles = {
 | 
				
			||||||
			"pipeworks_storage_tank_fittings.png",
 | 
								"pipeworks_storage_tank_fittings.png",
 | 
				
			||||||
			"pipeworks_storage_tank_fittings.png",
 | 
								"pipeworks_storage_tank_fittings.png",
 | 
				
			||||||
@@ -588,7 +620,9 @@ for fill = 0, 10 do
 | 
				
			|||||||
		paramtype = "light",
 | 
							paramtype = "light",
 | 
				
			||||||
		paramtype2 = "facedir",
 | 
							paramtype2 = "facedir",
 | 
				
			||||||
		groups = sgroups,
 | 
							groups = sgroups,
 | 
				
			||||||
		sounds = default.node_sound_wood_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		walkable = true,
 | 
							walkable = true,
 | 
				
			||||||
		drop = "pipeworks:storage_tank_0",
 | 
							drop = "pipeworks:storage_tank_0",
 | 
				
			||||||
		pipe_connections = { top = 1, bottom = 1},
 | 
							pipe_connections = { top = 1, bottom = 1},
 | 
				
			||||||
@@ -602,19 +636,22 @@ 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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local nodename_fountain_empty = "pipeworks:fountainhead"
 | 
					local nodename_fountain_empty = "pipeworks:fountainhead"
 | 
				
			||||||
minetest.register_node(nodename_fountain_empty, {
 | 
					minetest.register_node(nodename_fountain_empty, {
 | 
				
			||||||
	description = "Fountainhead",
 | 
						description = S("Fountainhead"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_fountainhead"..polys..".obj",
 | 
						mesh = "pipeworks_fountainhead"..polys..".obj",
 | 
				
			||||||
	tiles = { "pipeworks_fountainhead.png" },
 | 
						tiles = { "pipeworks_fountainhead.png" },
 | 
				
			||||||
	sunlight_propagates = true,
 | 
						sunlight_propagates = true,
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	groups = {snappy=3, pipe=1},
 | 
						groups = {snappy=3, pipe=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	pipe_connections = { bottom = 1 },
 | 
						pipe_connections = { bottom = 1 },
 | 
				
			||||||
	after_place_node = function(pos)
 | 
						after_place_node = function(pos)
 | 
				
			||||||
@@ -625,7 +662,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 = {
 | 
				
			||||||
@@ -638,17 +675,20 @@ 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, {
 | 
				
			||||||
	description = "Fountainhead",
 | 
						description = S("Fountainhead"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_fountainhead"..polys..".obj",
 | 
						mesh = "pipeworks_fountainhead"..polys..".obj",
 | 
				
			||||||
	tiles = { "pipeworks_fountainhead.png" },
 | 
						tiles = { "pipeworks_fountainhead.png" },
 | 
				
			||||||
	sunlight_propagates = true,
 | 
						sunlight_propagates = true,
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
						groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	pipe_connections = { bottom = 1 },
 | 
						pipe_connections = { bottom = 1 },
 | 
				
			||||||
	after_place_node = function(pos)
 | 
						after_place_node = function(pos)
 | 
				
			||||||
@@ -660,7 +700,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 = {
 | 
				
			||||||
@@ -691,14 +731,16 @@ local sp_cbox = {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
local nodename_sp_empty = "pipeworks:straight_pipe_empty"
 | 
					local nodename_sp_empty = "pipeworks:straight_pipe_empty"
 | 
				
			||||||
minetest.register_node(nodename_sp_empty, {
 | 
					minetest.register_node(nodename_sp_empty, {
 | 
				
			||||||
	description = "Straight-only Pipe",
 | 
						description = S("Straight-only Pipe"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_straight_pipe"..polys..".obj",
 | 
						mesh = "pipeworks_straight_pipe"..polys..".obj",
 | 
				
			||||||
	tiles = { "pipeworks_straight_pipe_empty.png" },
 | 
						tiles = { "pipeworks_straight_pipe_empty.png" },
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
	groups = {snappy=3, pipe=1},
 | 
						groups = {snappy=3, pipe=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	on_place = pipeworks.rotate_on_place,
 | 
						on_place = pipeworks.rotate_on_place,
 | 
				
			||||||
	after_dig_node = function(pos)
 | 
						after_dig_node = function(pos)
 | 
				
			||||||
@@ -706,19 +748,23 @@ minetest.register_node(nodename_sp_empty, {
 | 
				
			|||||||
	end,
 | 
						end,
 | 
				
			||||||
	selection_box = sp_cbox,
 | 
						selection_box = sp_cbox,
 | 
				
			||||||
	collision_box = sp_cbox,
 | 
						collision_box = sp_cbox,
 | 
				
			||||||
	on_rotate = pipeworks.fix_after_rotation
 | 
						on_rotate = pipeworks.fix_after_rotation,
 | 
				
			||||||
 | 
						check_for_pole = pipeworks.check_for_vert_pipe,
 | 
				
			||||||
 | 
						check_for_horiz_pole = pipeworks.check_for_horiz_pipe
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local nodename_sp_loaded = "pipeworks:straight_pipe_loaded"
 | 
					local nodename_sp_loaded = "pipeworks:straight_pipe_loaded"
 | 
				
			||||||
minetest.register_node(nodename_sp_loaded, {
 | 
					minetest.register_node(nodename_sp_loaded, {
 | 
				
			||||||
	description = "Straight-only Pipe",
 | 
						description = S("Straight-only Pipe"),
 | 
				
			||||||
	drawtype = "mesh",
 | 
						drawtype = "mesh",
 | 
				
			||||||
	mesh = "pipeworks_straight_pipe"..polys..".obj",
 | 
						mesh = "pipeworks_straight_pipe"..polys..".obj",
 | 
				
			||||||
	tiles = { "pipeworks_straight_pipe_loaded.png" },
 | 
						tiles = { "pipeworks_straight_pipe_loaded.png" },
 | 
				
			||||||
	paramtype = "light",
 | 
						paramtype = "light",
 | 
				
			||||||
	paramtype2 = "facedir",
 | 
						paramtype2 = "facedir",
 | 
				
			||||||
	groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
 | 
						groups = {snappy=3, pipe=1, not_in_creative_inventory=1, dig_generic = 4},
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	walkable = true,
 | 
						walkable = true,
 | 
				
			||||||
	on_place = pipeworks.rotate_on_place,
 | 
						on_place = pipeworks.rotate_on_place,
 | 
				
			||||||
	after_dig_node = function(pos)
 | 
						after_dig_node = function(pos)
 | 
				
			||||||
@@ -727,8 +773,11 @@ minetest.register_node(nodename_sp_loaded, {
 | 
				
			|||||||
	selection_box = sp_cbox,
 | 
						selection_box = sp_cbox,
 | 
				
			||||||
	collision_box = sp_cbox,
 | 
						collision_box = sp_cbox,
 | 
				
			||||||
	drop = "pipeworks:straight_pipe_empty",
 | 
						drop = "pipeworks:straight_pipe_empty",
 | 
				
			||||||
	on_rotate = pipeworks.fix_after_rotation
 | 
						on_rotate = pipeworks.fix_after_rotation,
 | 
				
			||||||
 | 
						check_for_pole = pipeworks.check_for_vert_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,60 +1,242 @@
 | 
				
			|||||||
 | 
					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 = data.wise_desc.." Filter-Injector"
 | 
						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
 | 
				
			||||||
		infotext = infotext .. " (slot #"..meta:get_int("slotseq_index").." next)"
 | 
							infotext = infotext .. " "..S("(slot #@1 next)", meta:get_int("slotseq_index"))
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	meta:set_string("infotext", infotext)
 | 
						meta:set_string("infotext", infotext)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function set_filter_formspec(data, meta)
 | 
					local function set_filter_formspec(data, meta)
 | 
				
			||||||
	local itemname = data.wise_desc.." Filter-Injector"
 | 
						local itemname = S("@1 Filter-Injector", data.wise_desc)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	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;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}]"..
 | 
				
			||||||
				{"Sequence slots by Priority",
 | 
								"button[4.8,1.3;1.5,1;set_channel;"..S("Set").."]"..
 | 
				
			||||||
				 "Sequence slots Randomly",
 | 
								fs_helpers.cycling_button(meta, "button[0.2,2.3;4.05,1", "slotseq_mode",
 | 
				
			||||||
				 "Sequence slots by Rotation"})..
 | 
									{S("Sequence slots by Priority"),
 | 
				
			||||||
			fs_helpers.cycling_button(meta, "button[4,2;4,1", "exmatch_mode",
 | 
									 S("Sequence slots Randomly"),
 | 
				
			||||||
				{"Exact match - off",
 | 
									 S("Sequence slots by Rotation")})..
 | 
				
			||||||
				 "Exact match - on "})
 | 
								fs_helpers.cycling_button(meta, "button[4.25,2.3;4.05,1", "exmatch_mode",
 | 
				
			||||||
 | 
									{S("Exact match - off"),
 | 
				
			||||||
 | 
									 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
 | 
				
			||||||
			exmatch_button =
 | 
								exmatch_button =
 | 
				
			||||||
				fs_helpers.cycling_button(meta, "button[4,3.5;4,1", "exmatch_mode",
 | 
									fs_helpers.cycling_button(meta, "button["..(10.2-(0.22)-4)..",4.5;4,1", "exmatch_mode",
 | 
				
			||||||
					{"Exact match - off",
 | 
										{S("Exact match - off"),
 | 
				
			||||||
					 "Exact match - on "})
 | 
										 S("Exact match - on")})
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
							local size = "10.2,11"
 | 
				
			||||||
		formspec = "size[8,8.5]"..
 | 
							local list_backgrounds = ""
 | 
				
			||||||
			"item_image[0,0;1,1;pipeworks:"..data.name.."]"..
 | 
							if minetest.get_modpath("i3") then
 | 
				
			||||||
			"label[1,0;"..minetest.formspec_escape(itemname).."]"..
 | 
								list_backgrounds = "style_type[box;colors=#666]"
 | 
				
			||||||
			"label[0,1;Prefer item types:]"..
 | 
								for i=0, 7 do
 | 
				
			||||||
			"list[context;main;0,1.5;8,2;]"..
 | 
									for j=0, 1 do
 | 
				
			||||||
			fs_helpers.cycling_button(meta, "button[0,3.5;4,1", "slotseq_mode",
 | 
										list_backgrounds = list_backgrounds .. "box[".. 0.22+(i*1.25) ..",".. 1.75+(j*1.25) ..";1,1;]"
 | 
				
			||||||
				{"Sequence slots by Priority",
 | 
									end
 | 
				
			||||||
				 "Sequence slots Randomly",
 | 
								end
 | 
				
			||||||
				 "Sequence slots by Rotation"})..
 | 
							end
 | 
				
			||||||
 | 
							formspec =
 | 
				
			||||||
 | 
								"formspec_version[2]"..
 | 
				
			||||||
 | 
								"size["..size.."]"..
 | 
				
			||||||
 | 
								pipeworks.fs_helpers.get_prepends(size)..
 | 
				
			||||||
 | 
								"item_image[0.22,0.22;1,1;pipeworks:"..data.name.."]"..
 | 
				
			||||||
 | 
								"label[1.22,0.72;"..minetest.formspec_escape(itemname).."]"..
 | 
				
			||||||
 | 
								"label[0.22,1.5;"..S("Prefer item types:").."]"..
 | 
				
			||||||
 | 
								list_backgrounds..
 | 
				
			||||||
 | 
								"list[context;main;0.22,1.75;8,2;]"..
 | 
				
			||||||
 | 
								fs_helpers.cycling_button(meta, "button[0.22,4.5;4,1", "slotseq_mode",
 | 
				
			||||||
 | 
									{S("Sequence slots by Priority"),
 | 
				
			||||||
 | 
									 S("Sequence slots Randomly"),
 | 
				
			||||||
 | 
									 S("Sequence slots by Rotation")})..
 | 
				
			||||||
			exmatch_button..
 | 
								exmatch_button..
 | 
				
			||||||
			"list[current_player;main;0,4.5;8,4;]" ..
 | 
								pipeworks.fs_helpers.get_inv(6)..
 | 
				
			||||||
			"listring[]"
 | 
								"listring[]"
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	meta:set_string("formspec", formspec)
 | 
						meta:set_string("formspec", formspec)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- todo SOON: this function has *way too many* parameters
 | 
					local function punch_filter(data, filtpos, filtnode, msg)
 | 
				
			||||||
local function grabAndFire(data,slotseq_mode,exmatch_mode,filtmeta,frominv,frominvname,frompos,fromnode,filterfor,fromtube,fromdef,dir,fakePlayer,all,digiline)
 | 
						local filtmeta = minetest.get_meta(filtpos)
 | 
				
			||||||
 | 
						local filtinv = filtmeta:get_inventory()
 | 
				
			||||||
 | 
						local owner = filtmeta:get_string("owner")
 | 
				
			||||||
 | 
						local fakePlayer = pipeworks.create_fake_player({
 | 
				
			||||||
 | 
							name = owner
 | 
				
			||||||
 | 
						})
 | 
				
			||||||
 | 
						local dir = pipeworks.facedir_to_right_dir(filtnode.param2)
 | 
				
			||||||
 | 
						local frompos = vector.subtract(filtpos, dir)
 | 
				
			||||||
 | 
						local fromnode = minetest.get_node(frompos)
 | 
				
			||||||
 | 
						if not fromnode then return end
 | 
				
			||||||
 | 
						local fromdef = minetest.registered_nodes[fromnode.name]
 | 
				
			||||||
 | 
						if not fromdef or not fromdef.tube then return end
 | 
				
			||||||
 | 
						local fromtube = table.copy(fromdef.tube)
 | 
				
			||||||
 | 
						local input_special_cases = {
 | 
				
			||||||
 | 
							["technic:mv_electric_furnace"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_electric_furnace_active"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_alloy_furnace"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_alloy_furnace_active"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_centrifuge"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_centrifuge_active"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_compressor"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_compressor_active"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_extractor"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_extractor_active"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_grinder"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_grinder_active"] = "dst",
 | 
				
			||||||
 | 
							["technic:tool_workshop"] = "src",
 | 
				
			||||||
 | 
							["technic:mv_freezer"] = "dst",
 | 
				
			||||||
 | 
							["technic:mv_freezer_active"] = "dst",
 | 
				
			||||||
 | 
							["technic:hv_electric_furnace"] = "dst",
 | 
				
			||||||
 | 
							["technic:hv_electric_furnace_active"] = "dst",
 | 
				
			||||||
 | 
							["technic:hv_compressor"] = "dst",
 | 
				
			||||||
 | 
							["technic:hv_compressor_active"] = "dst",
 | 
				
			||||||
 | 
							["technic:hv_grinder"] = "dst",
 | 
				
			||||||
 | 
							["technic:hv_grinder_active"] = "dst"
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- make sure there's something appropriate to inject the item into
 | 
				
			||||||
 | 
						local todir = pipeworks.facedir_to_right_dir(filtnode.param2)
 | 
				
			||||||
 | 
						local topos = vector.add(filtpos, todir)
 | 
				
			||||||
 | 
						local tonode = minetest.get_node(topos)
 | 
				
			||||||
 | 
						local todef = minetest.registered_nodes[tonode.name]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if not todef
 | 
				
			||||||
 | 
						  or not (minetest.get_item_group(tonode.name, "tube") == 1
 | 
				
			||||||
 | 
								  or minetest.get_item_group(tonode.name, "tubedevice") == 1
 | 
				
			||||||
 | 
								  or minetest.get_item_group(tonode.name, "tubedevice_receiver") == 1) then
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if fromtube then fromtube.input_inventory = input_special_cases[fromnode.name] or fromtube.input_inventory end
 | 
				
			||||||
 | 
						if not (fromtube and fromtube.input_inventory) then return end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local slotseq_mode
 | 
				
			||||||
 | 
						local exmatch_mode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local filters = {}
 | 
				
			||||||
 | 
						if data.digiline then
 | 
				
			||||||
 | 
							local function add_filter(name, group, count, wear, metadata)
 | 
				
			||||||
 | 
								table.insert(filters, {name = name, group = group, count = tonumber(count), wear = wear, metadata = metadata})
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							local function add_itemstring_filter(filter)
 | 
				
			||||||
 | 
								local filterstack = ItemStack(filter)
 | 
				
			||||||
 | 
								local filtername = filterstack:get_name()
 | 
				
			||||||
 | 
								local filtercount = filterstack:get_count()
 | 
				
			||||||
 | 
								local filterwear = string.match(filter, "%S*:%S*%s%d%s(%d)") and filterstack:get_wear()
 | 
				
			||||||
 | 
								local filtermetadata = string.match(filter, "%S*:%S*%s%d%s%d(%s.*)") and filterstack:get_metadata()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								add_filter(filtername, nil, filtercount, filterwear, filtermetadata)
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							local t_msg = type(msg)
 | 
				
			||||||
 | 
							if t_msg == "table" then
 | 
				
			||||||
 | 
								local slotseq = msg.slotseq
 | 
				
			||||||
 | 
								local t_slotseq = type(slotseq)
 | 
				
			||||||
 | 
								if t_slotseq == "number" and slotseq >= 0 and slotseq <= 2 then
 | 
				
			||||||
 | 
									slotseq_mode = slotseq
 | 
				
			||||||
 | 
								elseif t_slotseq == "string" then
 | 
				
			||||||
 | 
									slotseq = string.lower(slotseq)
 | 
				
			||||||
 | 
									if slotseq == "priority" then
 | 
				
			||||||
 | 
										slotseq_mode = 0
 | 
				
			||||||
 | 
									elseif slotseq == "random" then
 | 
				
			||||||
 | 
										slotseq_mode = 1
 | 
				
			||||||
 | 
									elseif slotseq == "rotation" then
 | 
				
			||||||
 | 
										slotseq_mode = 2
 | 
				
			||||||
 | 
									end
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								local exmatch = msg.exmatch
 | 
				
			||||||
 | 
								local t_exmatch = type(exmatch)
 | 
				
			||||||
 | 
								if t_exmatch == "number" and (exmatch == 0 or exmatch == 1) then
 | 
				
			||||||
 | 
									exmatch_mode = exmatch
 | 
				
			||||||
 | 
								elseif t_exmatch == "boolean" then
 | 
				
			||||||
 | 
									exmatch_mode = exmatch and 1 or 0
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								local slotseq_index = msg.slotseq_index
 | 
				
			||||||
 | 
								if type(slotseq_index) == "number" then
 | 
				
			||||||
 | 
									-- This should allow any valid index, but I'm not completely sure what
 | 
				
			||||||
 | 
									-- constitutes a valid index, so I'm only allowing resetting it to 1.
 | 
				
			||||||
 | 
									if slotseq_index == 1 then
 | 
				
			||||||
 | 
										filtmeta:set_int("slotseq_index", slotseq_index)
 | 
				
			||||||
 | 
										set_filter_infotext(data, filtmeta)
 | 
				
			||||||
 | 
									end
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if slotseq_mode ~= nil then
 | 
				
			||||||
 | 
									filtmeta:set_int("slotseq_mode", slotseq_mode)
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if exmatch_mode ~= nil then
 | 
				
			||||||
 | 
									filtmeta:set_int("exmatch_mode", exmatch_mode)
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if slotseq_mode ~= nil or exmatch_mode ~= nil then
 | 
				
			||||||
 | 
									set_filter_formspec(data, filtmeta)
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if msg.nofire then
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if msg.name or msg.group or msg.count or msg.wear or msg.metadata then
 | 
				
			||||||
 | 
									add_filter(msg.name, msg.group, msg.count, msg.wear, msg.metadata)
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									for _, filter in ipairs(msg) do
 | 
				
			||||||
 | 
										local t_filter = type(filter)
 | 
				
			||||||
 | 
										if t_filter == "table" then
 | 
				
			||||||
 | 
											if filter.name or filter.group or filter.count or filter.wear or filter.metadata then
 | 
				
			||||||
 | 
												add_filter(filter.name, filter.group, filter.count, filter.wear, filter.metadata)
 | 
				
			||||||
 | 
											end
 | 
				
			||||||
 | 
										elseif t_filter == "string" then
 | 
				
			||||||
 | 
											add_itemstring_filter(filter)
 | 
				
			||||||
 | 
										end
 | 
				
			||||||
 | 
									end
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							elseif t_msg == "string" then
 | 
				
			||||||
 | 
								add_itemstring_filter(msg)
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							for _, filterstack in ipairs(filtinv:get_list("main")) do
 | 
				
			||||||
 | 
								local filtername = filterstack:get_name()
 | 
				
			||||||
 | 
								local filtercount = filterstack:get_count()
 | 
				
			||||||
 | 
								if filtername ~= "" then table.insert(filters, {name = filtername, count = filtercount}) end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						if #filters == 0 then table.insert(filters, "") end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if slotseq_mode == nil then
 | 
				
			||||||
 | 
							slotseq_mode = filtmeta:get_int("slotseq_mode")
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if exmatch_mode == nil then
 | 
				
			||||||
 | 
							exmatch_mode = filtmeta:get_int("exmatch_mode")
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local frominv
 | 
				
			||||||
 | 
						if fromtube.return_input_invref then
 | 
				
			||||||
 | 
							frominv = fromtube.return_input_invref(frompos, fromnode, dir, owner)
 | 
				
			||||||
 | 
							if not frominv then
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							local frommeta = minetest.get_meta(frompos)
 | 
				
			||||||
 | 
							frominv = frommeta:get_inventory()
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						if fromtube.before_filter then fromtube.before_filter(frompos) end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local function grabAndFire(frominvname, filterfor)
 | 
				
			||||||
		local sposes = {}
 | 
							local sposes = {}
 | 
				
			||||||
		if not frominvname or not frominv:get_list(frominvname) then return end
 | 
							if not frominvname or not frominv:get_list(frominvname) then return end
 | 
				
			||||||
		for spos,stack in ipairs(frominv:get_list(frominvname)) do
 | 
							for spos,stack in ipairs(frominv:get_list(frominvname)) do
 | 
				
			||||||
@@ -85,8 +267,8 @@ local function grabAndFire(data,slotseq_mode,exmatch_mode,filtmeta,frominv,fromi
 | 
				
			|||||||
				                        or (type(fwear[2]) == "number"           --    it must be a number
 | 
									                        or (type(fwear[2]) == "number"           --    it must be a number
 | 
				
			||||||
				                            and stack:get_wear() < fwear[2]))))  --    and it must be > the actual wear.
 | 
									                            and stack:get_wear() < fwear[2]))))  --    and it must be > the actual wear.
 | 
				
			||||||
				                                                                 --  If the wear filter is of any other type, fail.
 | 
									                                                                 --  If the wear filter is of any other type, fail.
 | 
				
			||||||
			                                                                 --
 | 
					
 | 
				
			||||||
			          and (not fmetadata                                     -- If there's a matadata filter,
 | 
									          and (not fmetadata                                     -- If there's a metadata filter,
 | 
				
			||||||
				               or (type(fmetadata) == "string"                   --  it must be a string
 | 
									               or (type(fmetadata) == "string"                   --  it must be a string
 | 
				
			||||||
				                   and stack:get_metadata() == fmetadata))       --  and it must match.
 | 
									                   and stack:get_metadata() == fmetadata))       --  and it must match.
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
@@ -131,9 +313,9 @@ local function grabAndFire(data,slotseq_mode,exmatch_mode,filtmeta,frominv,fromi
 | 
				
			|||||||
				end
 | 
									end
 | 
				
			||||||
				local item
 | 
									local item
 | 
				
			||||||
				local count
 | 
									local count
 | 
				
			||||||
				if all then
 | 
									if data.stackwise then
 | 
				
			||||||
					count = math.min(stack:get_count(), doRemove)
 | 
										count = math.min(stack:get_count(), doRemove)
 | 
				
			||||||
					if filterfor.count and (filterfor.count > 1 or digiline) then
 | 
										if filterfor.count and (filterfor.count > 1 or data.digiline) then
 | 
				
			||||||
						if exmatch_mode ~= 0 and filterfor.count > count then
 | 
											if exmatch_mode ~= 0 and filterfor.count > count then
 | 
				
			||||||
							return false -- not enough, fail
 | 
												return false -- not enough, fail
 | 
				
			||||||
						else
 | 
											else
 | 
				
			||||||
@@ -156,182 +338,18 @@ local function grabAndFire(data,slotseq_mode,exmatch_mode,filtmeta,frominv,fromi
 | 
				
			|||||||
				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,
 | 
				
			||||||
				return true-- only fire one item, please
 | 
										fakePlayer:get_player_name())
 | 
				
			||||||
 | 
									return true -- only fire one item, please
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		return false
 | 
							return false
 | 
				
			||||||
end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
local function punch_filter(data, filtpos, filtnode, msg)
 | 
					 | 
				
			||||||
	local filtmeta = minetest.get_meta(filtpos)
 | 
					 | 
				
			||||||
	local filtinv = filtmeta:get_inventory()
 | 
					 | 
				
			||||||
	local owner = filtmeta:get_string("owner")
 | 
					 | 
				
			||||||
	local fakePlayer = pipeworks.create_fake_player({
 | 
					 | 
				
			||||||
		name = owner
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
	local dir = pipeworks.facedir_to_right_dir(filtnode.param2)
 | 
					 | 
				
			||||||
	local frompos = vector.subtract(filtpos, dir)
 | 
					 | 
				
			||||||
	local fromnode = minetest.get_node(frompos)
 | 
					 | 
				
			||||||
	if not fromnode then return end
 | 
					 | 
				
			||||||
	local fromdef = minetest.registered_nodes[fromnode.name]
 | 
					 | 
				
			||||||
	if not fromdef then return end
 | 
					 | 
				
			||||||
	local fromtube = fromdef.tube
 | 
					 | 
				
			||||||
	local input_special_cases = {
 | 
					 | 
				
			||||||
		["technic:mv_furnace"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_furnace_active"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_electric_furnace"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_electric_furnace_active"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_alloy_furnace"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_alloy_furnace_active"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_centrifuge"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_centrifuge_active"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_compressor"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_compressor_active"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_extractor"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_extractor_active"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_grinder"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_grinder_active"] = "dst",
 | 
					 | 
				
			||||||
		["technic:tool_workshop"] = "src",
 | 
					 | 
				
			||||||
		["technic:mv_freezer"] = "dst",
 | 
					 | 
				
			||||||
		["technic:mv_freezer_active"] = "dst"
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	-- make sure there's something appropriate to inject the item into
 | 
					 | 
				
			||||||
	local todir = pipeworks.facedir_to_right_dir(filtnode.param2)
 | 
					 | 
				
			||||||
	local topos = vector.add(filtpos, todir)
 | 
					 | 
				
			||||||
	local tonode = minetest.get_node(topos)
 | 
					 | 
				
			||||||
	local todef = minetest.registered_nodes[tonode.name]
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if not todef
 | 
					 | 
				
			||||||
	  or not (minetest.get_item_group(tonode.name, "tube") == 1
 | 
					 | 
				
			||||||
			  or minetest.get_item_group(tonode.name, "tubedevice") == 1
 | 
					 | 
				
			||||||
			  or minetest.get_item_group(tonode.name, "tubedevice_receiver") == 1) then
 | 
					 | 
				
			||||||
		return
 | 
					 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if fromtube then fromtube.input_inventory = input_special_cases[fromnode.name] or fromtube.input_inventory end
 | 
					 | 
				
			||||||
	if not (fromtube and fromtube.input_inventory) then return end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	local slotseq_mode
 | 
					 | 
				
			||||||
	local exact_match
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	local filters = {}
 | 
					 | 
				
			||||||
	if data.digiline then
 | 
					 | 
				
			||||||
		local function add_filter(name, group, count, wear, metadata)
 | 
					 | 
				
			||||||
			table.insert(filters, {name = name, group = group, count = tonumber(count), wear = wear, metadata = metadata})
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		local function add_itemstring_filter(filter)
 | 
					 | 
				
			||||||
			local filterstack = ItemStack(filter)
 | 
					 | 
				
			||||||
			local filtername = filterstack:get_name()
 | 
					 | 
				
			||||||
			local filtercount = filterstack:get_count()
 | 
					 | 
				
			||||||
			local filterwear = string.match(filter, "%S*:%S*%s%d%s(%d)") and filterstack:get_wear()
 | 
					 | 
				
			||||||
			local filtermetadata = string.match(filter, "%S*:%S*%s%d%s%d(%s.*)") and filterstack:get_metadata()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			add_filter(filtername, nil, filtercount, filterwear, filtermetadata)
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		local t_msg = type(msg)
 | 
					 | 
				
			||||||
		if t_msg == "table" then
 | 
					 | 
				
			||||||
			local slotseq = msg.slotseq
 | 
					 | 
				
			||||||
			local t_slotseq = type(slotseq)
 | 
					 | 
				
			||||||
			if t_slotseq == "number" and slotseq >= 0 and slotseq <= 2 then
 | 
					 | 
				
			||||||
				slotseq_mode = slotseq
 | 
					 | 
				
			||||||
			elseif t_slotseq == "string" then
 | 
					 | 
				
			||||||
				slotseq = string.lower(slotseq)
 | 
					 | 
				
			||||||
				if slotseq == "priority" then
 | 
					 | 
				
			||||||
					slotseq_mode = 0
 | 
					 | 
				
			||||||
				elseif slotseq == "random" then
 | 
					 | 
				
			||||||
					slotseq_mode = 1
 | 
					 | 
				
			||||||
				elseif slotseq == "rotation" then
 | 
					 | 
				
			||||||
					slotseq_mode = 2
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			local exmatch = msg.exmatch
 | 
					 | 
				
			||||||
			local t_exmatch = type(exmatch)
 | 
					 | 
				
			||||||
			if t_exmatch == "number" and exmatch >= 0 and exmatch <= 1 then
 | 
					 | 
				
			||||||
				exact_match = exmatch
 | 
					 | 
				
			||||||
			elseif t_exmatch == "boolean" then
 | 
					 | 
				
			||||||
				exact_match = exmatch and 1 or 0
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			local slotseq_index = msg.slotseq_index
 | 
					 | 
				
			||||||
			if type(slotseq_index) == "number" then
 | 
					 | 
				
			||||||
				-- This should allow any valid index, but I'm not completely sure what
 | 
					 | 
				
			||||||
				-- constitutes a valid index, so I'm only allowing resetting it to 1.
 | 
					 | 
				
			||||||
				if slotseq_index == 1 then
 | 
					 | 
				
			||||||
					filtmeta:set_int("slotseq_index", slotseq_index)
 | 
					 | 
				
			||||||
					set_filter_infotext(data, filtmeta)
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if slotseq_mode ~= nil then
 | 
					 | 
				
			||||||
				filtmeta:set_int("slotseq_mode", slotseq_mode)
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if exact_match ~= nil then
 | 
					 | 
				
			||||||
				filtmeta:set_int("exmatch_mode", exact_match)
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if slotseq_mode ~= nil or exact_match ~= nil then
 | 
					 | 
				
			||||||
				set_filter_formspec(data, filtmeta)
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if msg.nofire then
 | 
					 | 
				
			||||||
				return
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if msg.name or msg.group or msg.count or msg.wear or msg.metadata then
 | 
					 | 
				
			||||||
				add_filter(msg.name, msg.group, msg.count, msg.wear, msg.metadata)
 | 
					 | 
				
			||||||
			else
 | 
					 | 
				
			||||||
				for _, filter in ipairs(msg) do
 | 
					 | 
				
			||||||
					local t_filter = type(filter)
 | 
					 | 
				
			||||||
					if t_filter == "table" then
 | 
					 | 
				
			||||||
						if filter.name or filter.group or filter.count or filter.wear or filter.metadata then
 | 
					 | 
				
			||||||
							add_filter(filter.name, filter.group, filter.count, filter.wear, filter.metadata)
 | 
					 | 
				
			||||||
						end
 | 
					 | 
				
			||||||
					elseif t_filter == "string" then
 | 
					 | 
				
			||||||
						add_itemstring_filter(filter)
 | 
					 | 
				
			||||||
					end
 | 
					 | 
				
			||||||
				end
 | 
					 | 
				
			||||||
			end
 | 
					 | 
				
			||||||
		elseif t_msg == "string" then
 | 
					 | 
				
			||||||
			add_itemstring_filter(msg)
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		for _, filterstack in ipairs(filtinv:get_list("main")) do
 | 
					 | 
				
			||||||
			local filtername = filterstack:get_name()
 | 
					 | 
				
			||||||
			local filtercount = filterstack:get_count()
 | 
					 | 
				
			||||||
			if filtername ~= "" then table.insert(filters, {name = filtername, count = filtercount}) end
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	if #filters == 0 then table.insert(filters, "") end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if slotseq_mode == nil then
 | 
					 | 
				
			||||||
		slotseq_mode = filtmeta:get_int("slotseq_mode")
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if exact_match == nil then
 | 
					 | 
				
			||||||
		exact_match = filtmeta:get_int("exmatch_mode")
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	local frominv
 | 
					 | 
				
			||||||
	if fromtube.return_input_invref then
 | 
					 | 
				
			||||||
		frominv = fromtube.return_input_invref(frompos, fromnode, dir, owner)
 | 
					 | 
				
			||||||
		if not frominv then
 | 
					 | 
				
			||||||
			return
 | 
					 | 
				
			||||||
		end
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		local frommeta = minetest.get_meta(frompos)
 | 
					 | 
				
			||||||
		frominv = frommeta:get_inventory()
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	if fromtube.before_filter then fromtube.before_filter(frompos) end
 | 
					 | 
				
			||||||
	for _, frominvname in ipairs(type(fromtube.input_inventory) == "table" and fromtube.input_inventory or {fromtube.input_inventory}) do
 | 
						for _, frominvname in ipairs(type(fromtube.input_inventory) == "table" and fromtube.input_inventory or {fromtube.input_inventory}) do
 | 
				
			||||||
		local done = false
 | 
							local done = false
 | 
				
			||||||
		for _, filterfor in ipairs(filters) do
 | 
							for _, filterfor in ipairs(filters) do
 | 
				
			||||||
			if grabAndFire(data, slotseq_mode, exact_match, filtmeta, frominv, frominvname, frompos, fromnode, filterfor, fromtube, fromdef, dir, fakePlayer, data.stackwise, data.digiline) then
 | 
								if grabAndFire(frominvname, filterfor) then
 | 
				
			||||||
				done = true
 | 
									done = true
 | 
				
			||||||
				break
 | 
									break
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
@@ -344,23 +362,23 @@ end
 | 
				
			|||||||
for _, data in ipairs({
 | 
					for _, data in ipairs({
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		name = "filter",
 | 
							name = "filter",
 | 
				
			||||||
		wise_desc = "Itemwise",
 | 
							wise_desc = S("Itemwise"),
 | 
				
			||||||
		stackwise = false,
 | 
							stackwise = false,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		name = "mese_filter",
 | 
							name = "mese_filter",
 | 
				
			||||||
		wise_desc = "Stackwise",
 | 
							wise_desc = S("Stackwise"),
 | 
				
			||||||
		stackwise = true,
 | 
							stackwise = true,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	{ -- register even if no digilines
 | 
						{ -- register even if no digilines
 | 
				
			||||||
		name = "digiline_filter",
 | 
							name = "digiline_filter",
 | 
				
			||||||
		wise_desc = "Digiline",
 | 
							wise_desc = S("Digiline"),
 | 
				
			||||||
		stackwise = true,
 | 
							stackwise = true,
 | 
				
			||||||
		digiline = true,
 | 
							digiline = true,
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
}) do
 | 
					}) do
 | 
				
			||||||
	local node = {
 | 
						local node = {
 | 
				
			||||||
		description = data.wise_desc.." Filter-Injector",
 | 
							description = S("@1 Filter-Injector", data.wise_desc),
 | 
				
			||||||
		tiles = {
 | 
							tiles = {
 | 
				
			||||||
			"pipeworks_"..data.name.."_top.png",
 | 
								"pipeworks_"..data.name.."_top.png",
 | 
				
			||||||
			"pipeworks_"..data.name.."_top.png",
 | 
								"pipeworks_"..data.name.."_top.png",
 | 
				
			||||||
@@ -372,7 +390,9 @@ for _, data in ipairs({
 | 
				
			|||||||
		paramtype2 = "facedir",
 | 
							paramtype2 = "facedir",
 | 
				
			||||||
		groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2},
 | 
							groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, mesecon = 2},
 | 
				
			||||||
		legacy_facedir_simple = true,
 | 
							legacy_facedir_simple = true,
 | 
				
			||||||
		sounds = default.node_sound_wood_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_wood_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		on_construct = function(pos)
 | 
							on_construct = function(pos)
 | 
				
			||||||
			local meta = minetest.get_meta(pos)
 | 
								local meta = minetest.get_meta(pos)
 | 
				
			||||||
			set_filter_formspec(data, meta)
 | 
								set_filter_formspec(data, meta)
 | 
				
			||||||
@@ -423,10 +443,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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -470,35 +494,7 @@ for _, data in ipairs({
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	minetest.register_node("pipeworks:"..data.name, node)
 | 
						minetest.register_node("pipeworks:"..data.name, node)
 | 
				
			||||||
end
 | 
						pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:"..data.name
 | 
				
			||||||
 | 
					 | 
				
			||||||
minetest.register_craft( {
 | 
					 | 
				
			||||||
	output = "pipeworks:filter 2",
 | 
					 | 
				
			||||||
	recipe = {
 | 
					 | 
				
			||||||
	        { "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
	        { "group:stick", "default:mese_crystal", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
	        { "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" }
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
minetest.register_craft( {
 | 
					 | 
				
			||||||
	output = "pipeworks:mese_filter 2",
 | 
					 | 
				
			||||||
	recipe = {
 | 
					 | 
				
			||||||
	        { "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
	        { "group:stick", "default:mese", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
	        { "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" }
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
if minetest.get_modpath("digilines") then
 | 
					 | 
				
			||||||
	minetest.register_craft( {
 | 
					 | 
				
			||||||
		output = "pipeworks:digiline_filter 2",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			{ "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
			{ "group:stick", "digilines:wire_std_00000000", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
			{ "default:steel_ingot", "default:steel_ingot", "basic_materials:plastic_sheet" }
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
--[[
 | 
					--[[
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -83,7 +83,7 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pipeworks.spigot_check = function(pos, node)
 | 
					pipeworks.spigot_check = function(pos, node)
 | 
				
			||||||
	local belowname = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
 | 
						local belowname = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z}).name
 | 
				
			||||||
	if belowname and (belowname == "air" or belowname == "default:water_flowing" or belowname == "default:water_source") then 
 | 
						if belowname and (belowname == "air" or belowname == pipeworks.liquids.water.flowing or belowname == pipeworks.liquids.water.source) then
 | 
				
			||||||
		local spigotname = minetest.get_node(pos).name
 | 
							local spigotname = minetest.get_node(pos).name
 | 
				
			||||||
		local fdir=node.param2 % 4
 | 
							local fdir=node.param2 % 4
 | 
				
			||||||
		local check = {
 | 
							local check = {
 | 
				
			||||||
@@ -96,14 +96,14 @@ pipeworks.spigot_check = function(pos, node)
 | 
				
			|||||||
		if near_node and string.find(near_node.name, "_loaded") then
 | 
							if near_node and string.find(near_node.name, "_loaded") then
 | 
				
			||||||
			if spigotname and spigotname == "pipeworks:spigot" then
 | 
								if spigotname and spigotname == "pipeworks:spigot" then
 | 
				
			||||||
				minetest.add_node(pos,{name = "pipeworks:spigot_pouring", param2 = fdir})
 | 
									minetest.add_node(pos,{name = "pipeworks:spigot_pouring", param2 = fdir})
 | 
				
			||||||
				if finitewater or belowname ~= "default:water_source" then
 | 
									if finitewater or belowname ~= pipeworks.liquids.water.source then
 | 
				
			||||||
					minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = "default:water_source"})
 | 
										minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = pipeworks.liquids.water.source})
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			if spigotname == "pipeworks:spigot_pouring" then
 | 
								if spigotname == "pipeworks:spigot_pouring" then
 | 
				
			||||||
				minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:spigot", param2 = fdir})
 | 
									minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:spigot", param2 = fdir})
 | 
				
			||||||
				if belowname == "default:water_source" and not finitewater then
 | 
									if belowname == pipeworks.liquids.water.source and not finitewater then
 | 
				
			||||||
					minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z})
 | 
										minetest.remove_node({x=pos.x,y=pos.y-1,z=pos.z})
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
@@ -113,20 +113,20 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
pipeworks.fountainhead_check = function(pos, node)
 | 
					pipeworks.fountainhead_check = function(pos, node)
 | 
				
			||||||
	local abovename = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
 | 
						local abovename = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z}).name
 | 
				
			||||||
	if abovename and (abovename == "air" or abovename == "default:water_flowing" or abovename == "default:water_source") then 
 | 
						if abovename and (abovename == "air" or abovename == pipeworks.liquids.water.flowing or abovename == pipeworks.liquids.water.source) then
 | 
				
			||||||
		local fountainhead_name = minetest.get_node(pos).name
 | 
							local fountainhead_name = minetest.get_node(pos).name
 | 
				
			||||||
		local near_node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
 | 
							local near_node = minetest.get_node({x=pos.x,y=pos.y-1,z=pos.z})
 | 
				
			||||||
		if near_node and string.find(near_node.name, "_loaded") then
 | 
							if near_node and string.find(near_node.name, "_loaded") then
 | 
				
			||||||
			if fountainhead_name and fountainhead_name == "pipeworks:fountainhead" then
 | 
								if fountainhead_name and fountainhead_name == "pipeworks:fountainhead" then
 | 
				
			||||||
				minetest.add_node(pos,{name = "pipeworks:fountainhead_pouring"})
 | 
									minetest.add_node(pos,{name = "pipeworks:fountainhead_pouring"})
 | 
				
			||||||
				if finitewater or abovename ~= "default:water_source" then
 | 
									if finitewater or abovename ~= pipeworks.liquids.water.source then
 | 
				
			||||||
					minetest.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "default:water_source"})
 | 
										minetest.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = pipeworks.liquids.water.source})
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			if fountainhead_name == "pipeworks:fountainhead_pouring" then
 | 
								if fountainhead_name == "pipeworks:fountainhead_pouring" then
 | 
				
			||||||
				minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:fountainhead"})
 | 
									minetest.add_node({x=pos.x,y=pos.y,z=pos.z},{name = "pipeworks:fountainhead"})
 | 
				
			||||||
				if abovename == "default:water_source" and not finitewater then
 | 
									if abovename == pipeworks.liquids.water.source and not finitewater then
 | 
				
			||||||
					minetest.remove_node({x=pos.x,y=pos.y+1,z=pos.z})
 | 
										minetest.remove_node({x=pos.x,y=pos.y+1,z=pos.z})
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										72
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										72
									
								
								init.lua
									
									
									
									
									
								
							@@ -5,11 +5,21 @@
 | 
				
			|||||||
--
 | 
					--
 | 
				
			||||||
 | 
					
 | 
				
			||||||
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")
 | 
				
			||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					pipeworks.liquids = {}
 | 
				
			||||||
 | 
					pipeworks.liquids.water = {
 | 
				
			||||||
 | 
						source = minetest.registered_nodes["mapgen_water_source"].name,
 | 
				
			||||||
 | 
						flowing = minetest.registered_nodes["mapgen_water_source"].liquid_alternative_flowing
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					pipeworks.liquids.river_water = {
 | 
				
			||||||
 | 
						source = minetest.registered_nodes["mapgen_river_water_source"].name,
 | 
				
			||||||
 | 
						flowing = minetest.registered_nodes["mapgen_river_water_source"].liquid_alternative_flowing
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dofile(pipeworks.modpath.."/default_settings.lua")
 | 
					dofile(pipeworks.modpath.."/default_settings.lua")
 | 
				
			||||||
-- Read the external config file if it exists.
 | 
					-- Read the external config file if it exists.
 | 
				
			||||||
@@ -22,6 +32,9 @@ end
 | 
				
			|||||||
if pipeworks.toggles.pipe_mode == "pressure" then
 | 
					if pipeworks.toggles.pipe_mode == "pressure" then
 | 
				
			||||||
	minetest.log("warning", "pipeworks pressure logic mode comes with caveats and differences in behaviour, you have been warned!")
 | 
						minetest.log("warning", "pipeworks pressure logic mode comes with caveats and differences in behaviour, you have been warned!")
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					if pipeworks.entity_update_interval >= 0.2 and pipeworks.enable_accelerator_tube then
 | 
				
			||||||
 | 
						minetest.log("warning", "pipeworks accelerator tubes will not entirely work with an entity update interval 0.2 or above.")
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Random variables
 | 
					-- Random variables
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -40,12 +53,13 @@ pipeworks.rules_all = {{x=0, y=0, z=1},{x=0, y=0, z=-1},{x=1, y=0, z=0},{x=-1, y
 | 
				
			|||||||
pipeworks.mesecons_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
 | 
					pipeworks.mesecons_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
 | 
				
			||||||
pipeworks.digilines_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
 | 
					pipeworks.digilines_rules={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pipeworks.liquid_texture = "default_water.png"
 | 
					pipeworks.liquid_texture = minetest.registered_nodes[pipeworks.liquids.water.flowing].tiles[1]
 | 
				
			||||||
 | 
					if type(pipeworks.liquid_texture) == "table" then pipeworks.liquid_texture = pipeworks.liquid_texture.name end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pipeworks.button_off   = {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"}
 | 
					pipeworks.button_off   = {text="", texture="pipeworks_button_off.png", addopts="false;false;pipeworks_button_interm.png"}
 | 
				
			||||||
pipeworks.button_on    = {text="", texture="pipeworks_button_on.png",  addopts="false;false;pipeworks_button_interm.png"}
 | 
					pipeworks.button_on    = {text="", texture="pipeworks_button_on.png",  addopts="false;false;pipeworks_button_interm.png"}
 | 
				
			||||||
pipeworks.button_base  = "image_button[0,4.3;1,0.6"
 | 
					pipeworks.button_base  = "image_button[0,4.3;1,0.6"
 | 
				
			||||||
pipeworks.button_label = "label[0.9,4.31;Allow splitting incoming stacks from tubes]"
 | 
					pipeworks.button_label = "label[0.9,4.31;"..S("Allow splitting incoming stacks from tubes").."]"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- Helper functions
 | 
					-- Helper functions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -58,6 +72,29 @@ function pipeworks.fix_image_names(table, replacement)
 | 
				
			|||||||
	return outtable
 | 
						return outtable
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function overlay_tube_texture(texture)
 | 
				
			||||||
 | 
						-- The texture appears the first time to be colorized as the opaque background.
 | 
				
			||||||
 | 
						return ("(%s)^[noalpha^[colorize:#dadada^(%s)"):format(texture, texture)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function pipeworks.make_tube_tile(tile)
 | 
				
			||||||
 | 
						if pipeworks.use_real_entities then
 | 
				
			||||||
 | 
							return tile
 | 
				
			||||||
 | 
						elseif type(tile) == "string" then
 | 
				
			||||||
 | 
							return overlay_tube_texture(tile)
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							tile = table.copy(tile)
 | 
				
			||||||
 | 
							if tile.color then
 | 
				
			||||||
 | 
								-- Won't work 100% of the time, but good enough.
 | 
				
			||||||
 | 
								tile.name = tile.name .. "^[multiply:" .. minetest.colorspec_to_colorstring(tile.color)
 | 
				
			||||||
 | 
								tile.color = nil
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
							tile.name = overlay_tube_texture(tile.name)
 | 
				
			||||||
 | 
							tile.backface_culling = nil -- The texture is opaque
 | 
				
			||||||
 | 
							return tile
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function pipeworks.add_node_box(t, b)
 | 
					function pipeworks.add_node_box(t, b)
 | 
				
			||||||
	if not t or not b then return end
 | 
						if not t or not b then return end
 | 
				
			||||||
	for i in ipairs(b)
 | 
						for i in ipairs(b)
 | 
				
			||||||
@@ -70,8 +107,8 @@ function pipeworks.may_configure(pos, player)
 | 
				
			|||||||
	local meta = minetest.get_meta(pos)
 | 
						local meta = minetest.get_meta(pos)
 | 
				
			||||||
	local owner = meta:get_string("owner")
 | 
						local owner = meta:get_string("owner")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if owner ~= "" then -- wielders and filters
 | 
						if owner ~= "" and owner == name then -- wielders and filters
 | 
				
			||||||
		return owner == name
 | 
							return true
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	return not minetest.is_protected(pos, name)
 | 
						return not minetest.is_protected(pos, name)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@@ -102,6 +139,10 @@ if pipeworks.toggles.finite_water == nil then
 | 
				
			|||||||
	dofile(pipeworks.modpath.."/autodetect-finite-water.lua")
 | 
						dofile(pipeworks.modpath.."/autodetect-finite-water.lua")
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if minetest.get_modpath("signs_lib") then
 | 
				
			||||||
 | 
						dofile(pipeworks.modpath.."/signs_compat.lua")
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
dofile(pipeworks.modpath.."/common.lua")
 | 
					dofile(pipeworks.modpath.."/common.lua")
 | 
				
			||||||
dofile(pipeworks.modpath.."/models.lua")
 | 
					dofile(pipeworks.modpath.."/models.lua")
 | 
				
			||||||
dofile(pipeworks.modpath.."/autoplace_pipes.lua")
 | 
					dofile(pipeworks.modpath.."/autoplace_pipes.lua")
 | 
				
			||||||
@@ -109,7 +150,6 @@ dofile(pipeworks.modpath.."/autoplace_tubes.lua")
 | 
				
			|||||||
dofile(pipeworks.modpath.."/luaentity.lua")
 | 
					dofile(pipeworks.modpath.."/luaentity.lua")
 | 
				
			||||||
dofile(pipeworks.modpath.."/item_transport.lua")
 | 
					dofile(pipeworks.modpath.."/item_transport.lua")
 | 
				
			||||||
dofile(pipeworks.modpath.."/flowing_logic.lua")
 | 
					dofile(pipeworks.modpath.."/flowing_logic.lua")
 | 
				
			||||||
dofile(pipeworks.modpath.."/crafts.lua")
 | 
					 | 
				
			||||||
dofile(pipeworks.modpath.."/tube_registration.lua")
 | 
					dofile(pipeworks.modpath.."/tube_registration.lua")
 | 
				
			||||||
dofile(pipeworks.modpath.."/routing_tubes.lua")
 | 
					dofile(pipeworks.modpath.."/routing_tubes.lua")
 | 
				
			||||||
dofile(pipeworks.modpath.."/sorting_tubes.lua")
 | 
					dofile(pipeworks.modpath.."/sorting_tubes.lua")
 | 
				
			||||||
@@ -133,7 +173,7 @@ dofile(pipeworks.modpath..logicdir.."flowable_node_registry_install.lua")
 | 
				
			|||||||
if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end
 | 
					if pipeworks.enable_pipes then dofile(pipeworks.modpath.."/pipes.lua") end
 | 
				
			||||||
if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end
 | 
					if pipeworks.enable_teleport_tube then dofile(pipeworks.modpath.."/teleport_tube.lua") end
 | 
				
			||||||
if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end
 | 
					if pipeworks.enable_pipe_devices then dofile(pipeworks.modpath.."/devices.lua") end
 | 
				
			||||||
if pipeworks.enable_redefines then
 | 
					if pipeworks.enable_redefines and (minetest.get_modpath("default") or minetest.get_modpath("hades_core")) then
 | 
				
			||||||
	dofile(pipeworks.modpath.."/compat-chests.lua")
 | 
						dofile(pipeworks.modpath.."/compat-chests.lua")
 | 
				
			||||||
	dofile(pipeworks.modpath.."/compat-furnaces.lua")
 | 
						dofile(pipeworks.modpath.."/compat-furnaces.lua")
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@@ -143,6 +183,20 @@ if pipeworks.enable_lua_tube and
 | 
				
			|||||||
	dofile(pipeworks.modpath.."/lua_tube.lua")
 | 
						dofile(pipeworks.modpath.."/lua_tube.lua")
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					dofile(pipeworks.modpath.."/crafts.lua")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
 | 
					minetest.register_alias("pipeworks:pipe", "pipeworks:pipe_110000_empty")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
print("Pipeworks loaded!")
 | 
					-- Unified Inventory categories integration
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if minetest.global_exists("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!")
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
local luaentity = pipeworks.luaentity
 | 
					local luaentity = pipeworks.luaentity
 | 
				
			||||||
local enable_max_limit = minetest.settings:get("pipeworks_enable_items_per_tube_limit")
 | 
					local enable_max_limit = minetest.settings:get_bool("pipeworks_enable_items_per_tube_limit")
 | 
				
			||||||
local max_tube_limit = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30
 | 
					local max_tube_limit = tonumber(minetest.settings:get("pipeworks_max_items_per_tube")) or 30
 | 
				
			||||||
if enable_max_limit == nil then enable_max_limit = true end
 | 
					if enable_max_limit == nil then enable_max_limit = true end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -25,7 +25,7 @@ end
 | 
				
			|||||||
-- both optional w/ sensible defaults and fallback to normal allow_* function
 | 
					-- both optional w/ sensible defaults and fallback to normal allow_* function
 | 
				
			||||||
-- XXX: possibly change insert_object to insert_item
 | 
					-- XXX: possibly change insert_object to insert_item
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local adjlist={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=1,y=0,z=0},{x=-1,y=0,z=0}}
 | 
					local default_adjlist={{x=0,y=0,z=1},{x=0,y=0,z=-1},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=1,y=0,z=0},{x=-1,y=0,z=0}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function pipeworks.notvel(tbl, vel)
 | 
					function pipeworks.notvel(tbl, vel)
 | 
				
			||||||
	local tbl2={}
 | 
						local tbl2={}
 | 
				
			||||||
@@ -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..")")
 | 
				
			||||||
			print("[Pipeworks] Warning - a tube at "..minetest.pos_to_string(pos).." broke due to too many items ("..itemcount..")")
 | 
								pipeworks.break_tube(pos)
 | 
				
			||||||
			minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
 | 
					 | 
				
			||||||
			pipeworks.scan_for_tube_objects(pos)
 | 
					 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@@ -80,6 +87,9 @@ local function go_next_compat(pos, cnode, cmeta, cycledir, vel, stack, owner)
 | 
				
			|||||||
	if minetest.registered_nodes[cnode.name] and minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then
 | 
						if minetest.registered_nodes[cnode.name] and minetest.registered_nodes[cnode.name].tube and minetest.registered_nodes[cnode.name].tube.can_go then
 | 
				
			||||||
		can_go = minetest.registered_nodes[cnode.name].tube.can_go(pos, cnode, vel, stack)
 | 
							can_go = minetest.registered_nodes[cnode.name].tube.can_go(pos, cnode, vel, stack)
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
 | 
							local adjlist_string = minetest.get_meta(pos):get_string("adjlist")
 | 
				
			||||||
 | 
							local adjlist = minetest.deserialize(adjlist_string) or default_adjlist -- backward compat: if not found, use old behavior: all directions
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		can_go = pipeworks.notvel(adjlist, vel)
 | 
							can_go = pipeworks.notvel(adjlist, vel)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	-- can_go() is expected to return an array-like table of candidate offsets.
 | 
						-- can_go() is expected to return an array-like table of candidate offsets.
 | 
				
			||||||
@@ -191,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
 | 
				
			||||||
@@ -202,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()}
 | 
				
			||||||
@@ -299,8 +311,6 @@ luaentity.register_entity("pipeworks:tubed_item", {
 | 
				
			|||||||
			self:set_pos(pos)
 | 
								self:set_pos(pos)
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		local stack = ItemStack(self.itemstring)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		local velocity = self:get_velocity()
 | 
							local velocity = self:get_velocity()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		local moved = false
 | 
							local moved = false
 | 
				
			||||||
@@ -317,9 +327,15 @@ luaentity.register_entity("pipeworks:tubed_item", {
 | 
				
			|||||||
			moved = true
 | 
								moved = true
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if not moved then
 | 
				
			||||||
 | 
								return
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							local stack = ItemStack(self.itemstring)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		pipeworks.load_position(self.start_pos)
 | 
							pipeworks.load_position(self.start_pos)
 | 
				
			||||||
		local node = minetest.get_node(self.start_pos)
 | 
							local node = minetest.get_node(self.start_pos)
 | 
				
			||||||
		if moved and minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then
 | 
							if minetest.get_item_group(node.name, "tubedevice_receiver") == 1 then
 | 
				
			||||||
			local leftover
 | 
								local leftover
 | 
				
			||||||
			if minetest.registered_nodes[node.name].tube and minetest.registered_nodes[node.name].tube.insert_object then
 | 
								if minetest.registered_nodes[node.name].tube and minetest.registered_nodes[node.name].tube.insert_object then
 | 
				
			||||||
				leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos, node, stack, vel, self.owner)
 | 
									leftover = minetest.registered_nodes[node.name].tube.insert_object(self.start_pos, node, stack, vel, self.owner)
 | 
				
			||||||
@@ -337,7 +353,6 @@ luaentity.register_entity("pipeworks:tubed_item", {
 | 
				
			|||||||
			return
 | 
								return
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if moved then
 | 
					 | 
				
			||||||
		local found_next, new_velocity, multimode = go_next(self.start_pos, velocity, stack, self.owner) -- todo: color
 | 
							local found_next, new_velocity, multimode = go_next(self.start_pos, velocity, stack, self.owner) -- todo: color
 | 
				
			||||||
		local rev_vel = vector.multiply(velocity, -1)
 | 
							local rev_vel = vector.multiply(velocity, -1)
 | 
				
			||||||
		local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel))
 | 
							local rev_dir = vector.direction(self.start_pos,vector.add(self.start_pos,rev_vel))
 | 
				
			||||||
@@ -377,7 +392,6 @@ luaentity.register_entity("pipeworks:tubed_item", {
 | 
				
			|||||||
			self:set_velocity(new_velocity)
 | 
								self:set_velocity(new_velocity)
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if minetest.get_modpath("mesecons_mvps") then
 | 
					if minetest.get_modpath("mesecons_mvps") then
 | 
				
			||||||
@@ -388,7 +402,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)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if not minetest.get_modpath("auto_tree_tap") and
 | 
					if not minetest.get_modpath("auto_tree_tap") and
 | 
				
			||||||
  minetest.get_modpath("technic") then
 | 
					  minetest.get_modpath("technic") then
 | 
				
			||||||
@@ -20,13 +21,15 @@ if not minetest.get_modpath("auto_tree_tap") and
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	minetest.register_node(":auto_tree_tap:off", {
 | 
						minetest.register_node(":auto_tree_tap:off", {
 | 
				
			||||||
		description = "Auto-Tap",
 | 
							description = S("Auto-Tap"),
 | 
				
			||||||
		tiles = {"pipeworks_nodebreaker_top_off.png","pipeworks_nodebreaker_bottom_off.png","pipeworks_nodebreaker_side2_off.png","pipeworks_nodebreaker_side1_off.png",
 | 
							tiles = {"pipeworks_nodebreaker_top_off.png","pipeworks_nodebreaker_bottom_off.png","pipeworks_nodebreaker_side2_off.png","pipeworks_nodebreaker_side1_off.png",
 | 
				
			||||||
			"pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_off.png"},
 | 
								"pipeworks_nodebreaker_back.png","pipeworks_nodebreaker_front_off.png"},
 | 
				
			||||||
		is_ground_content = true,
 | 
							is_ground_content = true,
 | 
				
			||||||
		paramtype2 = "facedir",
 | 
							paramtype2 = "facedir",
 | 
				
			||||||
		groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1 },
 | 
							groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2, mesecon = 2,tubedevice=1, not_in_creative_inventory=1 },
 | 
				
			||||||
		sounds = default.node_sound_stone_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_stone_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		tube = {connect_sides={back=1}},
 | 
							tube = {connect_sides={back=1}},
 | 
				
			||||||
		on_construct = function(pos)
 | 
							on_construct = function(pos)
 | 
				
			||||||
			local meta = minetest.get_meta(pos)
 | 
								local meta = minetest.get_meta(pos)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										119
									
								
								locale/pipeworks.fr.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								locale/pipeworks.fr.tr
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,119 @@
 | 
				
			|||||||
 | 
					# textdomain: pipeworks
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# License: CC-by-SA 4.0
 | 
				
			||||||
 | 
					# Author: Louis Royer <4259825-lroyer@users.noreply.gitlab.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## generic interaction
 | 
				
			||||||
 | 
					Set=Fixer
 | 
				
			||||||
 | 
					Close=Fermer
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## digilines interfacing
 | 
				
			||||||
 | 
					Channel=Canal
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## init
 | 
				
			||||||
 | 
					Allow splitting incoming stacks from tubes=Séparer les piles venant des tubes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## autocrafter
 | 
				
			||||||
 | 
					Unknown item=Item inconnu
 | 
				
			||||||
 | 
					unconfigured Autocrafter: unknown recipe=Autocrafteur non-configuré : recette inconnue
 | 
				
			||||||
 | 
					unconfigured Autocrafter=Autocrafteur non-configuré
 | 
				
			||||||
 | 
					'@1' Autocrafter (@2)=Autocrafteur de '@1' (@2)
 | 
				
			||||||
 | 
					Save=Valider
 | 
				
			||||||
 | 
					paused '@1' Autocrafter=Autocrafteur de '@1' en pause
 | 
				
			||||||
 | 
					Autocrafter=Autocrafteur
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## compat-furnaces
 | 
				
			||||||
 | 
					Allow splitting incoming material (not fuel) stacks from tubes=Séparer les piles (sauf le carburant) venant des tubes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## decorative tubes
 | 
				
			||||||
 | 
					Airtight steelblock embedded tube=Tube hermétique intégré à un bloc d’acier
 | 
				
			||||||
 | 
					Airtight panel embedded tube=Tube hermétique intégré à un panneau
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## devices
 | 
				
			||||||
 | 
					Pump/Intake Module=Module de pompage et d’admission
 | 
				
			||||||
 | 
					Valve=Vanne
 | 
				
			||||||
 | 
					Decorative grating=Grillage décoratif
 | 
				
			||||||
 | 
					Spigot outlet=Sortie de robinet
 | 
				
			||||||
 | 
					Airtight Pipe entry/exit=Extrémité de tube hermétique
 | 
				
			||||||
 | 
					Flow Sensor=Détecteur de débit
 | 
				
			||||||
 | 
					Flow sensor (on)=Détecteur de débit (actif)
 | 
				
			||||||
 | 
					empty=vide
 | 
				
			||||||
 | 
					@1% full=plein à @1 %
 | 
				
			||||||
 | 
					Expansion Tank (@1)=Réservoir d’expansion (@1)
 | 
				
			||||||
 | 
					Fluid Storage Tank (@1)=Réservoir de liquides (@1)
 | 
				
			||||||
 | 
					Fountainhead=Tête de fontaine
 | 
				
			||||||
 | 
					Straight-only Pipe=Tuyau droit
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## filter-injector
 | 
				
			||||||
 | 
					(slot #@1 next)=(slot suivant : #@1)
 | 
				
			||||||
 | 
					@1 Filter-Injector=Filtre-injecteur @1
 | 
				
			||||||
 | 
					Sequence slots by Priority=Ordonner par priorité
 | 
				
			||||||
 | 
					Sequence slots Randomly=Ordonner aléatoirement
 | 
				
			||||||
 | 
					Sequence slots by Rotation=Ordonner en rotation
 | 
				
			||||||
 | 
					Exact match - off=Filtrage inactif
 | 
				
			||||||
 | 
					Exact match - on=Filtrage actif
 | 
				
			||||||
 | 
					Prefer item types:=Items à filtrer :
 | 
				
			||||||
 | 
					Itemwise=par item
 | 
				
			||||||
 | 
					Stackwise=par piles d’items
 | 
				
			||||||
 | 
					Digiline=digiline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## legacy
 | 
				
			||||||
 | 
					Auto-Tap=Robinet d’arbre automatique
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## pipes
 | 
				
			||||||
 | 
					Pipe Segment=Segment de tuyau
 | 
				
			||||||
 | 
					Pipe Segment (legacy)=Segment de tuyau (obsolète)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## routing tubes
 | 
				
			||||||
 | 
					Pneumatic tube segment=Segment de tuyau pneumatique
 | 
				
			||||||
 | 
					Broken Tube=Tuyau cassé
 | 
				
			||||||
 | 
					High Priority Tube Segment=Segment de tuyau haute priorité
 | 
				
			||||||
 | 
					Accelerating Pneumatic Tube Segment=Segment de tuyau pneumatique accélérante
 | 
				
			||||||
 | 
					Crossing Pneumatic Tube Segment=Intersection de tuyau pneumatique
 | 
				
			||||||
 | 
					One way tube=Tuyau unidirectionnel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## signal tubes
 | 
				
			||||||
 | 
					Detecting Pneumatic Tube Segment on=Segment de tuyau pneumatique avec détecteur (actif)
 | 
				
			||||||
 | 
					Detecting Pneumatic Tube Segment=Segment de tuyau pneumatique avec détecteur
 | 
				
			||||||
 | 
					Digiline Detecting Pneumatic Tube Segment=Segment de tuyau pneumatique avec détecteur digiline
 | 
				
			||||||
 | 
					Digiline Detecting Tube=Tuyau avec détecteur digiline
 | 
				
			||||||
 | 
					Conducting Pneumatic Tube Segment=Segment de tuyau pneumatique conducteur
 | 
				
			||||||
 | 
					Conducting Pneumatic Tube Segment on=Segment de tuyau pneumatique conducteur actif
 | 
				
			||||||
 | 
					Digiline Conducting Pneumatic Tube Segment=Segment de tuyau pneumatique conducteur digiline
 | 
				
			||||||
 | 
					Mesecon and Digiline Conducting Pneumatic Tube Segment=Segment de tuyau pneumatique conducteur mesecon et digiline
 | 
				
			||||||
 | 
					Mesecon and Digiline Conducting Pneumatic Tube Segment on=Segment de tuyau pneumatique conducteur mesecon et digiline (actif)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## sorting tubes
 | 
				
			||||||
 | 
					Sorting Pneumatic Tube Segment=Segment de tuyau pneumatique triant
 | 
				
			||||||
 | 
					Sorting pneumatic tube=Tuyau pneumatique triant
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## teleport tube
 | 
				
			||||||
 | 
					Receive=Reception
 | 
				
			||||||
 | 
					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 private receivers=Utilisez <joueur>;<canal> pour une réception privée
 | 
				
			||||||
 | 
					Teleporting Pneumatic Tube Segment=Segment de tuyau pneumatique téléporteur
 | 
				
			||||||
 | 
					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, 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'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## trashcan
 | 
				
			||||||
 | 
					Trash Can=Poubelle
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## tube registration
 | 
				
			||||||
 | 
					Pneumatic tube segment (legacy)=Segment de tuyau pneumatique (obsolète)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## vacuum tubes
 | 
				
			||||||
 | 
					Radius=Rayon
 | 
				
			||||||
 | 
					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 (@1m)=Segment de tuyau pneumatique aspirant réglable (@1 m)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## wielder
 | 
				
			||||||
 | 
					Node Breaker=Casseur de blocs
 | 
				
			||||||
 | 
					Deployer=Poseur de blocs
 | 
				
			||||||
 | 
					Dispenser=Distributeur
 | 
				
			||||||
							
								
								
									
										117
									
								
								locale/pipeworks.zh_CN.tr
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										117
									
								
								locale/pipeworks.zh_CN.tr
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,117 @@
 | 
				
			|||||||
 | 
					# textdomain: pipeworks
 | 
				
			||||||
 | 
					# License: CC-by-SA 4.0
 | 
				
			||||||
 | 
					# Author: pevernow <3450354617@qq.com>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## generic interaction
 | 
				
			||||||
 | 
					Set=
 | 
				
			||||||
 | 
					Cancel=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## digilines interfacing
 | 
				
			||||||
 | 
					Channel=频道
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## init
 | 
				
			||||||
 | 
					Allow splitting incoming stacks from tubes=允许从管道中拆分传入堆栈
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## autocrafter
 | 
				
			||||||
 | 
					Unknown item=通道
 | 
				
			||||||
 | 
					unconfigured Autocrafter: unknown recipe=未配置的自动工作台: 未知配方
 | 
				
			||||||
 | 
					unconfigured Autocrafter=未配置的自动工作台
 | 
				
			||||||
 | 
					'@1' Autocrafter (@2)=自动工作台 '@1' (@2)
 | 
				
			||||||
 | 
					Save=保存
 | 
				
			||||||
 | 
					paused '@1' Autocrafter=暂停的自动工作台
 | 
				
			||||||
 | 
					Autocrafter=自动工作台
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## compat-furnaces
 | 
				
			||||||
 | 
					Allow splitting incoming material (not fuel) stacks from tubes=允许从管子中分离进来的材料(不是燃料)堆
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## decorative tubes
 | 
				
			||||||
 | 
					Airtight steelblock embedded tube=密封嵌入式铁块管道
 | 
				
			||||||
 | 
					Airtight panel embedded tube=密封嵌入式片状管道
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## devices
 | 
				
			||||||
 | 
					Pump/Intake Module=泵/进气模块
 | 
				
			||||||
 | 
					Valve=阀门
 | 
				
			||||||
 | 
					Decorative grating=Decorative grating
 | 
				
			||||||
 | 
					Spigot outlet=龙头
 | 
				
			||||||
 | 
					Airtight Pipe entry/exit=密闭管进/出
 | 
				
			||||||
 | 
					Flow Sensor=流量传感器
 | 
				
			||||||
 | 
					Flow sensor (on)=流量传感器(上)
 | 
				
			||||||
 | 
					empty=空的
 | 
				
			||||||
 | 
					@1% full=满的@1 %
 | 
				
			||||||
 | 
					Expansion Tank (@1)=扩展水箱 (@1)
 | 
				
			||||||
 | 
					Fluid Storage Tank (@1)=储液罐 (@1)
 | 
				
			||||||
 | 
					Fountainhead=源泉
 | 
				
			||||||
 | 
					Straight-only Pipe=直管
 | 
				
			||||||
 | 
					## filter-injector
 | 
				
			||||||
 | 
					(slot #@1 next)=(下一个插槽 : #@1)
 | 
				
			||||||
 | 
					@1 Filter-Injector=@1取物器
 | 
				
			||||||
 | 
					Sequence slots by Priority=优先顺序排列
 | 
				
			||||||
 | 
					Sequence slots Randomly=随机排列时隙
 | 
				
			||||||
 | 
					Sequence slots by Rotation=旋转顺序槽
 | 
				
			||||||
 | 
					Exact match - off=完全匹配-关闭
 | 
				
			||||||
 | 
					Exact match - on=完全匹配-开启
 | 
				
			||||||
 | 
					Prefer item types:=偏好物品类型 :
 | 
				
			||||||
 | 
					Itemwise=逐项
 | 
				
			||||||
 | 
					Stackwise=堆叠方式
 | 
				
			||||||
 | 
					Digiline=Digiline
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## legacy
 | 
				
			||||||
 | 
					Auto-Tap=自动轴阀
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## pipes
 | 
				
			||||||
 | 
					Pipe Segment=管道
 | 
				
			||||||
 | 
					Pipe Segment (legacy)=管道(旧版)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## routing tubes
 | 
				
			||||||
 | 
					Pneumatic tube segment=普通管道
 | 
				
			||||||
 | 
					Broken Tube=断管
 | 
				
			||||||
 | 
					High Priority Tube Segment=高优先级管段
 | 
				
			||||||
 | 
					Accelerating Pneumatic Tube Segment=加速管道
 | 
				
			||||||
 | 
					Crossing Pneumatic Tube Segment=定向管道
 | 
				
			||||||
 | 
					One way tube=单向管
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## signal tubes
 | 
				
			||||||
 | 
					Detecting Pneumatic Tube Segment on=检测管道(运行中)
 | 
				
			||||||
 | 
					Detecting Pneumatic Tube Segment=检测管道
 | 
				
			||||||
 | 
					Digiline Detecting Pneumatic Tube Segment=Digiline检测管道
 | 
				
			||||||
 | 
					Digiline Detecting Tube=Digiline检测管
 | 
				
			||||||
 | 
					Conducting Pneumatic Tube Segment=传导管道
 | 
				
			||||||
 | 
					Conducting Pneumatic Tube Segment on=传导管道(运行中)
 | 
				
			||||||
 | 
					Digiline Conducting Pneumatic Tube Segment=Digiline传导式气动管道
 | 
				
			||||||
 | 
					Mesecon and Digiline Conducting Pneumatic Tube Segment=Mesecon和Digiline传导管道
 | 
				
			||||||
 | 
					Mesecon and Digiline Conducting Pneumatic Tube Segment on=Mesecon和Digiline传导管道(运行中)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## sorting tubes
 | 
				
			||||||
 | 
					Sorting Pneumatic Tube Segment=分类管道
 | 
				
			||||||
 | 
					Sorting pneumatic tube=分类管道
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## teleport tube
 | 
				
			||||||
 | 
					Receive=接收
 | 
				
			||||||
 | 
					Channels are public by default=频道默认为公开
 | 
				
			||||||
 | 
					Use <player>:<channel> for fully private channels=将<player>:<channel>用于完全私人的频道
 | 
				
			||||||
 | 
					Use <player>;<channel> for private receivers=使用<player>;<channel>作为私人接收器
 | 
				
			||||||
 | 
					Teleporting Pneumatic Tube Segment=传送管道
 | 
				
			||||||
 | 
					Teleporting Tube=
 | 
				
			||||||
 | 
					Unconfigured Teleportation Tube=未配置的传送管道
 | 
				
			||||||
 | 
					Sorry, channel '@1' is reserved for exclusive use by @2=抱歉,频道‘@1’保留供‘@2’专用
 | 
				
			||||||
 | 
					Sorry, receiving from channel '@1' is reserved for @2=抱歉,从频道'@1'接收的内容已保留给'@2'
 | 
				
			||||||
 | 
					Teleportation Tube @1 on '@2'=传送管'@1'在'@2'上
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## trashcan
 | 
				
			||||||
 | 
					Trash Can=垃圾箱
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## tube registration
 | 
				
			||||||
 | 
					Pneumatic tube segment (legacy)=普通管道(旧式)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## vacuum tubes
 | 
				
			||||||
 | 
					Radius=
 | 
				
			||||||
 | 
					Vacuuming Pneumatic Tube Segment=拾取管道
 | 
				
			||||||
 | 
					Adjustable Vacuuming Tube=
 | 
				
			||||||
 | 
					Adjustable Vacuuming Pneumatic Tube Segment=高级拾取管道
 | 
				
			||||||
 | 
					Adjustable Vacuuming Pneumatic Tube Segment (@1m)=高级拾取管道(@1m)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## wielder
 | 
				
			||||||
 | 
					Node Breaker=方块破坏器
 | 
				
			||||||
 | 
					Deployer=放置器
 | 
				
			||||||
 | 
					Dispenser=投掷器
 | 
				
			||||||
							
								
								
									
										119
									
								
								locale/template.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										119
									
								
								locale/template.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,119 @@
 | 
				
			|||||||
 | 
					# textdomain: pipeworks
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# License: CC-by-SA 4.0
 | 
				
			||||||
 | 
					# Author:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## generic interaction
 | 
				
			||||||
 | 
					Set=
 | 
				
			||||||
 | 
					Cancel=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## digilines interfacing
 | 
				
			||||||
 | 
					Channel=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## init
 | 
				
			||||||
 | 
					Allow splitting incoming stacks from tubes=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## autocrafter
 | 
				
			||||||
 | 
					Unknown item=
 | 
				
			||||||
 | 
					unconfigured Autocrafter: unknown recipe=
 | 
				
			||||||
 | 
					unconfigured Autocrafter=
 | 
				
			||||||
 | 
					'@1' Autocrafter (@2)=
 | 
				
			||||||
 | 
					Save=
 | 
				
			||||||
 | 
					paused '@1' Autocrafter=
 | 
				
			||||||
 | 
					Autocrafter=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## compat-furnaces
 | 
				
			||||||
 | 
					Allow splitting incoming material (not fuel) stacks from tubes=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## decorative tubes
 | 
				
			||||||
 | 
					Airtight steelblock embedded tube=
 | 
				
			||||||
 | 
					Airtight panel embedded tube=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## devices
 | 
				
			||||||
 | 
					Pump/Intake Module=
 | 
				
			||||||
 | 
					Valve=
 | 
				
			||||||
 | 
					Decorative grating=
 | 
				
			||||||
 | 
					Spigot outlet=
 | 
				
			||||||
 | 
					Airtight Pipe entry/exit=
 | 
				
			||||||
 | 
					Flow Sensor=
 | 
				
			||||||
 | 
					Flow sensor (on)=
 | 
				
			||||||
 | 
					empty=
 | 
				
			||||||
 | 
					@1% full=
 | 
				
			||||||
 | 
					Expansion Tank (@1)=
 | 
				
			||||||
 | 
					Fluid Storage Tank (@1)=
 | 
				
			||||||
 | 
					Fountainhead=
 | 
				
			||||||
 | 
					Straight-only Pipe=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## filter-injector
 | 
				
			||||||
 | 
					(slot #@1 next)=
 | 
				
			||||||
 | 
					@1 Filter-Injector=
 | 
				
			||||||
 | 
					Sequence slots by Priority=
 | 
				
			||||||
 | 
					Sequence slots Randomly=
 | 
				
			||||||
 | 
					Sequence slots by Rotation=
 | 
				
			||||||
 | 
					Exact match - off=
 | 
				
			||||||
 | 
					Exact match - on=
 | 
				
			||||||
 | 
					Prefer item types:=
 | 
				
			||||||
 | 
					Itemwise=
 | 
				
			||||||
 | 
					Stackwise=
 | 
				
			||||||
 | 
					Digiline=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## legacy
 | 
				
			||||||
 | 
					Auto-Tap=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## pipes
 | 
				
			||||||
 | 
					Pipe Segment=
 | 
				
			||||||
 | 
					Pipe Segment (legacy)=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## routing tubes
 | 
				
			||||||
 | 
					Pneumatic tube segment=
 | 
				
			||||||
 | 
					Broken Tube=
 | 
				
			||||||
 | 
					High Priority Tube Segment=
 | 
				
			||||||
 | 
					Accelerating Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					Crossing Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					One way tube=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## signal tubes
 | 
				
			||||||
 | 
					Detecting Pneumatic Tube Segment on=
 | 
				
			||||||
 | 
					Detecting Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					Digiline Detecting Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					Digiline Detecting Tube=
 | 
				
			||||||
 | 
					Conducting Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					Conducting Pneumatic Tube Segment on=
 | 
				
			||||||
 | 
					Digiline Conducting Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					Mesecon and Digiline Conducting Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					Mesecon and Digiline Conducting Pneumatic Tube Segment on=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## sorting tubes
 | 
				
			||||||
 | 
					Sorting Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					Sorting pneumatic tube=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## teleport tube
 | 
				
			||||||
 | 
					Receive=
 | 
				
			||||||
 | 
					Channels are public by default=
 | 
				
			||||||
 | 
					Use <player>:<channel> for fully private channels=
 | 
				
			||||||
 | 
					Use <player>;<channel> for private receivers=
 | 
				
			||||||
 | 
					Teleporting Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					Teleporting Tube=
 | 
				
			||||||
 | 
					Unconfigured Teleportation Tube=
 | 
				
			||||||
 | 
					Sorry, channel '@1' is reserved for exclusive use by @2=
 | 
				
			||||||
 | 
					Sorry, receiving from channel '@1' is reserved for @2=
 | 
				
			||||||
 | 
					Teleportation Tube @1 on '@2'=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## trashcan
 | 
				
			||||||
 | 
					Trash Can=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## tube registration
 | 
				
			||||||
 | 
					Pneumatic tube segment (legacy)=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## vacuum tubes
 | 
				
			||||||
 | 
					Radius=
 | 
				
			||||||
 | 
					Vacuuming Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					Adjustable Vacuuming Tube=
 | 
				
			||||||
 | 
					Adjustable Vacuuming Pneumatic Tube Segment=
 | 
				
			||||||
 | 
					Adjustable Vacuuming Pneumatic Tube Segment (@1m)=
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					## wielder
 | 
				
			||||||
 | 
					Node Breaker=
 | 
				
			||||||
 | 
					Deployer=
 | 
				
			||||||
 | 
					Dispenser=
 | 
				
			||||||
							
								
								
									
										475
									
								
								lua_tube.lua
									
									
									
									
									
								
							
							
						
						
									
										475
									
								
								lua_tube.lua
									
									
									
									
									
								
							@@ -13,8 +13,10 @@
 | 
				
			|||||||
-- newport = merge_port_states(state1, state2): just does result = state1 or state2 for every port
 | 
					-- newport = merge_port_states(state1, state2): just does result = state1 or state2 for every port
 | 
				
			||||||
-- set_port(pos, rule, state): activates/deactivates the mesecons according to the port states
 | 
					-- set_port(pos, rule, state): activates/deactivates the mesecons according to the port states
 | 
				
			||||||
-- set_port_states(pos, ports): Applies new port states to a Luacontroller at pos
 | 
					-- set_port_states(pos, ports): Applies new port states to a Luacontroller at pos
 | 
				
			||||||
-- run(pos): runs the code in the controller at pos
 | 
					-- run_inner(pos, code, event): runs code on the controller at pos and event
 | 
				
			||||||
-- reset_meta(pos, code, errmsg): performs a software-reset, installs new code and prints error messages
 | 
					-- reset_formspec(pos, code, errmsg): installs new code and prints error messages, without resetting LCID
 | 
				
			||||||
 | 
					-- reset_meta(pos, code, errmsg): performs a software-reset, installs new code and prints error message
 | 
				
			||||||
 | 
					-- run(pos, event): a wrapper for run_inner which gets code & handles errors via reset_meta
 | 
				
			||||||
-- resetn(pos): performs a hardware reset, turns off all ports
 | 
					-- resetn(pos): performs a hardware reset, turns off all ports
 | 
				
			||||||
--
 | 
					--
 | 
				
			||||||
-- The Sandbox
 | 
					-- The Sandbox
 | 
				
			||||||
@@ -24,7 +26,7 @@
 | 
				
			|||||||
-- use too much memory from the sandbox.
 | 
					-- use too much memory from the sandbox.
 | 
				
			||||||
-- You can add more functions to the environment
 | 
					-- You can add more functions to the environment
 | 
				
			||||||
-- (see where local env is defined)
 | 
					-- (see where local env is defined)
 | 
				
			||||||
-- Something nice to play is is appending minetest.env to it.
 | 
					-- Something nice to play is appending minetest.env to it.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local BASENAME = "pipeworks:lua_tube"
 | 
					local BASENAME = "pipeworks:lua_tube"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -77,7 +79,7 @@ local function update_real_port_states(pos, rule_name, new_state)
 | 
				
			|||||||
	if rule_name.x == nil then
 | 
						if rule_name.x == nil then
 | 
				
			||||||
		for _, rname in ipairs(rule_name) do
 | 
							for _, rname in ipairs(rule_name) do
 | 
				
			||||||
			local port = pos_to_side[rname.x + (2 * rname.y) + (3 * rname.z) + 4]
 | 
								local port = pos_to_side[rname.x + (2 * rname.y) + (3 * rname.z) + 4]
 | 
				
			||||||
			L[port] = (newstate == "on") and 1 or 0
 | 
								L[port] = (new_state == "on") and 1 or 0
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		local port = pos_to_side[rule_name.x + (2 * rule_name.y) + (3 * rule_name.z) + 4]
 | 
							local port = pos_to_side[rule_name.x + (2 * rule_name.y) + (3 * rule_name.z) + 4]
 | 
				
			||||||
@@ -168,7 +170,7 @@ local function set_port_states(pos, ports)
 | 
				
			|||||||
		-- Solution / Workaround:
 | 
							-- Solution / Workaround:
 | 
				
			||||||
		-- Remember which output was turned off and ignore next "off" event.
 | 
							-- Remember which output was turned off and ignore next "off" event.
 | 
				
			||||||
		local meta = minetest.get_meta(pos)
 | 
							local meta = minetest.get_meta(pos)
 | 
				
			||||||
		local ign = minetest.deserialize(meta:get_string("ignore_offevents")) or {}
 | 
							local ign = minetest.deserialize(meta:get_string("ignore_offevents"), true) or {}
 | 
				
			||||||
		if ports.red    and not vports.red    and not mesecon.is_powered(pos, rules.red)    then ign.red    = true end
 | 
							if ports.red    and not vports.red    and not mesecon.is_powered(pos, rules.red)    then ign.red    = true end
 | 
				
			||||||
		if ports.blue   and not vports.blue   and not mesecon.is_powered(pos, rules.blue)   then ign.blue   = true end
 | 
							if ports.blue   and not vports.blue   and not mesecon.is_powered(pos, rules.blue)   then ign.blue   = true end
 | 
				
			||||||
		if ports.yellow and not vports.yellow and not mesecon.is_powered(pos, rules.yellow) then ign.yellow = true end
 | 
							if ports.yellow and not vports.yellow and not mesecon.is_powered(pos, rules.yellow) then ign.yellow = true end
 | 
				
			||||||
@@ -214,7 +216,7 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
local function ignore_event(event, meta)
 | 
					local function ignore_event(event, meta)
 | 
				
			||||||
	if event.type ~= "off" then return false end
 | 
						if event.type ~= "off" then return false end
 | 
				
			||||||
	local ignore_offevents = minetest.deserialize(meta:get_string("ignore_offevents")) or {}
 | 
						local ignore_offevents = minetest.deserialize(meta:get_string("ignore_offevents"), true) or {}
 | 
				
			||||||
	if ignore_offevents[event.pin.name] then
 | 
						if ignore_offevents[event.pin.name] then
 | 
				
			||||||
		ignore_offevents[event.pin.name] = nil
 | 
							ignore_offevents[event.pin.name] = nil
 | 
				
			||||||
		meta:set_string("ignore_offevents", minetest.serialize(ignore_offevents))
 | 
							meta:set_string("ignore_offevents", minetest.serialize(ignore_offevents))
 | 
				
			||||||
@@ -227,7 +229,11 @@ end
 | 
				
			|||||||
-------------------------
 | 
					-------------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function safe_print(param)
 | 
					local function safe_print(param)
 | 
				
			||||||
 | 
						local string_meta = getmetatable("")
 | 
				
			||||||
 | 
						local sandbox = string_meta.__index
 | 
				
			||||||
 | 
						string_meta.__index = string -- Leave string sandbox temporarily
 | 
				
			||||||
	print(dump(param))
 | 
						print(dump(param))
 | 
				
			||||||
 | 
						string_meta.__index = sandbox -- Restore string sandbox
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function safe_date()
 | 
					local function safe_date()
 | 
				
			||||||
@@ -267,6 +273,7 @@ local function remove_functions(x)
 | 
				
			|||||||
	local seen = {}
 | 
						local seen = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local function rfuncs(x)
 | 
						local function rfuncs(x)
 | 
				
			||||||
 | 
							if x == nil then return end
 | 
				
			||||||
		if seen[x] then return end
 | 
							if seen[x] then return end
 | 
				
			||||||
		seen[x] = true
 | 
							seen[x] = true
 | 
				
			||||||
		if type(x) ~= "table" then return end
 | 
							if type(x) ~= "table" then return end
 | 
				
			||||||
@@ -290,49 +297,174 @@ local function remove_functions(x)
 | 
				
			|||||||
	return x
 | 
						return x
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function get_interrupt(pos)
 | 
					-- The setting affects API so is not intended to be changeable at runtime
 | 
				
			||||||
 | 
					local get_interrupt
 | 
				
			||||||
 | 
					if mesecon.setting("luacontroller_lightweight_interrupts", false) then
 | 
				
			||||||
 | 
						-- use node timer
 | 
				
			||||||
 | 
						get_interrupt = function(pos, itbl, send_warning)
 | 
				
			||||||
 | 
							return (function(time, iid)
 | 
				
			||||||
 | 
								if type(time) ~= "number" then error("Delay must be a number") end
 | 
				
			||||||
 | 
								if iid ~= nil then send_warning("Interrupt IDs are disabled on this server") end
 | 
				
			||||||
 | 
								table.insert(itbl, function() minetest.get_node_timer(pos):start(time) end)
 | 
				
			||||||
 | 
							end)
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
						-- use global action queue
 | 
				
			||||||
 | 
						-- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards
 | 
				
			||||||
 | 
						get_interrupt = function(pos, itbl, send_warning)
 | 
				
			||||||
		-- iid = interrupt id
 | 
							-- iid = interrupt id
 | 
				
			||||||
		local function interrupt(time, iid)
 | 
							local function interrupt(time, iid)
 | 
				
			||||||
		if type(time) ~= "number" then return end
 | 
								-- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y
 | 
				
			||||||
 | 
								-- Hence the values get moved out. Should take less time than original, so totally compatible
 | 
				
			||||||
 | 
								if type(time) ~= "number" then error("Delay must be a number") end
 | 
				
			||||||
 | 
								table.insert(itbl, function ()
 | 
				
			||||||
 | 
									-- Outside string metatable sandbox, can safely run this now
 | 
				
			||||||
				local luac_id = minetest.get_meta(pos):get_int("luac_id")
 | 
									local luac_id = minetest.get_meta(pos):get_int("luac_id")
 | 
				
			||||||
 | 
									-- Check if IID is dodgy, so you can't use interrupts to store an infinite amount of data.
 | 
				
			||||||
 | 
									-- Note that this is safe from alter-after-free because this code gets run after the sandbox has ended.
 | 
				
			||||||
 | 
									-- This runs outside of the timer and *shouldn't* harm perf. unless dodgy data is being sent in the first place
 | 
				
			||||||
 | 
									iid = remove_functions(iid)
 | 
				
			||||||
 | 
									local msg_ser = minetest.serialize(iid)
 | 
				
			||||||
 | 
									if #msg_ser <= mesecon.setting("luacontroller_interruptid_maxlen", 256) then
 | 
				
			||||||
					mesecon.queue:add_action(pos, "pipeworks:lc_tube_interrupt", {luac_id, iid}, time, iid, 1)
 | 
										mesecon.queue:add_action(pos, "pipeworks:lc_tube_interrupt", {luac_id, iid}, time, iid, 1)
 | 
				
			||||||
 | 
									else
 | 
				
			||||||
 | 
										send_warning("An interrupt ID was too large!")
 | 
				
			||||||
 | 
									end
 | 
				
			||||||
 | 
								end)
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
		return interrupt
 | 
							return interrupt
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Given a message object passed to digiline_send, clean it up into a form
 | 
				
			||||||
 | 
					-- which is safe to transmit over the network and compute its "cost" (a very
 | 
				
			||||||
 | 
					-- rough estimate of its memory usage).
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					-- The cleaning comprises the following:
 | 
				
			||||||
 | 
					-- 1. Functions (and userdata, though user scripts ought not to get hold of
 | 
				
			||||||
 | 
					--    those in the first place) are removed, because they break the model of
 | 
				
			||||||
 | 
					--    Digilines as a network that carries basic data, and they could exfiltrate
 | 
				
			||||||
 | 
					--    references to mutable objects from one Luacontroller to another, allowing
 | 
				
			||||||
 | 
					--    inappropriate high-bandwidth, no-wires communication.
 | 
				
			||||||
 | 
					-- 2. Tables are duplicated because, being mutable, they could otherwise be
 | 
				
			||||||
 | 
					--    modified after the send is complete in order to change what data arrives
 | 
				
			||||||
 | 
					--    at the recipient, perhaps in violation of the previous cleaning rule or
 | 
				
			||||||
 | 
					--    in violation of the message size limit.
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					-- The cost indication is only approximate; it’s not a perfect measurement of
 | 
				
			||||||
 | 
					-- the number of bytes of memory used by the message object.
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					-- Parameters:
 | 
				
			||||||
 | 
					-- msg -- the message to clean
 | 
				
			||||||
 | 
					-- back_references -- for internal use only; do not provide
 | 
				
			||||||
 | 
					--
 | 
				
			||||||
 | 
					-- Returns:
 | 
				
			||||||
 | 
					-- 1. The cleaned object.
 | 
				
			||||||
 | 
					-- 2. The approximate cost of the object.
 | 
				
			||||||
 | 
					local function clean_and_weigh_digiline_message(msg, back_references)
 | 
				
			||||||
 | 
						local t = type(msg)
 | 
				
			||||||
 | 
						if t == "string" then
 | 
				
			||||||
 | 
							-- Strings are immutable so can be passed by reference, and cost their
 | 
				
			||||||
 | 
							-- length plus the size of the Lua object header (24 bytes on a 64-bit
 | 
				
			||||||
 | 
							-- platform) plus one byte for the NUL terminator.
 | 
				
			||||||
 | 
							return msg, #msg + 25
 | 
				
			||||||
 | 
						elseif t == "number" then
 | 
				
			||||||
 | 
							-- Numbers are passed by value so need not be touched, and cost 8 bytes
 | 
				
			||||||
 | 
							-- as all numbers in Lua are doubles.
 | 
				
			||||||
 | 
							return msg, 8
 | 
				
			||||||
 | 
						elseif t == "boolean" then
 | 
				
			||||||
 | 
							-- Booleans are passed by value so need not be touched, and cost 1
 | 
				
			||||||
 | 
							-- byte.
 | 
				
			||||||
 | 
							return msg, 1
 | 
				
			||||||
 | 
						elseif t == "table" then
 | 
				
			||||||
 | 
							-- Tables are duplicated. Check if this table has been seen before
 | 
				
			||||||
 | 
							-- (self-referential or shared table); if so, reuse the cleaned value
 | 
				
			||||||
 | 
							-- of the previous occurrence, maintaining table topology and avoiding
 | 
				
			||||||
 | 
							-- infinite recursion, and charge zero bytes for this as the object has
 | 
				
			||||||
 | 
							-- already been counted.
 | 
				
			||||||
 | 
							back_references = back_references or {}
 | 
				
			||||||
 | 
							local bref = back_references[msg]
 | 
				
			||||||
 | 
							if bref then
 | 
				
			||||||
 | 
								return bref, 0
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
							-- Construct a new table by cleaning all the keys and values and adding
 | 
				
			||||||
 | 
							-- up their costs, plus 8 bytes as a rough estimate of table overhead.
 | 
				
			||||||
 | 
							local cost = 8
 | 
				
			||||||
 | 
							local ret = {}
 | 
				
			||||||
 | 
							back_references[msg] = ret
 | 
				
			||||||
 | 
							for k, v in pairs(msg) do
 | 
				
			||||||
 | 
								local k_cost, v_cost
 | 
				
			||||||
 | 
								k, k_cost = clean_and_weigh_digiline_message(k, back_references)
 | 
				
			||||||
 | 
								v, v_cost = clean_and_weigh_digiline_message(v, back_references)
 | 
				
			||||||
 | 
								if k ~= nil and v ~= nil then
 | 
				
			||||||
 | 
									-- Only include an element if its key and value are of legal
 | 
				
			||||||
 | 
									-- types.
 | 
				
			||||||
 | 
									ret[k] = v
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
								-- If we only counted the cost of a table element when we actually
 | 
				
			||||||
 | 
								-- used it, we would be vulnerable to the following attack:
 | 
				
			||||||
 | 
								-- 1. Construct a huge table (too large to pass the cost limit).
 | 
				
			||||||
 | 
								-- 2. Insert it somewhere in a table, with a function as a key.
 | 
				
			||||||
 | 
								-- 3. Insert it somewhere in another table, with a number as a key.
 | 
				
			||||||
 | 
								-- 4. The first occurrence doesn’t pay the cost because functions
 | 
				
			||||||
 | 
								--    are stripped and therefore the element is dropped.
 | 
				
			||||||
 | 
								-- 5. The second occurrence doesn’t pay the cost because it’s in
 | 
				
			||||||
 | 
								--    back_references.
 | 
				
			||||||
 | 
								-- By counting the costs regardless of whether the objects will be
 | 
				
			||||||
 | 
								-- included, we avoid this attack; it may overestimate the cost of
 | 
				
			||||||
 | 
								-- some messages, but only those that won’t be delivered intact
 | 
				
			||||||
 | 
								-- anyway because they contain illegal object types.
 | 
				
			||||||
 | 
								cost = cost + k_cost + v_cost
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
							return ret, cost
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							return nil, 0
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function get_digiline_send(pos)
 | 
					-- itbl: Flat table of functions to run after sandbox cleanup, used to prevent various security hazards
 | 
				
			||||||
	if not digiline then return end
 | 
					local function get_digiline_send(pos, itbl, send_warning)
 | 
				
			||||||
 | 
						if not minetest.global_exists("digilines") then return end
 | 
				
			||||||
 | 
						local chan_maxlen = mesecon.setting("luacontroller_digiline_channel_maxlen", 256)
 | 
				
			||||||
 | 
						local maxlen = mesecon.setting("luacontroller_digiline_maxlen", 50000)
 | 
				
			||||||
	return function(channel, msg)
 | 
						return function(channel, msg)
 | 
				
			||||||
 | 
							-- NOTE: This runs within string metatable sandbox, so don't *rely* on anything of the form (""):y
 | 
				
			||||||
 | 
							--        or via anything that could.
 | 
				
			||||||
		-- Make sure channel is string, number or boolean
 | 
							-- Make sure channel is string, number or boolean
 | 
				
			||||||
		if (type(channel) ~= "string" and type(channel) ~= "number" and type(channel) ~= "boolean") then
 | 
							if type(channel) == "string" then
 | 
				
			||||||
 | 
								if #channel > chan_maxlen then
 | 
				
			||||||
 | 
									send_warning("Channel string too long.")
 | 
				
			||||||
 | 
									return false
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							elseif (type(channel) ~= "string" and type(channel) ~= "number" and type(channel) ~= "boolean") then
 | 
				
			||||||
 | 
								send_warning("Channel must be string, number or boolean.")
 | 
				
			||||||
			return false
 | 
								return false
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		-- It is technically possible to send functions over the wire since
 | 
							local msg_cost
 | 
				
			||||||
		-- the high performance impact of stripping those from the data has
 | 
							msg, msg_cost = clean_and_weigh_digiline_message(msg)
 | 
				
			||||||
		-- been decided to not be worth the added realism.
 | 
							if msg == nil or msg_cost > maxlen then
 | 
				
			||||||
		-- Make sure serialized version of the data is not insanely long to
 | 
								send_warning("Message was too complex, or contained invalid data.")
 | 
				
			||||||
		-- prevent DoS-like attacks
 | 
					 | 
				
			||||||
		local msg_ser = minetest.serialize(msg)
 | 
					 | 
				
			||||||
		if #msg_ser > mesecon.setting("luacontroller_digiline_maxlen", 50000) then
 | 
					 | 
				
			||||||
			return false
 | 
								return false
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		minetest.after(0, function()
 | 
							table.insert(itbl, function ()
 | 
				
			||||||
			digilines.receptor_send(pos, digiline_rules_luatube, channel, msg)
 | 
								-- Runs outside of string metatable sandbox
 | 
				
			||||||
 | 
								local luac_id = minetest.get_meta(pos):get_int("luac_id")
 | 
				
			||||||
 | 
								mesecon.queue:add_action(pos, "pipeworks:lt_digiline_relay", {channel, luac_id, msg})
 | 
				
			||||||
		end)
 | 
							end)
 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
local safe_globals = {
 | 
					local safe_globals = {
 | 
				
			||||||
 | 
						-- Don't add pcall/xpcall unless willing to deal with the consequences (unless very careful, incredibly likely to allow killing server indirectly)
 | 
				
			||||||
	"assert", "error", "ipairs", "next", "pairs", "select",
 | 
						"assert", "error", "ipairs", "next", "pairs", "select",
 | 
				
			||||||
	"tonumber", "tostring", "type", "unpack", "_VERSION"
 | 
						"tonumber", "tostring", "type", "unpack", "_VERSION"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function create_environment(pos, mem, event)
 | 
					local function create_environment(pos, mem, event, itbl, send_warning)
 | 
				
			||||||
	-- Make sure the tube hasn't broken.
 | 
						-- Make sure the tube hasn't broken.
 | 
				
			||||||
	local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
 | 
						local vports = minetest.registered_nodes[minetest.get_node(pos).name].virtual_portstates
 | 
				
			||||||
	if not vports then return {} end
 | 
						if not vports then return {} end
 | 
				
			||||||
@@ -352,8 +484,8 @@ local function create_environment(pos, mem, event)
 | 
				
			|||||||
		heat = mesecon.get_heat(pos),
 | 
							heat = mesecon.get_heat(pos),
 | 
				
			||||||
		heat_max = mesecon.setting("overheat_max", 20),
 | 
							heat_max = mesecon.setting("overheat_max", 20),
 | 
				
			||||||
		print = safe_print,
 | 
							print = safe_print,
 | 
				
			||||||
		interrupt = get_interrupt(pos),
 | 
							interrupt = get_interrupt(pos, itbl, send_warning),
 | 
				
			||||||
		digiline_send = get_digiline_send(pos),
 | 
							digiline_send = get_digiline_send(pos, itbl, send_warning),
 | 
				
			||||||
		string = {
 | 
							string = {
 | 
				
			||||||
			byte = string.byte,
 | 
								byte = string.byte,
 | 
				
			||||||
			char = string.char,
 | 
								char = string.char,
 | 
				
			||||||
@@ -441,10 +573,11 @@ local function create_sandbox(code, env)
 | 
				
			|||||||
		jit.off(f, true)
 | 
							jit.off(f, true)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local maxevents = mesecon.setting("luacontroller_maxevents", 10000)
 | 
				
			||||||
	return function(...)
 | 
						return function(...)
 | 
				
			||||||
 | 
							-- NOTE: This runs within string metatable sandbox, so the setting's been moved out for safety
 | 
				
			||||||
		-- Use instruction counter to stop execution
 | 
							-- Use instruction counter to stop execution
 | 
				
			||||||
		-- after luacontroller_maxevents
 | 
							-- after luacontroller_maxevents
 | 
				
			||||||
		local maxevents = mesecon.setting("luacontroller_maxevents", 10000)
 | 
					 | 
				
			||||||
		debug.sethook(timeout, "", maxevents)
 | 
							debug.sethook(timeout, "", maxevents)
 | 
				
			||||||
		local ok, ret = pcall(f, ...)
 | 
							local ok, ret = pcall(f, ...)
 | 
				
			||||||
		debug.sethook()  -- Clear hook
 | 
							debug.sethook()  -- Clear hook
 | 
				
			||||||
@@ -455,7 +588,7 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function load_memory(meta)
 | 
					local function load_memory(meta)
 | 
				
			||||||
	return minetest.deserialize(meta:get_string("lc_memory")) or {}
 | 
						return minetest.deserialize(meta:get_string("lc_memory"), true) or {}
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -465,6 +598,7 @@ local function save_memory(pos, meta, mem)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (#memstring <= memsize_max) then
 | 
						if (#memstring <= memsize_max) then
 | 
				
			||||||
		meta:set_string("lc_memory", memstring)
 | 
							meta:set_string("lc_memory", memstring)
 | 
				
			||||||
 | 
							meta:mark_as_private("lc_memory")
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		print("Error: lua_tube memory overflow. "..memsize_max.." bytes available, "
 | 
							print("Error: lua_tube memory overflow. "..memsize_max.." bytes available, "
 | 
				
			||||||
				..#memstring.." required. Controller overheats.")
 | 
									..#memstring.." required. Controller overheats.")
 | 
				
			||||||
@@ -472,26 +606,42 @@ local function save_memory(pos, meta, mem)
 | 
				
			|||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Returns success (boolean), errmsg (string), retval(any, return value of the user supplied code)
 | 
				
			||||||
local function run(pos, event)
 | 
					-- run (as opposed to run_inner) is responsible for setting up meta according to this output
 | 
				
			||||||
 | 
					local function run_inner(pos, code, event)
 | 
				
			||||||
	local meta = minetest.get_meta(pos)
 | 
						local meta = minetest.get_meta(pos)
 | 
				
			||||||
	if overheat(pos) then return end
 | 
						-- Note: These return success, presumably to avoid changing LC ID.
 | 
				
			||||||
	if ignore_event(event, meta) then return end
 | 
						if overheat(pos) then return true, "", nil end
 | 
				
			||||||
 | 
						if ignore_event(event, meta) then return true, "", nil end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	-- Load code & mem from meta
 | 
						-- Load code & mem from meta
 | 
				
			||||||
	local mem  = load_memory(meta)
 | 
						local mem  = load_memory(meta)
 | 
				
			||||||
	local code = meta:get_string("code")
 | 
						local code = meta:get_string("code")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- 'Last warning' label.
 | 
				
			||||||
 | 
						local warning = ""
 | 
				
			||||||
 | 
						local function send_warning(str)
 | 
				
			||||||
 | 
							warning = "Warning: " .. str
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	-- Create environment
 | 
						-- Create environment
 | 
				
			||||||
	local env = create_environment(pos, mem, event)
 | 
						local itbl = {}
 | 
				
			||||||
 | 
						local env = create_environment(pos, mem, event, itbl, send_warning)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	-- Create the sandbox and execute code
 | 
						-- Create the sandbox and execute code
 | 
				
			||||||
	local f, msg = create_sandbox(code, env)
 | 
						local f, msg = create_sandbox(code, env)
 | 
				
			||||||
	if not f then return false, msg end
 | 
						if not f then return false, msg, nil end
 | 
				
			||||||
	local succ, msg = pcall(f)
 | 
						-- Start string true sandboxing
 | 
				
			||||||
	if not succ then return false, msg end
 | 
						local onetruestring = getmetatable("")
 | 
				
			||||||
 | 
						-- If a string sandbox is already up yet inconsistent, something is very wrong
 | 
				
			||||||
 | 
						assert(onetruestring.__index == string)
 | 
				
			||||||
 | 
						onetruestring.__index = env.string
 | 
				
			||||||
 | 
						local success, msg = pcall(f)
 | 
				
			||||||
 | 
						onetruestring.__index = string
 | 
				
			||||||
 | 
						-- End string true sandboxing
 | 
				
			||||||
 | 
						if not success then return false, msg, nil end
 | 
				
			||||||
	if type(env.port) ~= "table" then
 | 
						if type(env.port) ~= "table" then
 | 
				
			||||||
		return false, "Ports set are invalid."
 | 
							return false, "Ports set are invalid.", nil
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	-- Actually set the ports
 | 
						-- Actually set the ports
 | 
				
			||||||
@@ -500,35 +650,82 @@ local function run(pos, event)
 | 
				
			|||||||
	-- Save memory. This may burn the luacontroller if a memory overflow occurs.
 | 
						-- Save memory. This may burn the luacontroller if a memory overflow occurs.
 | 
				
			||||||
	save_memory(pos, meta, env.mem)
 | 
						save_memory(pos, meta, env.mem)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return succ, msg
 | 
						-- Execute deferred tasks
 | 
				
			||||||
 | 
						for _, v in ipairs(itbl) do
 | 
				
			||||||
 | 
							local failure = v()
 | 
				
			||||||
 | 
							if failure then
 | 
				
			||||||
 | 
								return false, failure, nil
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						return true, warning, msg
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
mesecon.queue:add_function("pipeworks:lc_tube_interrupt", function (pos, luac_id, iid)
 | 
					local function reset_formspec(meta, code, errmsg)
 | 
				
			||||||
	-- There is no lua_tube anymore / it has been reprogrammed / replaced / burnt
 | 
						meta:set_string("code", code)
 | 
				
			||||||
	if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
 | 
						meta:mark_as_private("code")
 | 
				
			||||||
	if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
 | 
						code = minetest.formspec_escape(code or "")
 | 
				
			||||||
	run(pos, {type = "interrupt", iid = iid})
 | 
						errmsg = minetest.formspec_escape(tostring(errmsg or ""))
 | 
				
			||||||
end)
 | 
						meta:set_string("formspec", "size[12,10]"
 | 
				
			||||||
 | 
							.."style_type[label,textarea;font=mono]"
 | 
				
			||||||
 | 
							.."background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]"
 | 
				
			||||||
 | 
							.."label[0.1,8.3;"..errmsg.."]"
 | 
				
			||||||
 | 
							.."textarea[0.2,0.2;12.2,9.5;code;;"..code.."]"
 | 
				
			||||||
 | 
							.."image_button[4.75,8.75;2.5,1;jeija_luac_runbutton.png;program;]"
 | 
				
			||||||
 | 
							.."image_button_exit[11.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]"
 | 
				
			||||||
 | 
							)
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function reset_meta(pos, code, errmsg)
 | 
					local function reset_meta(pos, code, errmsg)
 | 
				
			||||||
	local meta = minetest.get_meta(pos)
 | 
						local meta = minetest.get_meta(pos)
 | 
				
			||||||
	meta:set_string("code", code)
 | 
						reset_formspec(meta, code, errmsg)
 | 
				
			||||||
	code = minetest.formspec_escape(code or "")
 | 
					 | 
				
			||||||
	errmsg = minetest.formspec_escape(tostring(errmsg or ""))
 | 
					 | 
				
			||||||
	meta:set_string("formspec", "size[12,10]"..
 | 
					 | 
				
			||||||
		"background[-0.2,-0.25;12.4,10.75;jeija_luac_background.png]"..
 | 
					 | 
				
			||||||
		"textarea[0.2,0.2;12.2,9.5;code;;"..code.."]"..
 | 
					 | 
				
			||||||
		"image_button[4.75,8.75;2.5,1;jeija_luac_runbutton.png;program;]"..
 | 
					 | 
				
			||||||
		"image_button_exit[11.72,-0.25;0.425,0.4;jeija_close_window.png;exit;]"..
 | 
					 | 
				
			||||||
		"label[0.1,9;"..errmsg.."]")
 | 
					 | 
				
			||||||
	meta:set_int("luac_id", math.random(1, 65535))
 | 
						meta:set_int("luac_id", math.random(1, 65535))
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Wraps run_inner with LC-reset-on-error
 | 
				
			||||||
 | 
					local function run(pos, event)
 | 
				
			||||||
 | 
						local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
						local code = meta:get_string("code")
 | 
				
			||||||
 | 
						local ok, errmsg, retval = run_inner(pos, code, event)
 | 
				
			||||||
 | 
						if not ok then
 | 
				
			||||||
 | 
							reset_meta(pos, code, errmsg)
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							reset_formspec(meta, code, errmsg)
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						return ok, errmsg, retval
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function reset(pos)
 | 
					local function reset(pos)
 | 
				
			||||||
	set_port_states(pos, {red = false, blue = false, yellow = false,
 | 
						set_port_states(pos, {red = false, blue = false, yellow = false,
 | 
				
			||||||
		green = false, black = false, white = false})
 | 
							green = false, black = false, white = false})
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function node_timer(pos)
 | 
				
			||||||
 | 
						if minetest.registered_nodes[minetest.get_node(pos).name].is_burnt then
 | 
				
			||||||
 | 
							return false
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						run(pos, {type="interrupt"})
 | 
				
			||||||
 | 
						return false
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-----------------------
 | 
				
			||||||
 | 
					-- A.Queue callbacks --
 | 
				
			||||||
 | 
					-----------------------
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mesecon.queue:add_function("pipeworks:lc_tube_interrupt", function (pos, luac_id, iid)
 | 
				
			||||||
 | 
						-- There is no lua_tube anymore / it has been reprogrammed / replaced / burnt
 | 
				
			||||||
 | 
						if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
 | 
				
			||||||
 | 
						if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
 | 
				
			||||||
 | 
						run(pos, {type="interrupt", iid = iid})
 | 
				
			||||||
 | 
					end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					mesecon.queue:add_function("pipeworks:lt_digiline_relay", function (pos, channel, luac_id, msg)
 | 
				
			||||||
 | 
						if not digiline then return end
 | 
				
			||||||
 | 
						-- This check is only really necessary because in case of server crash, old actions can be thrown into the future
 | 
				
			||||||
 | 
						if (minetest.get_meta(pos):get_int("luac_id") ~= luac_id) then return end
 | 
				
			||||||
 | 
						if (minetest.registered_nodes[minetest.get_node(pos).name].is_burnt) then return end
 | 
				
			||||||
 | 
						-- The actual work
 | 
				
			||||||
 | 
						digiline:receptor_send(pos, digiline_rules_luatube, channel, msg)
 | 
				
			||||||
 | 
					end)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-----------------------
 | 
					-----------------------
 | 
				
			||||||
-- Node Registration --
 | 
					-- Node Registration --
 | 
				
			||||||
@@ -558,6 +755,7 @@ local digiline = {
 | 
				
			|||||||
	receptor = {},
 | 
						receptor = {},
 | 
				
			||||||
	effector = {
 | 
						effector = {
 | 
				
			||||||
		action = function(pos, node, channel, msg)
 | 
							action = function(pos, node, channel, msg)
 | 
				
			||||||
 | 
								msg = clean_and_weigh_digiline_message(msg)
 | 
				
			||||||
			run(pos, {type = "digiline", channel = channel, msg = msg})
 | 
								run(pos, {type = "digiline", channel = channel, msg = msg})
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
@@ -565,6 +763,18 @@ local digiline = {
 | 
				
			|||||||
		rules = pipeworks.digilines_rules
 | 
							rules = pipeworks.digilines_rules
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function get_program(pos)
 | 
				
			||||||
 | 
						local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
						return meta:get_string("code")
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function set_program(pos, code)
 | 
				
			||||||
 | 
						reset(pos)
 | 
				
			||||||
 | 
						reset_meta(pos, code)
 | 
				
			||||||
 | 
						return run(pos, {type="program"})
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function on_receive_fields(pos, form_name, fields, sender)
 | 
					local function on_receive_fields(pos, form_name, fields, sender)
 | 
				
			||||||
	if not fields.program then
 | 
						if not fields.program then
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
@@ -574,12 +784,10 @@ local function on_receive_fields(pos, form_name, fields, sender)
 | 
				
			|||||||
		minetest.record_protection_violation(pos, name)
 | 
							minetest.record_protection_violation(pos, name)
 | 
				
			||||||
		return
 | 
							return
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	reset(pos)
 | 
						local ok, err = set_program(pos, fields.code)
 | 
				
			||||||
	reset_meta(pos, fields.code)
 | 
						if not ok then
 | 
				
			||||||
	local succ, err = run(pos, {type="program"})
 | 
							-- it's not an error from the server perspective
 | 
				
			||||||
	if not succ then
 | 
							minetest.log("action", "Lua controller programming error: " .. tostring(err))
 | 
				
			||||||
		print(err)
 | 
					 | 
				
			||||||
		reset_meta(pos, fields.code, err)
 | 
					 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -606,84 +814,58 @@ 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)
 | 
					 | 
				
			||||||
	if red == 1 then
 | 
					 | 
				
			||||||
		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_on.png^[transformR90)"
 | 
					 | 
				
			||||||
		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_on.png^[transformR90)"
 | 
					 | 
				
			||||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_on.png^[transformR270)"
 | 
					 | 
				
			||||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_on.png^[transformR90)"
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_off.png^[transformR90)"
 | 
					 | 
				
			||||||
		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_off.png^[transformR90)"
 | 
					 | 
				
			||||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_off.png^[transformR270)"
 | 
					 | 
				
			||||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_off.png^[transformR90)"
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	if blue == 1 then
 | 
					 | 
				
			||||||
		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_on.png^[transformR270)"
 | 
					 | 
				
			||||||
		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_on.png^[transformR270)"
 | 
					 | 
				
			||||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_on.png^[transformR90)"
 | 
					 | 
				
			||||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_on.png^[transformR270)"
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		tiles[1] = tiles[1].."^(pipeworks_lua_tube_port_off.png^[transformR270)"
 | 
					 | 
				
			||||||
		tiles[2] = tiles[2].."^(pipeworks_lua_tube_port_off.png^[transformR270)"
 | 
					 | 
				
			||||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_off.png^[transformR90)"
 | 
					 | 
				
			||||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_off.png^[transformR270)"
 | 
					 | 
				
			||||||
	end
 | 
					 | 
				
			||||||
	if yellow == 1 then
 | 
					 | 
				
			||||||
		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_on.png^[transformR180)"
 | 
					 | 
				
			||||||
		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_on.png^[transformR180)"
 | 
					 | 
				
			||||||
		tiles[5] = tiles[5].."^(pipeworks_lua_tube_port_on.png^[transformR180)"
 | 
					 | 
				
			||||||
		tiles[6] = tiles[6].."^(pipeworks_lua_tube_port_on.png^[transformR180)"
 | 
					 | 
				
			||||||
	else
 | 
					 | 
				
			||||||
		tiles[3] = tiles[3].."^(pipeworks_lua_tube_port_off.png^[transformR180)"
 | 
					 | 
				
			||||||
		tiles[4] = tiles[4].."^(pipeworks_lua_tube_port_off.png^[transformR180)"
 | 
					 | 
				
			||||||
		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 tiles = table.copy(tiles_base)
 | 
				
			||||||
 | 
						-- Red
 | 
				
			||||||
 | 
						tiles[1] = tiles[1]..tiles_on_off.R_90:format(red == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[2] = tiles[2]..tiles_on_off.R_90:format(red == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[5] = tiles[5]..tiles_on_off.R270:format(red == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[6] = tiles[6]..tiles_on_off.R_90:format(red == 1 and "on" or "off");
 | 
				
			||||||
 | 
						-- Blue
 | 
				
			||||||
 | 
						tiles[1] = tiles[1]..tiles_on_off.R270:format(blue == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[2] = tiles[2]..tiles_on_off.R270:format(blue == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[5] = tiles[5]..tiles_on_off.R_90:format(blue == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[6] = tiles[6]..tiles_on_off.R270:format(blue == 1 and "on" or "off");
 | 
				
			||||||
 | 
						-- Yellow
 | 
				
			||||||
 | 
						tiles[1] = tiles[1]..tiles_on_off.R180:format(yellow == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[2] = tiles[2]..tiles_on_off.R180:format(yellow == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[5] = tiles[5]..tiles_on_off.R180:format(yellow == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[6] = tiles[6]..tiles_on_off.R180:format(yellow == 1 and "on" or "off");
 | 
				
			||||||
 | 
						-- Green
 | 
				
			||||||
 | 
						tiles[3] = tiles[3]..tiles_on_off.R__0:format(green == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[4] = tiles[4]..tiles_on_off.R__0:format(green == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[5] = tiles[5]..tiles_on_off.R__0:format(green == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[6] = tiles[6]..tiles_on_off.R__0:format(green == 1 and "on" or "off");
 | 
				
			||||||
 | 
						-- Black
 | 
				
			||||||
 | 
						tiles[1] = tiles[1]..tiles_on_off.R180:format(black == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[2] = tiles[2]..tiles_on_off.R__0:format(black == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[3] = tiles[3]..tiles_on_off.R_90:format(black == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[4] = tiles[4]..tiles_on_off.R270:format(black == 1 and "on" or "off");
 | 
				
			||||||
 | 
						-- White
 | 
				
			||||||
 | 
						tiles[1] = tiles[1]..tiles_on_off.R__0:format(white == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[2] = tiles[2]..tiles_on_off.R180:format(white == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[3] = tiles[3]..tiles_on_off.R270:format(white == 1 and "on" or "off");
 | 
				
			||||||
 | 
						tiles[4] = tiles[4]..tiles_on_off.R_90:format(white == 1 and "on" or "off");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						local groups = {snappy = 3, tube = 1, tubedevice = 1, overheat = 1, dig_generic = 4}
 | 
				
			||||||
	if red + blue + yellow + green + black + white ~= 0 then
 | 
						if red + blue + yellow + green + black + white ~= 0 then
 | 
				
			||||||
		groups.not_in_creative_inventory = 1
 | 
							groups.not_in_creative_inventory = 1
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
@@ -715,14 +897,20 @@ for white  = 0, 1 do
 | 
				
			|||||||
		receptor = {
 | 
							receptor = {
 | 
				
			||||||
			state = mesecon.state.on,
 | 
								state = mesecon.state.on,
 | 
				
			||||||
			rules = output_rules[cid]
 | 
								rules = output_rules[cid]
 | 
				
			||||||
		}
 | 
							},
 | 
				
			||||||
 | 
							luacontroller = {
 | 
				
			||||||
 | 
								get_program = get_program,
 | 
				
			||||||
 | 
								set_program = set_program,
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	minetest.register_node(node_name, {
 | 
						minetest.register_node(node_name, {
 | 
				
			||||||
		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,
 | 
				
			||||||
		groups = groups,
 | 
							groups = groups,
 | 
				
			||||||
		drop = BASENAME.."000000",
 | 
							drop = BASENAME.."000000",
 | 
				
			||||||
		sunlight_propagates = true,
 | 
							sunlight_propagates = true,
 | 
				
			||||||
@@ -730,7 +918,9 @@ for white  = 0, 1 do
 | 
				
			|||||||
		node_box = node_box,
 | 
							node_box = node_box,
 | 
				
			||||||
		on_construct = reset_meta,
 | 
							on_construct = reset_meta,
 | 
				
			||||||
		on_receive_fields = on_receive_fields,
 | 
							on_receive_fields = on_receive_fields,
 | 
				
			||||||
		sounds = default.node_sound_wood_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_wood_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		mesecons = mesecons,
 | 
							mesecons = mesecons,
 | 
				
			||||||
		digiline = digiline,
 | 
							digiline = digiline,
 | 
				
			||||||
		-- Virtual portstates are the ports that
 | 
							-- Virtual portstates are the ports that
 | 
				
			||||||
@@ -749,6 +939,7 @@ for white  = 0, 1 do
 | 
				
			|||||||
			pipeworks.after_dig(pos, node)
 | 
								pipeworks.after_dig(pos, node)
 | 
				
			||||||
		end,
 | 
							end,
 | 
				
			||||||
		is_luacontroller = true,
 | 
							is_luacontroller = true,
 | 
				
			||||||
 | 
							on_timer = node_timer,
 | 
				
			||||||
		tubelike = 1,
 | 
							tubelike = 1,
 | 
				
			||||||
		tube = {
 | 
							tube = {
 | 
				
			||||||
			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},
 | 
				
			||||||
@@ -756,13 +947,13 @@ 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
 | 
				
			||||||
					end
 | 
										end
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
				local succ, msg = run(pos, {
 | 
									local succ, _, msg = run(pos, {
 | 
				
			||||||
					type = "item",
 | 
										type = "item",
 | 
				
			||||||
					pin = src,
 | 
										pin = src,
 | 
				
			||||||
					itemstring = stack:to_string(),
 | 
										itemstring = stack:to_string(),
 | 
				
			||||||
@@ -780,15 +971,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
 | 
					 | 
				
			||||||
			minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"})
 | 
					 | 
				
			||||||
			pipeworks.scan_for_tube_objects(pos)
 | 
					 | 
				
			||||||
		end,
 | 
					 | 
				
			||||||
		on_blast = function(pos, intensity)
 | 
					 | 
				
			||||||
			if not intensity or intensity > 1 + 3^0.5 then
 | 
					 | 
				
			||||||
				minetest.remove_node(pos)
 | 
					 | 
				
			||||||
				return {string.format("%s_%s", name, dropname)}
 | 
					 | 
				
			||||||
			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)
 | 
				
			||||||
@@ -801,6 +984,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 --
 | 
				
			||||||
------------------------------------
 | 
					------------------------------------
 | 
				
			||||||
@@ -834,16 +1019,20 @@ 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",
 | 
				
			||||||
	groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1},
 | 
						is_ground_content = false,
 | 
				
			||||||
 | 
						groups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory=1, dig_generic = 4},
 | 
				
			||||||
	drop = BASENAME.."000000",
 | 
						drop = BASENAME.."000000",
 | 
				
			||||||
	sunlight_propagates = true,
 | 
						sunlight_propagates = true,
 | 
				
			||||||
	selection_box = selection_box,
 | 
						selection_box = selection_box,
 | 
				
			||||||
	node_box = node_box,
 | 
						node_box = node_box,
 | 
				
			||||||
	on_construct = reset_meta,
 | 
						on_construct = reset_meta,
 | 
				
			||||||
	on_receive_fields = on_receive_fields,
 | 
						on_receive_fields = on_receive_fields,
 | 
				
			||||||
	sounds = default.node_sound_wood_defaults(),
 | 
						_sound_def = {
 | 
				
			||||||
 | 
					        key = "node_sound_wood_defaults",
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
	virtual_portstates = {red = false, blue = false, yellow = false,
 | 
						virtual_portstates = {red = false, blue = false, yellow = false,
 | 
				
			||||||
		green = false, black = false, white = false},
 | 
							green = false, black = false, white = false},
 | 
				
			||||||
	mesecons = {
 | 
						mesecons = {
 | 
				
			||||||
@@ -864,7 +1053,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)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -73,9 +73,13 @@ local function get_blockpos(pos)
 | 
				
			|||||||
	        z = math.floor(pos.z / 16)}
 | 
						        z = math.floor(pos.z / 16)}
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
 | 
					local move_entities_globalstep_part1
 | 
				
			||||||
 | 
					local is_active
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local move_entities_globalstep_part1 = function(dtime)
 | 
					if pipeworks.use_real_entities then
 | 
				
			||||||
 | 
						local active_blocks = {} -- These only contain active blocks near players (i.e., not forceloaded ones)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						move_entities_globalstep_part1 = function(dtime)
 | 
				
			||||||
		local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2
 | 
							local active_block_range = tonumber(minetest.settings:get("active_block_range")) or 2
 | 
				
			||||||
		local new_active_blocks = {}
 | 
							local new_active_blocks = {}
 | 
				
			||||||
		for _, player in ipairs(minetest.get_connected_players()) do
 | 
							for _, player in ipairs(minetest.get_connected_players()) do
 | 
				
			||||||
@@ -94,10 +98,18 @@ local move_entities_globalstep_part1 = function(dtime)
 | 
				
			|||||||
		end
 | 
							end
 | 
				
			||||||
		active_blocks = new_active_blocks
 | 
							active_blocks = new_active_blocks
 | 
				
			||||||
		-- todo: callbacks on block load/unload
 | 
							-- todo: callbacks on block load/unload
 | 
				
			||||||
end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function is_active(pos)
 | 
						is_active = function(pos)
 | 
				
			||||||
		return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
 | 
							return active_blocks[minetest.hash_node_position(get_blockpos(pos))] ~= nil
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					else
 | 
				
			||||||
 | 
						move_entities_globalstep_part1 = function()
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						is_active = function()
 | 
				
			||||||
 | 
							return false
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local entitydef_default = {
 | 
					local entitydef_default = {
 | 
				
			||||||
@@ -318,19 +330,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
 | 
				
			||||||
@@ -340,6 +353,8 @@ local move_entities_globalstep_part2 = function(dtime)
 | 
				
			|||||||
			entity._velocity = master_entity:get_velocity()
 | 
								entity._velocity = master_entity:get_velocity()
 | 
				
			||||||
			entity._acceleration = master_entity:get_acceleration()
 | 
								entity._acceleration = master_entity:get_acceleration()
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
 | 
								entity._velocity = entity._velocity or vector.new(0,0,0)
 | 
				
			||||||
 | 
								entity._acceleration = entity._acceleration or vector.new(0,0,0)
 | 
				
			||||||
			entity._pos = vector.add(vector.add(
 | 
								entity._pos = vector.add(vector.add(
 | 
				
			||||||
				entity._pos,
 | 
									entity._pos,
 | 
				
			||||||
				vector.multiply(entity._velocity, dtime)),
 | 
									vector.multiply(entity._velocity, dtime)),
 | 
				
			||||||
@@ -367,13 +382,36 @@ local move_entities_globalstep_part2 = function(dtime)
 | 
				
			|||||||
	end
 | 
						end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local handle_active_blocks_timer = 0.1
 | 
					-- dtime after which there is an update (or skip).
 | 
				
			||||||
 | 
					local dtime_threshold = pipeworks.entity_update_interval
 | 
				
			||||||
 | 
					-- Accumulated dtime since last update (or skip).
 | 
				
			||||||
 | 
					local dtime_accum = 0
 | 
				
			||||||
 | 
					-- Delayed dtime accumulated due to skipped updates.
 | 
				
			||||||
 | 
					local dtime_delayed = 0
 | 
				
			||||||
 | 
					local skip_update = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
minetest.register_globalstep(function(dtime)
 | 
					minetest.register_globalstep(function(dtime)
 | 
				
			||||||
	handle_active_blocks_timer = handle_active_blocks_timer + dtime
 | 
						if dtime >= 0.2 and dtime_delayed < 1 then
 | 
				
			||||||
	if dtime < 0.2 or handle_active_blocks_timer >= (dtime * 3) then
 | 
							-- Reduce activity when the server is lagging.
 | 
				
			||||||
		handle_active_blocks_timer = 0.1
 | 
							skip_update = true
 | 
				
			||||||
		move_entities_globalstep_part1(dtime)
 | 
					 | 
				
			||||||
		move_entities_globalstep_part2(dtime)
 | 
					 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dtime_accum = dtime_accum + dtime
 | 
				
			||||||
 | 
						if dtime_accum < dtime_threshold then
 | 
				
			||||||
 | 
							return
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if skip_update then
 | 
				
			||||||
 | 
							dtime_delayed = dtime_delayed + dtime_accum
 | 
				
			||||||
 | 
							skip_update = false
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							move_entities_globalstep_part1(dtime_accum + dtime_delayed)
 | 
				
			||||||
 | 
							move_entities_globalstep_part2(dtime_accum + dtime_delayed)
 | 
				
			||||||
 | 
							dtime_delayed = 0
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						-- Tune the threshold so that the average interval is pipeworks.entity_update_interval.
 | 
				
			||||||
 | 
						dtime_threshold = math.max(dtime_threshold + (pipeworks.entity_update_interval - dtime_accum) / 10, 0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						dtime_accum = 0
 | 
				
			||||||
end)
 | 
					end)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								mod.conf
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								mod.conf
									
									
									
									
									
								
							@@ -1 +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.
 | 
				
			||||||
 | 
					depends = basic_materials
 | 
				
			||||||
 | 
					optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen, sound_api, i3, hades_core, hades_furnaces, hades_chests
 | 
				
			||||||
 | 
					min_minetest_version = 5.2.0
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										37
									
								
								pipes.lua
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								pipes.lua
									
									
									
									
									
								
							@@ -1,4 +1,5 @@
 | 
				
			|||||||
-- This file supplies the steel pipes
 | 
					-- This file supplies the steel pipes
 | 
				
			||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local REGISTER_COMPATIBILITY = true
 | 
					local REGISTER_COMPATIBILITY = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -10,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 = {}
 | 
				
			||||||
@@ -29,17 +30,19 @@ 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, dig_generic = 4}
 | 
				
			||||||
	local pipedesc = "Pipe segement".." "..dump(connects).."... You hacker, you."
 | 
						local pipedesc = S("Pipe Segment").." "..dump(connects)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if #connects == 0 then
 | 
						if #connects == 0 then
 | 
				
			||||||
		pgroups = {snappy = 3, tube = 1}
 | 
							pgroups = {snappy = 3, tube = 1, dig_generic = 4}
 | 
				
			||||||
		pipedesc = "Pipe segment"
 | 
							pipedesc = S("Pipe Segment")
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local outimg_e = { "pipeworks_pipe_plain.png" }
 | 
						local outimg_e = { "pipeworks_pipe_plain.png" }
 | 
				
			||||||
@@ -73,7 +76,9 @@ for index, connects in ipairs(cconnects) do
 | 
				
			|||||||
			fixed = outsel
 | 
								fixed = outsel
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		groups = pgroups,
 | 
							groups = pgroups,
 | 
				
			||||||
		sounds = default.node_sound_wood_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		walkable = true,
 | 
							walkable = true,
 | 
				
			||||||
		drop = "pipeworks:pipe_1_empty",
 | 
							drop = "pipeworks:pipe_1_empty",
 | 
				
			||||||
		after_place_node = function(pos)
 | 
							after_place_node = function(pos)
 | 
				
			||||||
@@ -82,10 +87,13 @@ for index, connects in ipairs(cconnects) do
 | 
				
			|||||||
		after_dig_node = function(pos)
 | 
							after_dig_node = function(pos)
 | 
				
			||||||
			pipeworks.scan_for_pipe_objects(pos)
 | 
								pipeworks.scan_for_pipe_objects(pos)
 | 
				
			||||||
		end,
 | 
							end,
 | 
				
			||||||
		on_rotate = false
 | 
							on_rotate = false,
 | 
				
			||||||
 | 
							check_for_pole = pipeworks.check_for_vert_pipe,
 | 
				
			||||||
 | 
							check_for_horiz_pole = pipeworks.check_for_horiz_pipe,
 | 
				
			||||||
 | 
							pipenumber = index
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1}
 | 
						local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1, dig_generic = 4}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	minetest.register_node("pipeworks:pipe_"..index.."_loaded", {
 | 
						minetest.register_node("pipeworks:pipe_"..index.."_loaded", {
 | 
				
			||||||
		description = pipedesc,
 | 
							description = pipedesc,
 | 
				
			||||||
@@ -104,7 +112,9 @@ for index, connects in ipairs(cconnects) do
 | 
				
			|||||||
			fixed = outsel
 | 
								fixed = outsel
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		groups = pgroups,
 | 
							groups = pgroups,
 | 
				
			||||||
		sounds = default.node_sound_wood_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_metal_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		walkable = true,
 | 
							walkable = true,
 | 
				
			||||||
		drop = "pipeworks:pipe_1_empty",
 | 
							drop = "pipeworks:pipe_1_empty",
 | 
				
			||||||
		after_place_node = function(pos)
 | 
							after_place_node = function(pos)
 | 
				
			||||||
@@ -114,7 +124,10 @@ for index, connects in ipairs(cconnects) do
 | 
				
			|||||||
		after_dig_node = function(pos)
 | 
							after_dig_node = function(pos)
 | 
				
			||||||
			pipeworks.scan_for_pipe_objects(pos)
 | 
								pipeworks.scan_for_pipe_objects(pos)
 | 
				
			||||||
		end,
 | 
							end,
 | 
				
			||||||
		on_rotate = false
 | 
							on_rotate = false,
 | 
				
			||||||
 | 
							check_for_pole = pipeworks.check_for_vert_pipe,
 | 
				
			||||||
 | 
							check_for_horiz_pole = pipeworks.check_for_horiz_pipe,
 | 
				
			||||||
 | 
							pipenumber = index
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local emptypipe = "pipeworks:pipe_"..index.."_empty"
 | 
						local emptypipe = "pipeworks:pipe_"..index.."_empty"
 | 
				
			||||||
@@ -124,7 +137,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
 | 
				
			||||||
@@ -134,7 +147,7 @@ if REGISTER_COMPATIBILITY then
 | 
				
			|||||||
		drawtype = "airlike",
 | 
							drawtype = "airlike",
 | 
				
			||||||
		sunlight_propagates = true,
 | 
							sunlight_propagates = true,
 | 
				
			||||||
		paramtype = "light",
 | 
							paramtype = "light",
 | 
				
			||||||
		description = "Pipe Segment (legacy)",
 | 
							description = S("Pipe Segment (legacy)"),
 | 
				
			||||||
		groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
 | 
							groups = {not_in_creative_inventory = 1, pipe_to_update = 1},
 | 
				
			||||||
		drop = "pipeworks:pipe_1_empty",
 | 
							drop = "pipeworks:pipe_1_empty",
 | 
				
			||||||
		after_place_node = function(pos)
 | 
							after_place_node = function(pos)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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,10 +39,10 @@ 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 == pipeworks.liquids.water.source then
 | 
				
			||||||
			minetest.remove_node(tpos)
 | 
								minetest.remove_node(tpos)
 | 
				
			||||||
			total = total + 1
 | 
								total = total + 1
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
@@ -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
 | 
				
			||||||
@@ -246,9 +247,9 @@ flowlogic.helpers.make_neighbour_output_fixed = function(neighbours)
 | 
				
			|||||||
			-- in non-finite mode, pressure has to be sustained to keep the sources there.
 | 
								-- in non-finite mode, pressure has to be sustained to keep the sources there.
 | 
				
			||||||
			-- so in non-finite mode, placing water is dependent on the target node;
 | 
								-- so in non-finite mode, placing water is dependent on the target node;
 | 
				
			||||||
			-- draining pressure is not.
 | 
								-- draining pressure is not.
 | 
				
			||||||
			local canplace = (name == "air") or (name == "default:water_flowing")
 | 
								local canplace = (name == "air") or (name == pipeworks.liquids.water.flowing)
 | 
				
			||||||
			if canplace then
 | 
								if canplace then
 | 
				
			||||||
				minetest.swap_node(npos, {name="default:water_source"})
 | 
									minetest.swap_node(npos, {name=pipeworks.liquids.water.source})
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
			if (not finitemode) or canplace then
 | 
								if (not finitemode) or canplace then
 | 
				
			||||||
				taken = taken + 1
 | 
									taken = taken + 1
 | 
				
			||||||
@@ -267,7 +268,7 @@ flowlogic.helpers.make_neighbour_cleanup_fixed = function(neighbours)
 | 
				
			|||||||
		for _, offset in pairs(neighbours) do
 | 
							for _, offset in pairs(neighbours) do
 | 
				
			||||||
			local npos = vector.add(pos, offset)
 | 
								local npos = vector.add(pos, offset)
 | 
				
			||||||
			local name = minetest.get_node(npos).name
 | 
								local name = minetest.get_node(npos).name
 | 
				
			||||||
			if (name == "default:water_source") then
 | 
								if (name == pipeworks.liquids.water.source) then
 | 
				
			||||||
				--pipeworks.logger("neighbour_cleanup_fixed removing "..formatvec(npos))
 | 
									--pipeworks.logger("neighbour_cleanup_fixed removing "..formatvec(npos))
 | 
				
			||||||
				minetest.remove_node(npos)
 | 
									minetest.remove_node(npos)
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
@@ -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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
-- the default tube and default textures
 | 
					-- the default tube and default textures
 | 
				
			||||||
pipeworks.register_tube("pipeworks:tube", "Pneumatic tube segment")
 | 
					pipeworks.register_tube("pipeworks:tube", S("Pneumatic tube segment"))
 | 
				
			||||||
minetest.register_craft( {
 | 
					minetest.register_craft( {
 | 
				
			||||||
	output = "pipeworks:tube_1 6",
 | 
						output = "pipeworks:tube_1 6",
 | 
				
			||||||
	recipe = {
 | 
						recipe = {
 | 
				
			||||||
@@ -10,10 +10,39 @@ 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", {
 | 
				
			||||||
	description = "Broken Tube (you hacker you)",
 | 
						description = S("Broken Tube"),
 | 
				
			||||||
	plain = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
 | 
						plain = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
 | 
				
			||||||
	noctr = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
 | 
						noctr = { { name = "pipeworks_broken_tube_plain.png", backface_culling = false, color = nodecolor } },
 | 
				
			||||||
	ends  = { { name = "pipeworks_broken_tube_end.png",   color = nodecolor } },
 | 
						ends  = { { name = "pipeworks_broken_tube_end.png",   color = nodecolor } },
 | 
				
			||||||
@@ -35,29 +64,38 @@ pipeworks.register_tube("pipeworks:broken_tube", {
 | 
				
			|||||||
			local itemstack = puncher:get_wielded_item()
 | 
								local itemstack = puncher:get_wielded_item()
 | 
				
			||||||
			local wieldname = itemstack:get_name()
 | 
								local wieldname = itemstack:get_name()
 | 
				
			||||||
			local playername = puncher:get_player_name()
 | 
								local playername = puncher:get_player_name()
 | 
				
			||||||
			print("[Pipeworks] "..playername.." struck a broken tube at "..minetest.pos_to_string(pos))
 | 
								local log_msg = playername.." struck a broken tube at "..minetest.pos_to_string(pos).."\n            "
 | 
				
			||||||
			if   wieldname == "anvil:hammer"
 | 
					 | 
				
			||||||
			  or wieldname == "cottages:hammer"
 | 
					 | 
				
			||||||
			  or wieldname == "glooptest:hammer_steel"
 | 
					 | 
				
			||||||
			  or wieldname == "glooptest:hammer_bronze"
 | 
					 | 
				
			||||||
			  or wieldname == "glooptest:hammer_diamond"
 | 
					 | 
				
			||||||
			  or wieldname == "glooptest:hammer_mese"
 | 
					 | 
				
			||||||
			  or wieldname == "glooptest:hammer_alatro"
 | 
					 | 
				
			||||||
			  or wieldname == "glooptest:hammer_arol" then
 | 
					 | 
				
			||||||
			local meta = minetest.get_meta(pos)
 | 
								local meta = minetest.get_meta(pos)
 | 
				
			||||||
			local was_node = minetest.deserialize(meta:get_string("the_tube_was"))
 | 
								local was_node = minetest.deserialize(meta:get_string("the_tube_was"))
 | 
				
			||||||
				if was_node and was_node ~= "" then
 | 
								if not was_node then
 | 
				
			||||||
					print("            with "..wieldname.." to repair it.")
 | 
									pipeworks.logger(log_msg.."but it can't be repaired.")
 | 
				
			||||||
					minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
 | 
									return
 | 
				
			||||||
					pipeworks.scan_for_tube_objects(pos)
 | 
								end
 | 
				
			||||||
					itemstack:add_wear(1000)
 | 
								if not pipeworks.check_and_wear_hammer(puncher) then
 | 
				
			||||||
					puncher:set_wielded_item(itemstack)
 | 
									if wieldname == "" then
 | 
				
			||||||
					return itemstack
 | 
										pipeworks.logger(log_msg.."by hand. It's not very effective.")
 | 
				
			||||||
				else
 | 
										if minetest.settings:get_bool("enable_damage") then
 | 
				
			||||||
					print("            but it can't be repaired.")
 | 
											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
 | 
										end
 | 
				
			||||||
				else
 | 
									else
 | 
				
			||||||
				print("            with "..wieldname.." but that tool is too weak.")
 | 
										pipeworks.logger(log_msg.."with "..wieldname.." but that tool is too weak.")
 | 
				
			||||||
 | 
									end
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
								log_msg = log_msg.."with "..wieldname.." to repair it"
 | 
				
			||||||
 | 
								local nodedef = minetest.registered_nodes[was_node.name]
 | 
				
			||||||
 | 
								if nodedef then
 | 
				
			||||||
 | 
									pipeworks.logger(log_msg..".")
 | 
				
			||||||
 | 
									if nodedef.tube and nodedef.tube.on_repair then
 | 
				
			||||||
 | 
										nodedef.tube.on_repair(pos, was_node)
 | 
				
			||||||
 | 
									else
 | 
				
			||||||
 | 
										minetest.swap_node(pos, { name = was_node.name, param2 = was_node.param2 })
 | 
				
			||||||
 | 
										pipeworks.scan_for_tube_objects(pos)
 | 
				
			||||||
 | 
									end
 | 
				
			||||||
 | 
								else
 | 
				
			||||||
 | 
									pipeworks.logger(log_msg.." but original node "..was_node.name.." is not registered anymore.")
 | 
				
			||||||
 | 
									minetest.chat_send_player(playername, S("This tube cannot be repaired."))
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -69,7 +107,7 @@ pipeworks.register_tube("pipeworks:broken_tube", {
 | 
				
			|||||||
if pipeworks.enable_priority_tube then
 | 
					if pipeworks.enable_priority_tube then
 | 
				
			||||||
	local color = "#ff3030:128"
 | 
						local color = "#ff3030:128"
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:priority_tube", {
 | 
						pipeworks.register_tube("pipeworks:priority_tube", {
 | 
				
			||||||
			description = "High Priority Tube Segment",
 | 
								description = S("High Priority Tube Segment"),
 | 
				
			||||||
			inventory_image = "pipeworks_tube_inv.png^[colorize:" .. color,
 | 
								inventory_image = "pipeworks_tube_inv.png^[colorize:" .. color,
 | 
				
			||||||
			plain = { { name = "pipeworks_tube_plain.png", color = nodecolor } },
 | 
								plain = { { name = "pipeworks_tube_plain.png", color = nodecolor } },
 | 
				
			||||||
			noctr = { { name = "pipeworks_tube_noctr.png", color = nodecolor } },
 | 
								noctr = { { name = "pipeworks_tube_noctr.png", color = nodecolor } },
 | 
				
			||||||
@@ -79,19 +117,11 @@ if pipeworks.enable_priority_tube then
 | 
				
			|||||||
				tube = { priority = 150 } -- higher than tubedevices (100)
 | 
									tube = { priority = 150 } -- higher than tubedevices (100)
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	minetest.register_craft( {
 | 
					 | 
				
			||||||
		output = "pipeworks:priority_tube_1 6",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
			{ "default:gold_ingot", "", "default:gold_ingot" },
 | 
					 | 
				
			||||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if pipeworks.enable_accelerator_tube then
 | 
					if pipeworks.enable_accelerator_tube then
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:accelerator_tube", {
 | 
						pipeworks.register_tube("pipeworks:accelerator_tube", {
 | 
				
			||||||
			description = "Accelerating Pneumatic Tube Segment",
 | 
								description = S("Accelerating Pneumatic Tube Segment"),
 | 
				
			||||||
			inventory_image = "pipeworks_accelerator_tube_inv.png",
 | 
								inventory_image = "pipeworks_accelerator_tube_inv.png",
 | 
				
			||||||
			plain = { "pipeworks_accelerator_tube_plain.png" },
 | 
								plain = { "pipeworks_accelerator_tube_plain.png" },
 | 
				
			||||||
			noctr = { "pipeworks_accelerator_tube_noctr.png" },
 | 
								noctr = { "pipeworks_accelerator_tube_noctr.png" },
 | 
				
			||||||
@@ -104,19 +134,11 @@ if pipeworks.enable_accelerator_tube then
 | 
				
			|||||||
					end}
 | 
										end}
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	minetest.register_craft( {
 | 
					 | 
				
			||||||
		output = "pipeworks:accelerator_tube_1 2",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
			{ "default:mese_crystal_fragment", "default:steel_ingot", "default:mese_crystal_fragment" },
 | 
					 | 
				
			||||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if pipeworks.enable_crossing_tube then
 | 
					if pipeworks.enable_crossing_tube then
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:crossing_tube", {
 | 
						pipeworks.register_tube("pipeworks:crossing_tube", {
 | 
				
			||||||
			description = "Crossing Pneumatic Tube Segment",
 | 
								description = S("Crossing Pneumatic Tube Segment"),
 | 
				
			||||||
			inventory_image = "pipeworks_crossing_tube_inv.png",
 | 
								inventory_image = "pipeworks_crossing_tube_inv.png",
 | 
				
			||||||
			plain = { "pipeworks_crossing_tube_plain.png" },
 | 
								plain = { "pipeworks_crossing_tube_plain.png" },
 | 
				
			||||||
			noctr = { "pipeworks_crossing_tube_noctr.png" },
 | 
								noctr = { "pipeworks_crossing_tube_noctr.png" },
 | 
				
			||||||
@@ -126,28 +148,30 @@ if pipeworks.enable_crossing_tube then
 | 
				
			|||||||
				tube = {can_go = function(pos, node, velocity, stack) return {velocity} end }
 | 
									tube = {can_go = function(pos, node, velocity, stack) return {velocity} end }
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	minetest.register_craft( {
 | 
					 | 
				
			||||||
		output = "pipeworks:crossing_tube_1 5",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			{ "", "pipeworks:tube_1", "" },
 | 
					 | 
				
			||||||
			{ "pipeworks:tube_1", "pipeworks:tube_1", "pipeworks:tube_1" },
 | 
					 | 
				
			||||||
			{ "", "pipeworks:tube_1", "" }
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local texture_alpha_mode = minetest.features.use_texture_alpha_string_modes
 | 
				
			||||||
 | 
						and "clip" or true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if pipeworks.enable_one_way_tube then
 | 
					if pipeworks.enable_one_way_tube then
 | 
				
			||||||
 | 
						local tiles = {"pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_output.png",
 | 
				
			||||||
 | 
							"pipeworks_one_way_tube_input.png", "pipeworks_one_way_tube_side.png", "pipeworks_one_way_tube_top.png"}
 | 
				
			||||||
 | 
						for i, tile in ipairs(tiles) do
 | 
				
			||||||
 | 
							tiles[i] = pipeworks.make_tube_tile(tile)
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
	minetest.register_node("pipeworks:one_way_tube", {
 | 
						minetest.register_node("pipeworks:one_way_tube", {
 | 
				
			||||||
		description = "One way tube",
 | 
							description = S("One way tube"),
 | 
				
			||||||
		tiles = {"pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_top.png", "pipeworks_one_way_tube_output.png",
 | 
							tiles = tiles,
 | 
				
			||||||
			"pipeworks_one_way_tube_input.png", "pipeworks_one_way_tube_side.png", "pipeworks_one_way_tube_top.png"},
 | 
							use_texture_alpha = texture_alpha_mode,
 | 
				
			||||||
		paramtype2 = "facedir",
 | 
							paramtype2 = "facedir",
 | 
				
			||||||
		drawtype = "nodebox",
 | 
							drawtype = "nodebox",
 | 
				
			||||||
		paramtype = "light",
 | 
							paramtype = "light",
 | 
				
			||||||
		node_box = {type = "fixed",
 | 
							node_box = {type = "fixed",
 | 
				
			||||||
			fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}},
 | 
								fixed = {{-1/2, -9/64, -9/64, 1/2, 9/64, 9/64}}},
 | 
				
			||||||
		groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1},
 | 
							groups = {snappy = 2, choppy = 2, oddly_breakable_by_hand = 2, tubedevice = 1},
 | 
				
			||||||
		sounds = default.node_sound_wood_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_wood_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		tube = {
 | 
							tube = {
 | 
				
			||||||
			connect_sides = {left = 1, right = 1},
 | 
								connect_sides = {left = 1, right = 1},
 | 
				
			||||||
			can_go = function(pos, node, velocity, stack)
 | 
								can_go = function(pos, node, velocity, stack)
 | 
				
			||||||
@@ -162,13 +186,8 @@ if pipeworks.enable_one_way_tube then
 | 
				
			|||||||
		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 = pipeworks.on_rotate,
 | 
							on_rotate = pipeworks.on_rotate,
 | 
				
			||||||
 | 
							check_for_pole = pipeworks.check_for_vert_tube,
 | 
				
			||||||
 | 
							check_for_horiz_pole = pipeworks.check_for_horiz_tube
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	minetest.register_craft({
 | 
						pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:one_way_tube"
 | 
				
			||||||
		output = "pipeworks:one_way_tube 2",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
			{ "group:stick", "default:mese_crystal", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,3 +75,12 @@ pipeworks_drop_on_routing_fail (Drop On Routing Fail) bool false
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#Delete item on clearobject.
 | 
					#Delete item on clearobject.
 | 
				
			||||||
pipeworks_delete_item_on_clearobject (Delete Item On Clearobject) bool true
 | 
					pipeworks_delete_item_on_clearobject (Delete Item On Clearobject) bool true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#Use real visible entities in tubes within active areas.
 | 
				
			||||||
 | 
					#When disabled, tubes are made opaque.
 | 
				
			||||||
 | 
					pipeworks_use_real_entities (Use Real Entities) bool true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#Target interval between tube entity steps.
 | 
				
			||||||
 | 
					#A high value may cause issues with tube entity visuals.
 | 
				
			||||||
 | 
					#A value 0.2 or above may cause issues with accelerator tubes.
 | 
				
			||||||
 | 
					pipeworks_entity_update_interval (Entity Update Interval) float 0 0 0.8
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,17 +1,29 @@
 | 
				
			|||||||
if pipeworks.enable_detector_tube then
 | 
					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 minetest.get_modpath("mesecons") and 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", {
 | 
				
			||||||
			description = "Detecting Pneumatic Tube Segment on (you hacker you)",
 | 
								description = S("Detecting Pneumatic Tube Segment on"),
 | 
				
			||||||
			inventory_image = "pipeworks_detector_tube_inv.png",
 | 
								inventory_image = "pipeworks_detector_tube_inv.png",
 | 
				
			||||||
			plain = { "pipeworks_detector_tube_plain.png" },
 | 
								plain = { "pipeworks_detector_tube_plain.png" },
 | 
				
			||||||
			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},
 | 
				
			||||||
@@ -33,14 +45,12 @@ 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,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:detector_tube_off", {
 | 
						pipeworks.register_tube("pipeworks:detector_tube_off", {
 | 
				
			||||||
			description = "Detecting Pneumatic Tube Segment",
 | 
								description = S("Detecting Pneumatic Tube Segment"),
 | 
				
			||||||
			inventory_image = "pipeworks_detector_tube_inv.png",
 | 
								inventory_image = "pipeworks_detector_tube_inv.png",
 | 
				
			||||||
			plain = { "pipeworks_detector_tube_plain.png" },
 | 
								plain = { "pipeworks_detector_tube_plain.png" },
 | 
				
			||||||
			node_def = {
 | 
								node_def = {
 | 
				
			||||||
@@ -70,7 +80,7 @@ end
 | 
				
			|||||||
local digiline_enabled = minetest.get_modpath("digilines") ~= nil
 | 
					local digiline_enabled = minetest.get_modpath("digilines") ~= nil
 | 
				
			||||||
if digiline_enabled and pipeworks.enable_digiline_detector_tube then
 | 
					if digiline_enabled and pipeworks.enable_digiline_detector_tube then
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:digiline_detector_tube", {
 | 
						pipeworks.register_tube("pipeworks:digiline_detector_tube", {
 | 
				
			||||||
			description = "Digiline Detecting Pneumatic Tube Segment",
 | 
								description = S("Digiline Detecting Pneumatic Tube Segment"),
 | 
				
			||||||
			inventory_image = "pipeworks_digiline_detector_tube_inv.png",
 | 
								inventory_image = "pipeworks_digiline_detector_tube_inv.png",
 | 
				
			||||||
			plain = { "pipeworks_digiline_detector_tube_plain.png" },
 | 
								plain = { "pipeworks_digiline_detector_tube_plain.png" },
 | 
				
			||||||
			node_def = {
 | 
								node_def = {
 | 
				
			||||||
@@ -79,20 +89,27 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
						local setchan = meta:get_string("channel")
 | 
											local setchan = meta:get_string("channel")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						digiline:receptor_send(pos, digiline.rules.default, setchan, stack:to_string())
 | 
											digiline:receptor_send(pos, digiline.rules.default, setchan, stack:to_table())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
						return pipeworks.notvel(pipeworks.meseadjlist, velocity)
 | 
											return pipeworks.notvel(pipeworks.meseadjlist, velocity)
 | 
				
			||||||
					end},
 | 
										end},
 | 
				
			||||||
				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;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;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
 | 
				
			||||||
@@ -120,9 +137,9 @@ if digiline_enabled and pipeworks.enable_digiline_detector_tube then
 | 
				
			|||||||
	})
 | 
						})
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if pipeworks.enable_conductor_tube then
 | 
					if minetest.get_modpath("mesecons") and pipeworks.enable_conductor_tube then
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:conductor_tube_off", {
 | 
						pipeworks.register_tube("pipeworks:conductor_tube_off", {
 | 
				
			||||||
			description = "Conducting Pneumatic Tube Segment",
 | 
								description = S("Conducting Pneumatic Tube Segment"),
 | 
				
			||||||
			inventory_image = "pipeworks_conductor_tube_inv.png",
 | 
								inventory_image = "pipeworks_conductor_tube_inv.png",
 | 
				
			||||||
			short = "pipeworks_conductor_tube_short.png",
 | 
								short = "pipeworks_conductor_tube_short.png",
 | 
				
			||||||
			plain = { "pipeworks_conductor_tube_plain.png" },
 | 
								plain = { "pipeworks_conductor_tube_plain.png" },
 | 
				
			||||||
@@ -136,7 +153,7 @@ if pipeworks.enable_conductor_tube then
 | 
				
			|||||||
			},
 | 
								},
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:conductor_tube_on", {
 | 
						pipeworks.register_tube("pipeworks:conductor_tube_on", {
 | 
				
			||||||
			description = "Conducting Pneumatic Tube Segment on (you hacker you)",
 | 
								description = S("Conducting Pneumatic Tube Segment on"),
 | 
				
			||||||
			inventory_image = "pipeworks_conductor_tube_inv.png",
 | 
								inventory_image = "pipeworks_conductor_tube_inv.png",
 | 
				
			||||||
			short = "pipeworks_conductor_tube_short.png",
 | 
								short = "pipeworks_conductor_tube_short.png",
 | 
				
			||||||
			plain = { "pipeworks_conductor_tube_on_plain.png" },
 | 
								plain = { "pipeworks_conductor_tube_on_plain.png" },
 | 
				
			||||||
@@ -160,7 +177,7 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if digiline_enabled and pipeworks.enable_digiline_conductor_tube then
 | 
					if digiline_enabled and pipeworks.enable_digiline_conductor_tube then
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:digiline_conductor_tube", {
 | 
						pipeworks.register_tube("pipeworks:digiline_conductor_tube", {
 | 
				
			||||||
		description = "Digiline Conducting Pneumatic Tube Segment",
 | 
							description = S("Digiline Conducting Pneumatic Tube Segment"),
 | 
				
			||||||
		inventory_image = "pipeworks_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
 | 
							inventory_image = "pipeworks_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
 | 
				
			||||||
		short = "pipeworks_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
 | 
							short = "pipeworks_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
 | 
				
			||||||
		plain = {"pipeworks_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
 | 
							plain = {"pipeworks_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
 | 
				
			||||||
@@ -178,7 +195,7 @@ end
 | 
				
			|||||||
if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
 | 
					if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
 | 
				
			||||||
		pipeworks.enable_conductor_tube then
 | 
							pipeworks.enable_conductor_tube then
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:mesecon_and_digiline_conductor_tube_off", {
 | 
						pipeworks.register_tube("pipeworks:mesecon_and_digiline_conductor_tube_off", {
 | 
				
			||||||
		description = "Mesecon and Digiline Conducting Pneumatic Tube Segment",
 | 
							description = S("Mesecon and Digiline Conducting Pneumatic Tube Segment"),
 | 
				
			||||||
		inventory_image = "pipeworks_conductor_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
 | 
							inventory_image = "pipeworks_conductor_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
 | 
				
			||||||
		short = "pipeworks_conductor_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
 | 
							short = "pipeworks_conductor_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
 | 
				
			||||||
		plain = {"pipeworks_conductor_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
 | 
							plain = {"pipeworks_conductor_tube_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
 | 
				
			||||||
@@ -195,7 +212,7 @@ if digiline_enabled and pipeworks.enable_digiline_conductor_tube and
 | 
				
			|||||||
		},
 | 
							},
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:mesecon_and_digiline_conductor_tube_on", {
 | 
						pipeworks.register_tube("pipeworks:mesecon_and_digiline_conductor_tube_on", {
 | 
				
			||||||
		description = "Mesecon and Digiline Conducting Pneumatic Tube Segment on (you hacker you)",
 | 
							description = S("Mesecon and Digiline Conducting Pneumatic Tube Segment on"),
 | 
				
			||||||
		inventory_image = "pipeworks_conductor_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
 | 
							inventory_image = "pipeworks_conductor_tube_inv.png^pipeworks_digiline_conductor_tube_inv.png",
 | 
				
			||||||
		short = "pipeworks_conductor_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
 | 
							short = "pipeworks_conductor_tube_short.png^pipeworks_digiline_conductor_tube_short.png",
 | 
				
			||||||
		plain = {"pipeworks_conductor_tube_on_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
 | 
							plain = {"pipeworks_conductor_tube_on_plain.png^pipeworks_digiline_conductor_tube_plain.png"},
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										241
									
								
								signs_compat.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										241
									
								
								signs_compat.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,241 @@
 | 
				
			|||||||
 | 
					-- This file adds placement rules for signs_lib, if present
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local spv = {
 | 
				
			||||||
 | 
						[4] = true,
 | 
				
			||||||
 | 
						[6] = true,
 | 
				
			||||||
 | 
						[8] = true,
 | 
				
			||||||
 | 
						[10] = true,
 | 
				
			||||||
 | 
						[13] = true,
 | 
				
			||||||
 | 
						[15] = true,
 | 
				
			||||||
 | 
						[17] = true,
 | 
				
			||||||
 | 
						[19] = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local sphns = {
 | 
				
			||||||
 | 
						[1] = true,
 | 
				
			||||||
 | 
						[3] = true,
 | 
				
			||||||
 | 
						[5] = true,
 | 
				
			||||||
 | 
						[7] = true,
 | 
				
			||||||
 | 
						[9] = true,
 | 
				
			||||||
 | 
						[11] = true,
 | 
				
			||||||
 | 
						[21] = true,
 | 
				
			||||||
 | 
						[23] = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local sphew = {
 | 
				
			||||||
 | 
						[0] = true,
 | 
				
			||||||
 | 
						[2] = true,
 | 
				
			||||||
 | 
						[12] = true,
 | 
				
			||||||
 | 
						[14] = true,
 | 
				
			||||||
 | 
						[16] = true,
 | 
				
			||||||
 | 
						[18] = true,
 | 
				
			||||||
 | 
						[20] = true,
 | 
				
			||||||
 | 
						[22] = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local owtv = {
 | 
				
			||||||
 | 
						[5] = true,
 | 
				
			||||||
 | 
						[7] = true,
 | 
				
			||||||
 | 
						[9] = true,
 | 
				
			||||||
 | 
						[11] = true,
 | 
				
			||||||
 | 
						[12] = true,
 | 
				
			||||||
 | 
						[14] = true,
 | 
				
			||||||
 | 
						[16] = true,
 | 
				
			||||||
 | 
						[18] = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local owtns = {
 | 
				
			||||||
 | 
						[0] = true,
 | 
				
			||||||
 | 
						[2] = true,
 | 
				
			||||||
 | 
						[4] = true,
 | 
				
			||||||
 | 
						[6] = true,
 | 
				
			||||||
 | 
						[8] = true,
 | 
				
			||||||
 | 
						[10] = true,
 | 
				
			||||||
 | 
						[20] = true,
 | 
				
			||||||
 | 
						[22] = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local owtew = {
 | 
				
			||||||
 | 
						[1] = true,
 | 
				
			||||||
 | 
						[3] = true,
 | 
				
			||||||
 | 
						[13] = true,
 | 
				
			||||||
 | 
						[15] = true,
 | 
				
			||||||
 | 
						[17] = true,
 | 
				
			||||||
 | 
						[19] = true,
 | 
				
			||||||
 | 
						[21] = true,
 | 
				
			||||||
 | 
						[23] = true
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local vert_n = {
 | 
				
			||||||
 | 
						[3] = {[5] = true},
 | 
				
			||||||
 | 
						[6] = {[9] = true, [12] = true, [16] = true},
 | 
				
			||||||
 | 
						[7] = {[9] = true, [11] = true},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local vert_e = {
 | 
				
			||||||
 | 
						[3] = {[5] = true},
 | 
				
			||||||
 | 
						[6] = {[5] = true, [9] = true, [16] = true},
 | 
				
			||||||
 | 
						[7] = {[7] = true, [11] = true},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local vert_s = {
 | 
				
			||||||
 | 
						[3] = {[5] = true},
 | 
				
			||||||
 | 
						[6] = {[5] = true, [12] = true, [16] = true},
 | 
				
			||||||
 | 
						[7] = {[5] = true, [7] = true},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local vert_w = {
 | 
				
			||||||
 | 
						[3] = {[5] = true},
 | 
				
			||||||
 | 
						[6] = {[5] = true, [9] = true, [12] = true},
 | 
				
			||||||
 | 
						[7] = {[5] = true, [9] = true},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local horiz_n = {
 | 
				
			||||||
 | 
						[3] = {[0] = true},
 | 
				
			||||||
 | 
						[6] = {[0] = true, [4] = true, [20] = true},
 | 
				
			||||||
 | 
						[7] = {[2] = true, [10] = true},
 | 
				
			||||||
 | 
						[8] = {[0] = true},
 | 
				
			||||||
 | 
						[9] = {[2] = true},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local horiz_e = {
 | 
				
			||||||
 | 
						[3] = {[1] = true},
 | 
				
			||||||
 | 
						[6] = {[1] = true, [17] = true, [21] = true},
 | 
				
			||||||
 | 
						[7] = {[3] = true, [19] = true},
 | 
				
			||||||
 | 
						[8] = {[1] = true},
 | 
				
			||||||
 | 
						[9] = {[3] = true},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local horiz_s = {
 | 
				
			||||||
 | 
						[3] = {[0] = true},
 | 
				
			||||||
 | 
						[6] = {[0] = true, [8] = true, [20] = true},
 | 
				
			||||||
 | 
						[7] = {[0] = true, [4] = true},
 | 
				
			||||||
 | 
						[8] = {[0] = true},
 | 
				
			||||||
 | 
						[9] = {[0] = true},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local horiz_w = {
 | 
				
			||||||
 | 
						[3] = {[1] = true},
 | 
				
			||||||
 | 
						[6] = {[1] = true, [13] = true, [21] = true},
 | 
				
			||||||
 | 
						[7] = {[1] = true, [13] = true},
 | 
				
			||||||
 | 
						[8] = {[1] = true},
 | 
				
			||||||
 | 
						[9] = {[1] = true},
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					local function get_sign_dir(node, def)
 | 
				
			||||||
 | 
						if (node.param2 == 4 and def.paramtype2 == "wallmounted")
 | 
				
			||||||
 | 
						  or (node.param2 == 0 and def.paramtype2 ~= "wallmounted") then
 | 
				
			||||||
 | 
							return {["N"] = true}
 | 
				
			||||||
 | 
						elseif (node.param2 == 2 and def.paramtype2 == "wallmounted")
 | 
				
			||||||
 | 
						  or (node.param2 == 1 and def.paramtype2 ~= "wallmounted") then
 | 
				
			||||||
 | 
							return {["E"] = true}
 | 
				
			||||||
 | 
						elseif (node.param2 == 5 and def.paramtype2 == "wallmounted")
 | 
				
			||||||
 | 
						  or (node.param2 == 2 and def.paramtype2 ~= "wallmounted") then
 | 
				
			||||||
 | 
							return {["S"] = true}
 | 
				
			||||||
 | 
						elseif node.param2 == 3 then
 | 
				
			||||||
 | 
							return {["W"] = true}
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
						return {}
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--[[
 | 
				
			||||||
 | 
					In the functions below:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 pos: the (real) position of the placed sign
 | 
				
			||||||
 | 
					 node: the sign node itself
 | 
				
			||||||
 | 
					 def: its definition
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 ppos: the position of the pointed node (pipe/tube)
 | 
				
			||||||
 | 
					 pnode: the node itself
 | 
				
			||||||
 | 
					 pdef: its definition
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					--]]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- pipes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function pipeworks.check_for_vert_pipe(pos, node, def, ppos, pnode, pdef)
 | 
				
			||||||
 | 
						local signdir = get_sign_dir(node, def)
 | 
				
			||||||
 | 
						local pipenumber = pdef.pipenumber
 | 
				
			||||||
 | 
						local pipedir = pnode.param2
 | 
				
			||||||
 | 
						if string.find(pnode.name, "straight_pipe") and spv[pipedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["N"] and vert_n[pipenumber] and vert_n[pipenumber][pipedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["E"] and vert_e[pipenumber] and vert_e[pipenumber][pipedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["S"] and vert_s[pipenumber] and vert_s[pipenumber][pipedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["W"] and vert_w[pipenumber] and vert_w[pipenumber][pipedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function pipeworks.check_for_horiz_pipe(pos, node, def, ppos, pnode, pdef)
 | 
				
			||||||
 | 
						local signdir = get_sign_dir(node, def)
 | 
				
			||||||
 | 
						local pipenumber = pdef.pipenumber
 | 
				
			||||||
 | 
						local pipedir = pnode.param2
 | 
				
			||||||
 | 
						if string.find(pnode.name, "straight_pipe") then
 | 
				
			||||||
 | 
							if (signdir["N"] or signdir["S"]) and sphns[pipedir] then
 | 
				
			||||||
 | 
								return true
 | 
				
			||||||
 | 
							elseif (signdir["E"] or signdir["W"]) and sphew[pipedir] then
 | 
				
			||||||
 | 
								return true
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						elseif signdir["N"] and horiz_n[pipenumber] and horiz_n[pipenumber][pipedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["E"] and horiz_e[pipenumber] and horiz_e[pipenumber][pipedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["S"] and horiz_s[pipenumber] and horiz_s[pipenumber][pipedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["W"] and horiz_w[pipenumber] and horiz_w[pipenumber][pipedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- tubes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function pipeworks.check_for_vert_tube(pos, node, def, ppos, pnode, pdef)
 | 
				
			||||||
 | 
						local signdir = get_sign_dir(node, def)
 | 
				
			||||||
 | 
						local tubenumber = pdef.tubenumber
 | 
				
			||||||
 | 
						local tubedir = pnode.param2
 | 
				
			||||||
 | 
						if pnode.name == "pipeworks:one_way_tube" and owtv[tubedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif tubenumber == 2 and (tubedir == 5 or tubedir == 7) then -- it's a stub pointing up or down
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["N"] and vert_n[tubenumber] and vert_n[tubenumber][tubedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["E"] and vert_e[tubenumber] and vert_e[tubenumber][tubedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["S"] and vert_s[tubenumber] and vert_s[tubenumber][tubedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["W"] and vert_w[tubenumber] and vert_w[tubenumber][tubedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function pipeworks.check_for_horiz_tube(pos, node, def, ppos, pnode, pdef)
 | 
				
			||||||
 | 
						local signdir = get_sign_dir(node, def)
 | 
				
			||||||
 | 
						local tubenumber = pdef.tubenumber
 | 
				
			||||||
 | 
						local tubedir = pnode.param2
 | 
				
			||||||
 | 
						if tubenumber == 2 then -- it'a a stub pointing sideways
 | 
				
			||||||
 | 
							if (tubedir == 0 or tubedir == 2) and (signdir["N"] or signdir["S"]) then
 | 
				
			||||||
 | 
								return true
 | 
				
			||||||
 | 
							elseif (tubedir == 1 or tubedir == 3) and (signdir["E"] or signdir["W"]) then
 | 
				
			||||||
 | 
								return true
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						elseif pnode.name == "pipeworks:one_way_tube" then
 | 
				
			||||||
 | 
							if (signdir["N"] or signdir["S"]) and owtns[tubedir] then
 | 
				
			||||||
 | 
								return true
 | 
				
			||||||
 | 
							elseif (signdir["E"] or signdir["W"]) and owtew[tubedir] then
 | 
				
			||||||
 | 
								return true
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						elseif signdir["N"] and horiz_n[tubenumber] and horiz_n[tubenumber][tubedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["E"] and horiz_e[tubenumber] and horiz_e[tubenumber][tubedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["S"] and horiz_s[tubenumber] and horiz_s[tubenumber][tubedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						elseif signdir["W"] and horiz_w[tubenumber] and horiz_w[tubenumber][tubedir] then
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					end
 | 
				
			||||||
@@ -1,3 +1,4 @@
 | 
				
			|||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
local fs_helpers = pipeworks.fs_helpers
 | 
					local fs_helpers = pipeworks.fs_helpers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if pipeworks.enable_mese_tube then
 | 
					if pipeworks.enable_mese_tube then
 | 
				
			||||||
@@ -15,29 +16,43 @@ if pipeworks.enable_mese_tube then
 | 
				
			|||||||
		local buttons_formspec = ""
 | 
							local buttons_formspec = ""
 | 
				
			||||||
		for i = 0, 5 do
 | 
							for i = 0, 5 do
 | 
				
			||||||
			buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta,
 | 
								buttons_formspec = buttons_formspec .. fs_helpers.cycling_button(meta,
 | 
				
			||||||
				"image_button[7,"..(i+0.2)..";1,0.6", "l"..(i+1).."s",
 | 
									"image_button[9,"..(i+(i*0.25)+0.5)..";1,0.6", "l"..(i+1).."s",
 | 
				
			||||||
				{
 | 
									{
 | 
				
			||||||
					pipeworks.button_off,
 | 
										pipeworks.button_off,
 | 
				
			||||||
					pipeworks.button_on
 | 
										pipeworks.button_on
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			)
 | 
								)
 | 
				
			||||||
		end
 | 
							end
 | 
				
			||||||
 | 
							local list_backgrounds = ""
 | 
				
			||||||
 | 
							if minetest.get_modpath("i3") then
 | 
				
			||||||
 | 
								list_backgrounds = "style_type[box;colors=#666]"
 | 
				
			||||||
 | 
								for i=0, 5 do
 | 
				
			||||||
 | 
									for j=0, 5 do
 | 
				
			||||||
 | 
										list_backgrounds = list_backgrounds .. "box[".. 1.5+(i*1.25) ..",".. 0.25+(j*1.25) ..";1,1;]"
 | 
				
			||||||
 | 
									end
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
							local size = "10.2,13"
 | 
				
			||||||
		meta:set_string("formspec",
 | 
							meta:set_string("formspec",
 | 
				
			||||||
			"size[8,11]"..
 | 
								"formspec_version[2]"..
 | 
				
			||||||
			"list[context;line1;1,0;6,1;]"..
 | 
								"size["..size.."]"..
 | 
				
			||||||
			"list[context;line2;1,1;6,1;]"..
 | 
								pipeworks.fs_helpers.get_prepends(size)..
 | 
				
			||||||
			"list[context;line3;1,2;6,1;]"..
 | 
								"list[context;line1;1.5,0.25;6,1;]"..
 | 
				
			||||||
			"list[context;line4;1,3;6,1;]"..
 | 
								"list[context;line2;1.5,1.50;6,1;]"..
 | 
				
			||||||
			"list[context;line5;1,4;6,1;]"..
 | 
								"list[context;line3;1.5,2.75;6,1;]"..
 | 
				
			||||||
			"list[context;line6;1,5;6,1;]"..
 | 
								"list[context;line4;1.5,4.00;6,1;]"..
 | 
				
			||||||
			"image[0,0;1,1;pipeworks_white.png]"..
 | 
								"list[context;line5;1.5,5.25;6,1;]"..
 | 
				
			||||||
			"image[0,1;1,1;pipeworks_black.png]"..
 | 
								"list[context;line6;1.5,6.50;6,1;]"..
 | 
				
			||||||
			"image[0,2;1,1;pipeworks_green.png]"..
 | 
								list_backgrounds..
 | 
				
			||||||
			"image[0,3;1,1;pipeworks_yellow.png]"..
 | 
								"image[0.22,0.25;1,1;pipeworks_white.png]"..
 | 
				
			||||||
			"image[0,4;1,1;pipeworks_blue.png]"..
 | 
								"image[0.22,1.50;1,1;pipeworks_black.png]"..
 | 
				
			||||||
			"image[0,5;1,1;pipeworks_red.png]"..
 | 
								"image[0.22,2.75;1,1;pipeworks_green.png]"..
 | 
				
			||||||
 | 
								"image[0.22,4.00;1,1;pipeworks_yellow.png]"..
 | 
				
			||||||
 | 
								"image[0.22,5.25;1,1;pipeworks_blue.png]"..
 | 
				
			||||||
 | 
								"image[0.22,6.50;1,1;pipeworks_red.png]"..
 | 
				
			||||||
			buttons_formspec..
 | 
								buttons_formspec..
 | 
				
			||||||
			"list[current_player;main;0,7;8,4;]" ..
 | 
								--"list[current_player;main;0,8;8,4;]" ..
 | 
				
			||||||
 | 
								pipeworks.fs_helpers.get_inv(8)..
 | 
				
			||||||
			"listring[current_player;main]" ..
 | 
								"listring[current_player;main]" ..
 | 
				
			||||||
			"listring[current_player;main]" ..
 | 
								"listring[current_player;main]" ..
 | 
				
			||||||
			"listring[context;line1]" ..
 | 
								"listring[context;line1]" ..
 | 
				
			||||||
@@ -55,7 +70,7 @@ if pipeworks.enable_mese_tube then
 | 
				
			|||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:mese_tube", {
 | 
						pipeworks.register_tube("pipeworks:mese_tube", {
 | 
				
			||||||
			description = "Sorting Pneumatic Tube Segment",
 | 
								description = S("Sorting Pneumatic Tube Segment"),
 | 
				
			||||||
			inventory_image = "pipeworks_mese_tube_inv.png",
 | 
								inventory_image = "pipeworks_mese_tube_inv.png",
 | 
				
			||||||
			noctr = {"pipeworks_mese_tube_noctr_1.png", "pipeworks_mese_tube_noctr_2.png", "pipeworks_mese_tube_noctr_3.png",
 | 
								noctr = {"pipeworks_mese_tube_noctr_1.png", "pipeworks_mese_tube_noctr_2.png", "pipeworks_mese_tube_noctr_3.png",
 | 
				
			||||||
				"pipeworks_mese_tube_noctr_4.png", "pipeworks_mese_tube_noctr_5.png", "pipeworks_mese_tube_noctr_6.png"},
 | 
									"pipeworks_mese_tube_noctr_4.png", "pipeworks_mese_tube_noctr_5.png", "pipeworks_mese_tube_noctr_6.png"},
 | 
				
			||||||
@@ -107,11 +122,24 @@ if pipeworks.enable_mese_tube then
 | 
				
			|||||||
						inv:set_size("line"..tostring(i), 6*1)
 | 
											inv:set_size("line"..tostring(i), 6*1)
 | 
				
			||||||
					end
 | 
										end
 | 
				
			||||||
					update_formspec(pos)
 | 
										update_formspec(pos)
 | 
				
			||||||
					meta:set_string("infotext", "Sorting pneumatic tube")
 | 
										meta:set_string("infotext", S("Sorting pneumatic tube"))
 | 
				
			||||||
 | 
									end,
 | 
				
			||||||
 | 
									after_place_node = function(pos, placer, itemstack, pointed_thing)
 | 
				
			||||||
 | 
										if placer and placer:is_player() and placer:get_player_control().aux1 then
 | 
				
			||||||
 | 
											local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
											for i = 1, 6 do
 | 
				
			||||||
 | 
												meta:set_int("l"..tostring(i).."s", 0)
 | 
				
			||||||
 | 
											end
 | 
				
			||||||
 | 
											update_formspec(pos)
 | 
				
			||||||
 | 
										end
 | 
				
			||||||
 | 
										return pipeworks.after_place(pos, placer, itemstack, pointed_thing)
 | 
				
			||||||
				end,
 | 
									end,
 | 
				
			||||||
				on_punch = update_formspec,
 | 
									on_punch = update_formspec,
 | 
				
			||||||
				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 not pipeworks.may_configure(pos, sender) then
 | 
				
			||||||
 | 
											return
 | 
				
			||||||
 | 
										end
 | 
				
			||||||
					fs_helpers.on_receive_fields(pos, fields)
 | 
										fs_helpers.on_receive_fields(pos, fields)
 | 
				
			||||||
					update_formspec(pos)
 | 
										update_formspec(pos)
 | 
				
			||||||
				end,
 | 
									end,
 | 
				
			||||||
@@ -149,25 +177,4 @@ if pipeworks.enable_mese_tube then
 | 
				
			|||||||
				end,
 | 
									end,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					 | 
				
			||||||
	minetest.register_craft( {
 | 
					 | 
				
			||||||
		output = "pipeworks:mese_tube_000000 2",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
			{ "", "default:mese_crystal", "" },
 | 
					 | 
				
			||||||
			{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	minetest.register_craft( {
 | 
					 | 
				
			||||||
		type = "shapeless",
 | 
					 | 
				
			||||||
		output = "pipeworks:mese_tube_000000",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			"pipeworks:tube_1",
 | 
					 | 
				
			||||||
			"default:mese_crystal_fragment",
 | 
					 | 
				
			||||||
			"default:mese_crystal_fragment",
 | 
					 | 
				
			||||||
			"default:mese_crystal_fragment",
 | 
					 | 
				
			||||||
			"default:mese_crystal_fragment"
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,12 @@
 | 
				
			|||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
local filename=minetest.get_worldpath() .. "/teleport_tubes"
 | 
					local filename=minetest.get_worldpath() .. "/teleport_tubes"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local tp_tube_db = nil -- nil forces a read
 | 
					local tp_tube_db = nil -- nil forces a read
 | 
				
			||||||
local tp_tube_db_version = 2.0
 | 
					local tp_tube_db_version = 2.0
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- cached rceiver list: hash(pos) => {receivers}
 | 
				
			||||||
 | 
					local cache = {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function hash(pos)
 | 
					local function hash(pos)
 | 
				
			||||||
	return string.format("%.30g", minetest.hash_node_position(pos))
 | 
						return string.format("%.30g", minetest.hash_node_position(pos))
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@@ -17,12 +21,14 @@ local function save_tube_db()
 | 
				
			|||||||
	else
 | 
						else
 | 
				
			||||||
		error(err)
 | 
							error(err)
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
						-- reset tp-tube cache
 | 
				
			||||||
 | 
						cache = {}
 | 
				
			||||||
end
 | 
					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
 | 
				
			||||||
@@ -100,6 +106,12 @@ local function read_node_with_vm(pos)
 | 
				
			|||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function get_receivers(pos, channel)
 | 
					local function get_receivers(pos, channel)
 | 
				
			||||||
 | 
						local hash = minetest.hash_node_position(pos)
 | 
				
			||||||
 | 
						if cache[hash] then
 | 
				
			||||||
 | 
							-- re-use cached result
 | 
				
			||||||
 | 
							return cache[hash]
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local tubes = tp_tube_db or read_tube_db()
 | 
						local tubes = tp_tube_db or read_tube_db()
 | 
				
			||||||
	local receivers = {}
 | 
						local receivers = {}
 | 
				
			||||||
	local dirty = false
 | 
						local dirty = false
 | 
				
			||||||
@@ -120,26 +132,34 @@ local function get_receivers(pos, channel)
 | 
				
			|||||||
	if dirty then
 | 
						if dirty then
 | 
				
			||||||
		save_tube_db()
 | 
							save_tube_db()
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
						-- cache the result for next time
 | 
				
			||||||
 | 
						cache[hash] = receivers
 | 
				
			||||||
	return receivers
 | 
						return receivers
 | 
				
			||||||
end
 | 
					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;Channel:;${channel}]"..
 | 
							S("Use <player>:<channel> for fully private channels").."\n"..
 | 
				
			||||||
			"label[7.3,0;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]"..
 | 
						local size = "8.5,4"
 | 
				
			||||||
			"image[0.3,1.3;1,1;pipeworks_teleport_tube_inv.png]"..
 | 
						meta:set_string("formspec",
 | 
				
			||||||
			"label[1.6,1.2;channels are public by default]" ..
 | 
							"formspec_version[2]"..
 | 
				
			||||||
			"label[1.6,1.5;use <player>:<channel> for fully private channels]" ..
 | 
							"size["..size.."]"..
 | 
				
			||||||
			"label[1.6,1.8;use <player>\\;<channel> for private receivers]" ..
 | 
							pipeworks.fs_helpers.get_prepends(size) ..
 | 
				
			||||||
			default.gui_bg..
 | 
							"image[0.5,o;1,1;pipeworks_teleport_tube_inv.png]"..
 | 
				
			||||||
			default.gui_bg_img)
 | 
							"label[1.5,0.5;"..S("Teleporting Tube").."]"..
 | 
				
			||||||
 | 
							"field[0.5,1.6;4.3,0.75;channel;"..S("Channel")..";${channel}]"..
 | 
				
			||||||
 | 
							"button[4.8,1.6;1.5,0.75;set_channel;"..S("Set").."]"..
 | 
				
			||||||
 | 
							"label[7.0,0.5;"..S("Receive").."]"..
 | 
				
			||||||
 | 
							"image_button[7.0,0.75;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.6;2,0.75;close;"..S("Close").."]"..
 | 
				
			||||||
 | 
							"label[0.5,2.7;"..itext.."]")
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pipeworks.register_tube("pipeworks:teleport_tube", {
 | 
					pipeworks.register_tube("pipeworks:teleport_tube", {
 | 
				
			||||||
	description = "Teleporting Pneumatic Tube Segment",
 | 
						description = S("Teleporting Pneumatic Tube Segment"),
 | 
				
			||||||
	inventory_image = "pipeworks_teleport_tube_inv.png",
 | 
						inventory_image = "pipeworks_teleport_tube_inv.png",
 | 
				
			||||||
	noctr = { "pipeworks_teleport_tube_noctr.png" },
 | 
						noctr = { "pipeworks_teleport_tube_noctr.png" },
 | 
				
			||||||
	plain = { "pipeworks_teleport_tube_plain.png" },
 | 
						plain = { "pipeworks_teleport_tube_plain.png" },
 | 
				
			||||||
@@ -164,15 +184,28 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
 | 
				
			|||||||
				pos.y = target[d].y
 | 
									pos.y = target[d].y
 | 
				
			||||||
				pos.z = target[d].z
 | 
									pos.z = target[d].z
 | 
				
			||||||
				return pipeworks.meseadjlist
 | 
									return pipeworks.meseadjlist
 | 
				
			||||||
 | 
								end,
 | 
				
			||||||
 | 
								on_repair = function(pos, node)
 | 
				
			||||||
 | 
									local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
									local channel = meta:get_string("channel")
 | 
				
			||||||
 | 
									minetest.swap_node(pos, { name = node.name, param2 = node.param2 })
 | 
				
			||||||
 | 
									pipeworks.scan_for_tube_objects(pos)
 | 
				
			||||||
 | 
									if channel ~= "" then
 | 
				
			||||||
 | 
										local can_receive = meta:get_int("can_receive")
 | 
				
			||||||
 | 
										set_tube(pos, channel, can_receive)
 | 
				
			||||||
 | 
										local cr_description = (can_receive == 1) and "sending and receiving" or "sending"
 | 
				
			||||||
 | 
										meta:set_string("infotext", S("Teleportation Tube @1 on '@2'", cr_description, channel))
 | 
				
			||||||
 | 
									end
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		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", "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
 | 
				
			||||||
@@ -189,12 +222,14 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
 | 
				
			|||||||
				if name and mode and name ~= sender_name then
 | 
									if name and mode and name ~= sender_name then
 | 
				
			||||||
					--channels starting with '[name]:' can only be used by the named player
 | 
										--channels starting with '[name]:' can only be used by the named player
 | 
				
			||||||
					if mode == ":" then
 | 
										if mode == ":" then
 | 
				
			||||||
						minetest.chat_send_player(sender_name, "Sorry, channel '"..new_channel.."' is reserved for exclusive use by "..name)
 | 
											minetest.chat_send_player(sender_name, S("Sorry, channel '@1' is reserved for exclusive use by @2",
 | 
				
			||||||
 | 
												new_channel, name))
 | 
				
			||||||
						return
 | 
											return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					--channels starting with '[name];' can be used by other players, but cannot be received from
 | 
										--channels starting with '[name];' can be used by other players, but cannot be received from
 | 
				
			||||||
					elseif mode == ";" and (fields.cr1 or (can_receive ~= 0 and not fields.cr0)) then
 | 
										elseif mode == ";" and (fields.cr1 or (can_receive ~= 0 and not fields.cr0)) then
 | 
				
			||||||
						minetest.chat_send_player(sender_name, "Sorry, receiving from channel '"..new_channel.."' is reserved for "..name)
 | 
											minetest.chat_send_player(sender_name, S("Sorry, receiving from channel '@1' is reserved for @2",
 | 
				
			||||||
 | 
												new_channel, name))
 | 
				
			||||||
						return
 | 
											return
 | 
				
			||||||
					end
 | 
										end
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
@@ -204,7 +239,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
 | 
				
			||||||
@@ -226,11 +261,11 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
 | 
				
			|||||||
				if channel ~= "" then
 | 
									if channel ~= "" then
 | 
				
			||||||
					set_tube(pos, channel, can_receive)
 | 
										set_tube(pos, channel, can_receive)
 | 
				
			||||||
					local cr_description = (can_receive == 1) and "sending and receiving" or "sending"
 | 
										local cr_description = (can_receive == 1) and "sending and receiving" or "sending"
 | 
				
			||||||
					meta:set_string("infotext", string.format("Teleportation Tube %s on '%s'", cr_description, channel))
 | 
										meta:set_string("infotext", S("Teleportation Tube @1 on '@2'", cr_description, channel))
 | 
				
			||||||
				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", "unconfigured Teleportation Tube")
 | 
										meta:set_string("infotext", S("Unconfigured Teleportation Tube"))
 | 
				
			||||||
				end
 | 
									end
 | 
				
			||||||
			end
 | 
								end
 | 
				
			||||||
		end,
 | 
							end,
 | 
				
			||||||
@@ -239,14 +274,6 @@ pipeworks.register_tube("pipeworks:teleport_tube", {
 | 
				
			|||||||
		end
 | 
							end
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
})
 | 
					})
 | 
				
			||||||
minetest.register_craft( {
 | 
					 | 
				
			||||||
	output = "pipeworks:teleport_tube_1 2",
 | 
					 | 
				
			||||||
	recipe = {
 | 
					 | 
				
			||||||
	        { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
	        { "default:desert_stone", "default:mese", "default:desert_stone" },
 | 
					 | 
				
			||||||
	        { "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
if minetest.get_modpath("mesecons_mvps") ~= nil then
 | 
					if minetest.get_modpath("mesecons_mvps") ~= nil then
 | 
				
			||||||
	mesecon.register_on_mvps_move(function(moved_nodes)
 | 
						mesecon.register_on_mvps_move(function(moved_nodes)
 | 
				
			||||||
@@ -258,3 +285,13 @@ if minetest.get_modpath("mesecons_mvps") ~= nil then
 | 
				
			|||||||
		end
 | 
							end
 | 
				
			||||||
	end)
 | 
						end)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					-- Expose teleport tube database API for other mods
 | 
				
			||||||
 | 
					pipeworks.tptube = {
 | 
				
			||||||
 | 
						hash = hash,
 | 
				
			||||||
 | 
						save_tube_db = save_tube_db,
 | 
				
			||||||
 | 
						get_db = function() return tp_tube_db or read_tube_db() end,
 | 
				
			||||||
 | 
						set_tube = set_tube,
 | 
				
			||||||
 | 
						update_meta = update_meta,
 | 
				
			||||||
 | 
						tp_tube_db_version = tp_tube_db_version
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										44
									
								
								trashcan.lua
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								trashcan.lua
									
									
									
									
									
								
							@@ -1,5 +1,6 @@
 | 
				
			|||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
minetest.register_node("pipeworks:trashcan", {
 | 
					minetest.register_node("pipeworks:trashcan", {
 | 
				
			||||||
	description = "Trash Can", 
 | 
						description = S("Trash Can"),
 | 
				
			||||||
	drawtype = "normal",
 | 
						drawtype = "normal",
 | 
				
			||||||
	tiles = {
 | 
						tiles = {
 | 
				
			||||||
		"pipeworks_trashcan_bottom.png",
 | 
							"pipeworks_trashcan_bottom.png",
 | 
				
			||||||
@@ -9,7 +10,7 @@ minetest.register_node("pipeworks:trashcan", {
 | 
				
			|||||||
		"pipeworks_trashcan_side.png",
 | 
							"pipeworks_trashcan_side.png",
 | 
				
			||||||
		"pipeworks_trashcan_side.png",
 | 
							"pipeworks_trashcan_side.png",
 | 
				
			||||||
	},
 | 
						},
 | 
				
			||||||
	groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1}, 
 | 
						groups = {snappy = 3, tubedevice = 1, tubedevice_receiver = 1, dig_generic = 4},
 | 
				
			||||||
	tube = {
 | 
						tube = {
 | 
				
			||||||
		insert_object = function(pos, node, stack, direction)
 | 
							insert_object = function(pos, node, stack, direction)
 | 
				
			||||||
			return ItemStack("")
 | 
								return ItemStack("")
 | 
				
			||||||
@@ -19,18 +20,25 @@ minetest.register_node("pipeworks:trashcan", {
 | 
				
			|||||||
	},
 | 
						},
 | 
				
			||||||
	on_construct = function(pos)
 | 
						on_construct = function(pos)
 | 
				
			||||||
		local meta = minetest.get_meta(pos)
 | 
							local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
							local size = "10.2,9"
 | 
				
			||||||
 | 
							local list_background = ""
 | 
				
			||||||
 | 
							if minetest.get_modpath("i3") then
 | 
				
			||||||
 | 
								list_background = "style_type[box;colors=#666]box[4.5,2;1,1;]"
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
		meta:set_string("formspec",
 | 
							meta:set_string("formspec",
 | 
				
			||||||
				"size[8,7]"..
 | 
								"formspec_version[2]" ..
 | 
				
			||||||
				"item_image[0,0;1,1;pipeworks:trashcan]"..
 | 
								"size["..size.."]"..
 | 
				
			||||||
				"label[1,0;Trash Can]"..
 | 
								pipeworks.fs_helpers.get_prepends(size) ..
 | 
				
			||||||
				"list[context;trash;3.5,1;1,1;]"..
 | 
								"item_image[0.5,0.5;1,1;pipeworks:trashcan]"..
 | 
				
			||||||
				default.gui_bg..
 | 
								"label[1.5,1;"..S("Trash Can").."]"..
 | 
				
			||||||
				default.gui_bg_img..
 | 
								list_background..
 | 
				
			||||||
				default.gui_slots..
 | 
								"list[context;trash;4.5,2;1,1;]"..
 | 
				
			||||||
				default.get_hotbar_bg(0,3) ..
 | 
								--"list[current_player;main;0,3;8,4;]" ..
 | 
				
			||||||
				"list[current_player;main;0,3;8,4;]" ..
 | 
								pipeworks.fs_helpers.get_inv(4)..
 | 
				
			||||||
				"listring[]")
 | 
								"listring[context;trash]"..
 | 
				
			||||||
		meta:set_string("infotext", "Trash Can")
 | 
								"listring[current_player;main]"
 | 
				
			||||||
 | 
							)
 | 
				
			||||||
 | 
							meta:set_string("infotext", S("Trash Can"))
 | 
				
			||||||
		meta:get_inventory():set_size("trash", 1)
 | 
							meta:get_inventory():set_size("trash", 1)
 | 
				
			||||||
	end,
 | 
						end,
 | 
				
			||||||
	after_place_node = pipeworks.after_place,
 | 
						after_place_node = pipeworks.after_place,
 | 
				
			||||||
@@ -39,12 +47,4 @@ 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({
 | 
					 | 
				
			||||||
	output = "pipeworks:trashcan",
 | 
					 | 
				
			||||||
	recipe = {
 | 
					 | 
				
			||||||
		{ "basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
		{ "default:steel_ingot", "", "default:steel_ingot" },
 | 
					 | 
				
			||||||
		{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
 | 
					 | 
				
			||||||
	},
 | 
					 | 
				
			||||||
})
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
-- This file supplies the various kinds of pneumatic tubes
 | 
					-- This file supplies the various kinds of pneumatic tubes
 | 
				
			||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local tubenodes = {}
 | 
					local tubenodes = {}
 | 
				
			||||||
pipeworks.tubenodes = tubenodes
 | 
					pipeworks.tubenodes = tubenodes
 | 
				
			||||||
@@ -25,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)
 | 
				
			||||||
@@ -55,13 +61,13 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
 | 
				
			|||||||
		outimgs[vti[v]] = ends[v]
 | 
							outimgs[vti[v]] = ends[v]
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1}
 | 
						local tgroups = {snappy = 3, tube = 1, tubedevice = 1, not_in_creative_inventory = 1, dig_generic = 4}
 | 
				
			||||||
	local tubedesc = string.format("%s %s... You hacker, you.", desc, dump(connects))
 | 
						local tubedesc = string.format("%s %s", desc, dump(connects))
 | 
				
			||||||
	local iimg = plain[1]
 | 
						local iimg = type(plain[1]) == "table" and plain[1].name or plain[1]
 | 
				
			||||||
	local wscale = {x = 1, y = 1, z = 1}
 | 
						local wscale = {x = 1, y = 1, z = 1}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if #connects == 0 then
 | 
						if #connects == 0 then
 | 
				
			||||||
		tgroups = {snappy = 3, tube = 1, tubedevice = 1}
 | 
							tgroups = {snappy = 3, tube = 1, tubedevice = 1, dig_generic = 4}
 | 
				
			||||||
		tubedesc = desc
 | 
							tubedesc = desc
 | 
				
			||||||
		iimg=inv
 | 
							iimg=inv
 | 
				
			||||||
		outimgs = {
 | 
							outimgs = {
 | 
				
			||||||
@@ -74,6 +80,10 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
 | 
				
			|||||||
		wscale = {x = 1, y = 1, z = 0.01}
 | 
							wscale = {x = 1, y = 1, z = 0.01}
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for i, tile in ipairs(outimgs) do
 | 
				
			||||||
 | 
							outimgs[i] = pipeworks.make_tube_tile(tile)
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	local rname = string.format("%s_%s", name, tname)
 | 
						local rname = string.format("%s_%s", name, tname)
 | 
				
			||||||
	table.insert(tubenodes, rname)
 | 
						table.insert(tubenodes, rname)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -81,6 +91,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,
 | 
				
			||||||
@@ -95,7 +106,9 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
 | 
				
			|||||||
			fixed = outboxes
 | 
								fixed = outboxes
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
		groups = tgroups,
 | 
							groups = tgroups,
 | 
				
			||||||
		sounds = default.node_sound_wood_defaults(),
 | 
							_sound_def = {
 | 
				
			||||||
 | 
								key = "node_sound_wood_defaults",
 | 
				
			||||||
 | 
							},
 | 
				
			||||||
		walkable = true,
 | 
							walkable = true,
 | 
				
			||||||
		stack_max = 99,
 | 
							stack_max = 99,
 | 
				
			||||||
		basename = name,
 | 
							basename = name,
 | 
				
			||||||
@@ -106,6 +119,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,
 | 
				
			||||||
@@ -116,7 +141,10 @@ local register_one_tube = function(name, tname, dropname, desc, plain, noctrs, e
 | 
				
			|||||||
			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)
 | 
				
			||||||
		end
 | 
							end,
 | 
				
			||||||
 | 
							check_for_pole = pipeworks.check_for_vert_tube,
 | 
				
			||||||
 | 
							check_for_horiz_pole = pipeworks.check_for_horiz_tube,
 | 
				
			||||||
 | 
							tubenumber = tonumber(tname)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if style == "6d" then
 | 
						if style == "6d" then
 | 
				
			||||||
		nodedef.paramtype2 = "facedir"
 | 
							nodedef.paramtype2 = "facedir"
 | 
				
			||||||
@@ -178,6 +206,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}}
 | 
				
			||||||
@@ -194,12 +223,13 @@ local register_all_tubes = function(name, desc, plain, noctrs, ends, short, inv,
 | 
				
			|||||||
				wield_image = inv,
 | 
									wield_image = inv,
 | 
				
			||||||
				paramtype = "light",
 | 
									paramtype = "light",
 | 
				
			||||||
				sunlight_propagates = true,
 | 
									sunlight_propagates = true,
 | 
				
			||||||
				description = "Pneumatic tube segment (legacy)",
 | 
									description = S("Pneumatic tube segment (legacy)"),
 | 
				
			||||||
				after_place_node = pipeworks.after_place,
 | 
									after_place_node = pipeworks.after_place,
 | 
				
			||||||
				groups = {not_in_creative_inventory = 1, tube_to_update = 1, tube = 1},
 | 
									groups = {not_in_creative_inventory = 1, tube_to_update = 1, tube = 1},
 | 
				
			||||||
				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
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,7 @@
 | 
				
			|||||||
 | 
					local S = minetest.get_translator("pipeworks")
 | 
				
			||||||
if pipeworks.enable_sand_tube then
 | 
					if pipeworks.enable_sand_tube then
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:sand_tube", {
 | 
						pipeworks.register_tube("pipeworks:sand_tube", {
 | 
				
			||||||
		description = "Vacuuming Pneumatic Tube Segment",
 | 
							description = S("Vacuuming Pneumatic Tube Segment"),
 | 
				
			||||||
		inventory_image = "pipeworks_sand_tube_inv.png",
 | 
							inventory_image = "pipeworks_sand_tube_inv.png",
 | 
				
			||||||
		short = "pipeworks_sand_tube_short.png",
 | 
							short = "pipeworks_sand_tube_short.png",
 | 
				
			||||||
		noctr = {"pipeworks_sand_tube_noctr.png"},
 | 
							noctr = {"pipeworks_sand_tube_noctr.png"},
 | 
				
			||||||
@@ -28,7 +29,7 @@ end
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
if pipeworks.enable_mese_sand_tube then
 | 
					if pipeworks.enable_mese_sand_tube then
 | 
				
			||||||
	pipeworks.register_tube("pipeworks:mese_sand_tube", {
 | 
						pipeworks.register_tube("pipeworks:mese_sand_tube", {
 | 
				
			||||||
			description = "Adjustable Vacuuming Pneumatic Tube Segment",
 | 
								description = S("Adjustable Vacuuming Pneumatic Tube Segment"),
 | 
				
			||||||
			inventory_image = "pipeworks_mese_sand_tube_inv.png",
 | 
								inventory_image = "pipeworks_mese_sand_tube_inv.png",
 | 
				
			||||||
			short = "pipeworks_mese_sand_tube_short.png",
 | 
								short = "pipeworks_mese_sand_tube_short.png",
 | 
				
			||||||
			noctr = {"pipeworks_mese_sand_tube_noctr.png"},
 | 
								noctr = {"pipeworks_mese_sand_tube_noctr.png"},
 | 
				
			||||||
@@ -38,48 +39,36 @@ if pipeworks.enable_mese_sand_tube then
 | 
				
			|||||||
				groups = {vacuum_tube = 1},
 | 
									groups = {vacuum_tube = 1},
 | 
				
			||||||
				on_construct = function(pos)
 | 
									on_construct = function(pos)
 | 
				
			||||||
					local meta = minetest.get_meta(pos)
 | 
										local meta = minetest.get_meta(pos)
 | 
				
			||||||
 | 
										local size = "6.0,2.4"
 | 
				
			||||||
					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["..size.."]"..
 | 
				
			||||||
							"field[1.3,0.4;1,1;dist;radius;${dist}]"..
 | 
											pipeworks.fs_helpers.get_prepends(size) ..
 | 
				
			||||||
							default.gui_bg..
 | 
											"image[0.2,0;1,1;pipeworks_mese_sand_tube_inv.png]"..
 | 
				
			||||||
							default.gui_bg_img)
 | 
											"label[1.2,0.2;"..S("Adjustable Vacuuming Tube").."]"..
 | 
				
			||||||
					meta:set_string("infotext", "Adjustable Vacuuming Pneumatic Tube Segment")
 | 
											"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").."]")
 | 
				
			||||||
 | 
										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", ("Adjustable Vacuuming Pneumatic Tube Segment (%dm)"):format(dist))
 | 
											meta:set_string("infotext", S("Adjustable Vacuuming Pneumatic Tube Segment (@1m)", dist))
 | 
				
			||||||
					end
 | 
										end
 | 
				
			||||||
				end,
 | 
									end,
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
 | 
					 | 
				
			||||||
	minetest.register_craft( {
 | 
					 | 
				
			||||||
		output = "pipeworks:mese_sand_tube_1 2",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" },
 | 
					 | 
				
			||||||
			{"group:sand",                 "default:mese_crystal",       "group:sand" },
 | 
					 | 
				
			||||||
			{"basic_materials:plastic_sheet", "basic_materials:plastic_sheet", "basic_materials:plastic_sheet" }
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	minetest.register_craft( {
 | 
					 | 
				
			||||||
		type = "shapeless",
 | 
					 | 
				
			||||||
		output = "pipeworks:mese_sand_tube_1",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			"pipeworks:sand_tube_1",
 | 
					 | 
				
			||||||
			"default:mese_crystal_fragment",
 | 
					 | 
				
			||||||
			"default:mese_crystal_fragment",
 | 
					 | 
				
			||||||
			"default:mese_crystal_fragment",
 | 
					 | 
				
			||||||
			"default:mese_crystal_fragment"
 | 
					 | 
				
			||||||
		},
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
local function vacuum(pos, radius)
 | 
					local function vacuum(pos, radius)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										73
									
								
								wielder.lua
									
									
									
									
									
								
							
							
						
						
									
										73
									
								
								wielder.lua
									
									
									
									
									
								
							@@ -1,21 +1,33 @@
 | 
				
			|||||||
 | 
					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)
 | 
				
			||||||
 | 
						local size = "10.2,"..(7+data.wield_inv_height)
 | 
				
			||||||
 | 
						local list_background = ""
 | 
				
			||||||
 | 
						if minetest.get_modpath("i3") then
 | 
				
			||||||
 | 
							list_background = "style_type[box;colors=#666]"
 | 
				
			||||||
 | 
							for i=0, data.wield_inv_height-1 do
 | 
				
			||||||
 | 
								for j=0, data.wield_inv_width-1 do
 | 
				
			||||||
 | 
									list_background = list_background .. "box[".. ((10-data.wield_inv_width)*0.5)+(i*1.25) ..",".. 1+(j*1.25) ..";1,1;]"
 | 
				
			||||||
 | 
								end
 | 
				
			||||||
 | 
							end
 | 
				
			||||||
 | 
						end
 | 
				
			||||||
	meta:set_string("formspec",
 | 
						meta:set_string("formspec",
 | 
				
			||||||
			"invsize[8,"..(6+data.wield_inv_height)..";]"..
 | 
							"formspec_version[2]" ..
 | 
				
			||||||
			"item_image[0,0;1,1;"..data.name_base.."_off]"..
 | 
							"size["..size.."]"..
 | 
				
			||||||
			"label[1,0;"..minetest.formspec_escape(data.description).."]"..
 | 
							pipeworks.fs_helpers.get_prepends(size)..
 | 
				
			||||||
			"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..";]"..
 | 
							"item_image[0.5,0.5;1,1;"..data.name_base.."_off]"..
 | 
				
			||||||
			"list[current_player;main;0,"..(2+data.wield_inv_height)..";8,4;]" ..
 | 
							"label[1.5,1;"..minetest.formspec_escape(data.description).."]"..
 | 
				
			||||||
			"listring[]")
 | 
							list_background ..
 | 
				
			||||||
 | 
							"list[context;"..minetest.formspec_escape(data.wield_inv_name)..";"..((10-data.wield_inv_width)*0.5)..",1;"..data.wield_inv_width..","..data.wield_inv_height..";]"..
 | 
				
			||||||
 | 
							pipeworks.fs_helpers.get_inv((2+data.wield_inv_height)) ..
 | 
				
			||||||
 | 
							"listring[context;"..minetest.formspec_escape(data.wield_inv_name).."]" ..
 | 
				
			||||||
 | 
							"listring[current_player;main]"
 | 
				
			||||||
 | 
						)
 | 
				
			||||||
	meta:set_string("infotext", data.description)
 | 
						meta:set_string("infotext", data.description)
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -39,7 +51,7 @@ local can_tool_dig_node = function(nodename, toolcaps, toolname)
 | 
				
			|||||||
		-- but a player holding one can - the game seems to fall back to the hand.
 | 
							-- but a player holding one can - the game seems to fall back to the hand.
 | 
				
			||||||
		-- fall back to checking the hand's properties if the tool isn't the correct one.
 | 
							-- fall back to checking the hand's properties if the tool isn't the correct one.
 | 
				
			||||||
		local hand_caps = minetest.registered_items[""].tool_capabilities
 | 
							local hand_caps = minetest.registered_items[""].tool_capabilities
 | 
				
			||||||
		diggable = minetest.get_dig_params(nodegroups, hand_caps)
 | 
							diggable = minetest.get_dig_params(nodegroups, hand_caps).diggable
 | 
				
			||||||
	end
 | 
						end
 | 
				
			||||||
	return diggable
 | 
						return diggable
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
@@ -187,7 +199,9 @@ local function register_wielder(data)
 | 
				
			|||||||
			paramtype2 = "facedir",
 | 
								paramtype2 = "facedir",
 | 
				
			||||||
			tubelike = 1,
 | 
								tubelike = 1,
 | 
				
			||||||
			groups = groups,
 | 
								groups = groups,
 | 
				
			||||||
			sounds = default.node_sound_stone_defaults(),
 | 
								_sound_def = {
 | 
				
			||||||
 | 
									key = "node_sound_stone_defaults",
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
			drop = data.name_base.."_off",
 | 
								drop = data.name_base.."_off",
 | 
				
			||||||
			on_construct = function(pos)
 | 
								on_construct = function(pos)
 | 
				
			||||||
				local meta = minetest.get_meta(pos)
 | 
									local meta = minetest.get_meta(pos)
 | 
				
			||||||
@@ -259,7 +273,7 @@ if pipeworks.enable_node_breaker then
 | 
				
			|||||||
	local wield_inv_name = "pick"
 | 
						local wield_inv_name = "pick"
 | 
				
			||||||
	data = {
 | 
						data = {
 | 
				
			||||||
		name_base = name_base,
 | 
							name_base = name_base,
 | 
				
			||||||
		description = "Node Breaker",
 | 
							description = S("Node Breaker"),
 | 
				
			||||||
		texture_base = "pipeworks_nodebreaker",
 | 
							texture_base = "pipeworks_nodebreaker",
 | 
				
			||||||
		texture_stateful = { top = true, bottom = true, side2 = true, side1 = true, front = true },
 | 
							texture_stateful = { top = true, bottom = true, side2 = true, side1 = true, front = true },
 | 
				
			||||||
		tube_connect_sides = { top=1, bottom=1, left=1, right=1, back=1 },
 | 
							tube_connect_sides = { top=1, bottom=1, left=1, right=1, back=1 },
 | 
				
			||||||
@@ -352,7 +366,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
 | 
				
			||||||
@@ -374,14 +388,7 @@ if pipeworks.enable_node_breaker then
 | 
				
			|||||||
		eject_drops = true,
 | 
							eject_drops = true,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	register_wielder(data)
 | 
						register_wielder(data)
 | 
				
			||||||
	minetest.register_craft({
 | 
						pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:nodebreaker_off"
 | 
				
			||||||
		output = "pipeworks:nodebreaker_off",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			{ "pipeworks:gear", "pipeworks:gear",   "pipeworks:gear"    },
 | 
					 | 
				
			||||||
			{ "default:stone", "mesecons:piston",   "default:stone" },
 | 
					 | 
				
			||||||
			{ "group:wood",    "mesecons:mesecon",  "group:wood" },
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
	-- aliases for when someone had technic installed, but then uninstalled it but not pipeworks
 | 
						-- aliases for when someone had technic installed, but then uninstalled it but not pipeworks
 | 
				
			||||||
	minetest.register_alias("technic:nodebreaker_off", "pipeworks:nodebreaker_off")
 | 
						minetest.register_alias("technic:nodebreaker_off", "pipeworks:nodebreaker_off")
 | 
				
			||||||
	minetest.register_alias("technic:nodebreaker_on", "pipeworks:nodebreaker_on")
 | 
						minetest.register_alias("technic:nodebreaker_on", "pipeworks:nodebreaker_on")
 | 
				
			||||||
@@ -408,7 +415,7 @@ end
 | 
				
			|||||||
if pipeworks.enable_deployer then
 | 
					if pipeworks.enable_deployer then
 | 
				
			||||||
	register_wielder({
 | 
						register_wielder({
 | 
				
			||||||
		name_base = "pipeworks:deployer",
 | 
							name_base = "pipeworks:deployer",
 | 
				
			||||||
		description = "Deployer",
 | 
							description = S("Deployer"),
 | 
				
			||||||
		texture_base = "pipeworks_deployer",
 | 
							texture_base = "pipeworks_deployer",
 | 
				
			||||||
		texture_stateful = { front = true },
 | 
							texture_stateful = { front = true },
 | 
				
			||||||
		tube_connect_sides = { back=1 },
 | 
							tube_connect_sides = { back=1 },
 | 
				
			||||||
@@ -425,14 +432,7 @@ if pipeworks.enable_deployer then
 | 
				
			|||||||
		end,
 | 
							end,
 | 
				
			||||||
		eject_drops = false,
 | 
							eject_drops = false,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	minetest.register_craft({
 | 
						pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:deployer_off"
 | 
				
			||||||
		output = "pipeworks:deployer_off",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			{ "group:wood",    "default:chest",    "group:wood"    },
 | 
					 | 
				
			||||||
			{ "default:stone", "mesecons:piston",  "default:stone" },
 | 
					 | 
				
			||||||
			{ "default:stone", "mesecons:mesecon", "default:stone" },
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
	-- aliases for when someone had technic installed, but then uninstalled it but not pipeworks
 | 
						-- aliases for when someone had technic installed, but then uninstalled it but not pipeworks
 | 
				
			||||||
	minetest.register_alias("technic:deployer_off", "pipeworks:deployer_off")
 | 
						minetest.register_alias("technic:deployer_off", "pipeworks:deployer_off")
 | 
				
			||||||
	minetest.register_alias("technic:deployer_on", "pipeworks:deployer_on")
 | 
						minetest.register_alias("technic:deployer_on", "pipeworks:deployer_on")
 | 
				
			||||||
@@ -441,7 +441,7 @@ end
 | 
				
			|||||||
if pipeworks.enable_dispenser then
 | 
					if pipeworks.enable_dispenser then
 | 
				
			||||||
	register_wielder({
 | 
						register_wielder({
 | 
				
			||||||
		name_base = "pipeworks:dispenser",
 | 
							name_base = "pipeworks:dispenser",
 | 
				
			||||||
		description = "Dispenser",
 | 
							description = S("Dispenser"),
 | 
				
			||||||
		texture_base = "pipeworks_dispenser",
 | 
							texture_base = "pipeworks_dispenser",
 | 
				
			||||||
		texture_stateful = { front = true },
 | 
							texture_stateful = { front = true },
 | 
				
			||||||
		tube_connect_sides = { back=1 },
 | 
							tube_connect_sides = { back=1 },
 | 
				
			||||||
@@ -460,12 +460,5 @@ if pipeworks.enable_dispenser then
 | 
				
			|||||||
		end,
 | 
							end,
 | 
				
			||||||
		eject_drops = false,
 | 
							eject_drops = false,
 | 
				
			||||||
	})
 | 
						})
 | 
				
			||||||
	minetest.register_craft({
 | 
						pipeworks.ui_cat_tube_list[#pipeworks.ui_cat_tube_list+1] = "pipeworks:dispenser_off"
 | 
				
			||||||
		output = "pipeworks:dispenser_off",
 | 
					 | 
				
			||||||
		recipe = {
 | 
					 | 
				
			||||||
			{ "default:desert_sand", "default:chest",    "default:desert_sand" },
 | 
					 | 
				
			||||||
			{ "default:stone",       "mesecons:piston",  "default:stone"       },
 | 
					 | 
				
			||||||
			{ "default:stone",       "mesecons:mesecon", "default:stone"       },
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	})
 | 
					 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user