mirror of
				https://github.com/mt-mods/pipeworks.git
				synced 2025-10-26 16:05:27 +01:00 
			
		
		
		
	Compare commits
	
		
			14 Commits
		
	
	
		
			2021-02-19
			...
			ee03959a65
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| ee03959a65 | |||
| 4dd30df37a | |||
| 946da11206 | |||
| 77c8026400 | |||
| 70b521c721 | |||
| 6d795b7d34 | |||
| 92249b7941 | |||
| e04fb691ad | |||
| ac80224371 | |||
| 34262ed8d5 | |||
| 5cfe8d893f | |||
| 975e20f704 | |||
| 2693e2ecbb | |||
|  | c93df73a5c | 
| @@ -47,7 +47,7 @@ local function autocraft(inventory, craft) | ||||
| 	end | ||||
| 	-- consume material | ||||
| 	for itemname, number in pairs(consumption) do | ||||
| 		for _ = 1, number do -- We have to do that since remove_item does not work if count > stack_max | ||||
| 		for i = 1, number do -- We have to do that since remove_item does not work if count > stack_max | ||||
| 			inventory:remove_item("src", ItemStack(itemname)) | ||||
| 		end | ||||
| 	end | ||||
| @@ -67,13 +67,16 @@ local function run_autocrafter(pos, elapsed) | ||||
| 	local inventory = meta:get_inventory() | ||||
| 	local craft = get_craft(pos, inventory) | ||||
| 	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 | ||||
| 	if output_item:is_empty() then | ||||
| 	-- NALC: ou si l'item n'est pas dans le group limitcraft | ||||
| 	if output_item:is_empty() or limitcraft > 0 then | ||||
| 		meta:set_string("infotext", S("unconfigured Autocrafter: unknown recipe")) | ||||
| 		return false | ||||
| 	end | ||||
|  | ||||
| 	for _ = 1, math.floor(elapsed/craft_time) do | ||||
| 	for step = 1, math.floor(elapsed/craft_time) do | ||||
| 		local continue = autocraft(inventory, craft) | ||||
| 		if not continue then return false end | ||||
| 	end | ||||
| @@ -106,6 +109,7 @@ local function after_recipe_change(pos, inventory) | ||||
| 		inventory:set_stack("output", 1, "") | ||||
| 		return | ||||
| 	end | ||||
| 	local recipe_changed = false | ||||
| 	local recipe = inventory:get_list("recipe") | ||||
|  | ||||
| 	local hash = minetest.hash_node_position(pos) | ||||
|   | ||||
| @@ -81,7 +81,7 @@ local function tube_autoroute(pos) | ||||
| 	local basename = nodedef.basename | ||||
| 	if nodedef.style == "old" then | ||||
| 		local nsurround = "" | ||||
| 		for _, n in ipairs(active) do | ||||
| 		for i, n in ipairs(active) do | ||||
| 			nsurround = nsurround..n | ||||
| 		end | ||||
| 		nctr.name = basename.."_"..nsurround | ||||
|   | ||||
| @@ -114,7 +114,7 @@ local fs_helpers = {} | ||||
| pipeworks.fs_helpers = fs_helpers | ||||
| function fs_helpers.on_receive_fields(pos, fields) | ||||
| 	local meta = minetest.get_meta(pos) | ||||
| 	for field in pairs(fields) do | ||||
| 	for field, value in pairs(fields) do | ||||
| 		if pipeworks.string_startswith(field, "fs_helpers_cycling:") then | ||||
| 			local l = field:split(":") | ||||
| 			local new_value = tonumber(l[2]) | ||||
| @@ -223,7 +223,7 @@ function pipeworks.create_fake_player(def, is_dynamic) | ||||
| 				return self._inventory:set_stack(def.wield_list, | ||||
| 					self._wield_index, item) | ||||
| 			end | ||||
| 			self._wielded_item = ItemStack(item) | ||||
| 			_wielded_item = ItemStack(item) | ||||
| 		end, | ||||
| 		get_wielded_item = function(self, item) | ||||
| 			if self._inventory and def.wield_list then | ||||
| @@ -242,18 +242,17 @@ function pipeworks.create_fake_player(def, is_dynamic) | ||||
| 		set_bone_position = delay(), | ||||
| 		hud_change = delay(), | ||||
| 	} | ||||
| 	local _trash | ||||
| 	-- Getter & setter functions | ||||
| 	p.get_inventory_formspec, p.set_inventory_formspec | ||||
| 		= get_set_wrap("formspec", 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_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_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 | ||||
| 	p.getpos = p.get_pos | ||||
| 	p.setpos = p.set_pos | ||||
|   | ||||
| @@ -65,7 +65,7 @@ minetest.register_on_player_receive_fields(function(player, formname, fields) | ||||
| 				local node = minetest.get_node(pos) | ||||
|  | ||||
| 				open_chests[pn] = nil | ||||
| 				for _, v in pairs(open_chests) do | ||||
| 				for k, 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 | ||||
| 						return true | ||||
| 					end | ||||
| @@ -230,7 +230,7 @@ override.tiles = { | ||||
| } | ||||
|  | ||||
| -- Add the extra groups | ||||
| for _,v in ipairs({override_protected, override, override_open, override_protected_open}) do | ||||
| for i,v in ipairs({override_protected, override, override_open, override_protected_open}) do | ||||
| 	v.groups.tubedevice = 1 | ||||
| 	v.groups.tubedevice_receiver = 1 | ||||
| end | ||||
|   | ||||
| @@ -7,7 +7,7 @@ local DS = minetest.get_translator("default") | ||||
|  | ||||
| local fs_helpers = pipeworks.fs_helpers | ||||
|  | ||||
| local tube_entry = "^pipeworks_tube_connection_stony.png" | ||||
| tube_entry = "^pipeworks_tube_connection_stony.png" | ||||
|  | ||||
| local function active_formspec(fuel_percent, item_percent, pos, meta) | ||||
| 	local formspec = | ||||
|   | ||||
							
								
								
									
										26
									
								
								devices.lua
									
									
									
									
									
								
							
							
						
						
									
										26
									
								
								devices.lua
									
									
									
									
									
								
							| @@ -10,7 +10,7 @@ function pipeworks.fix_after_rotation(pos, node, user, mode, new_param2) | ||||
|  | ||||
| 	if string.find(node.name, "spigot") then new_param2 = new_param2 % 4 end | ||||
|  | ||||
| 	local newnode = string.gsub(node.name, "_on", "_off") | ||||
| 	newnode = string.gsub(node.name, "_on", "_off") | ||||
| 	minetest.swap_node(pos, { name = newnode, param2 = new_param2 }) | ||||
| 	pipeworks.scan_for_pipe_objects(pos) | ||||
|  | ||||
| @@ -20,7 +20,7 @@ end | ||||
| function pipeworks.rotate_on_place(itemstack, placer, pointed_thing) | ||||
|  | ||||
| 	local playername = placer:get_player_name() | ||||
| 	if not minetest.is_protected(pointed_thing.under, playername) | ||||
| 	if not minetest.is_protected(pointed_thing.under, playername)  | ||||
| 	   and not minetest.is_protected(pointed_thing.above, playername) then | ||||
|  | ||||
| 		local node = minetest.get_node(pointed_thing.under) | ||||
| @@ -36,7 +36,9 @@ function pipeworks.rotate_on_place(itemstack, placer, pointed_thing) | ||||
| 			local under = pointed_thing.under | ||||
| 			local fdir = minetest.dir_to_facedir(placer:get_look_dir()) | ||||
| 			local undernode = minetest.get_node(under) | ||||
| 			local abovenode = minetest.get_node(above) | ||||
| 			local uname = undernode.name | ||||
| 			local aname = abovenode.name | ||||
| 			local isabove = (above.x == under.x) and (above.z == under.z) and (pitch > 0) | ||||
| 			local pos1 = above | ||||
|  | ||||
| @@ -103,7 +105,6 @@ if minetest.get_modpath("mesecons") then | ||||
| 	} | ||||
| end | ||||
|  | ||||
| --[[ | ||||
| local pipes_devicelist = { | ||||
| 	"pump", | ||||
| 	"valve", | ||||
| @@ -119,15 +120,14 @@ local pipes_devicelist = { | ||||
| 	"storage_tank_9", | ||||
| 	"storage_tank_10" | ||||
| } | ||||
| --]] | ||||
|  | ||||
| -- Now define the nodes. | ||||
|  | ||||
| local states = { "on", "off" } | ||||
| local dgroups = "" | ||||
|  | ||||
| for s in ipairs(states) do | ||||
|  | ||||
| 	local dgroups | ||||
| 	if states[s] == "off" then | ||||
| 		dgroups = {snappy=3, pipe=1} | ||||
| 	else | ||||
| @@ -187,11 +187,11 @@ for s in ipairs(states) do | ||||
| 		paramtype = "light", | ||||
| 		paramtype2 = "facedir", | ||||
| 		selection_box = { | ||||
| 			type = "fixed", | ||||
| 	             	type = "fixed", | ||||
| 			fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | ||||
| 		}, | ||||
| 		collision_box = { | ||||
| 			type = "fixed", | ||||
| 	             	type = "fixed", | ||||
| 			fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | ||||
| 		}, | ||||
| 		groups = dgroups, | ||||
| @@ -233,11 +233,11 @@ minetest.register_node(nodename_valve_loaded, { | ||||
| 	paramtype = "light", | ||||
| 	paramtype2 = "facedir", | ||||
| 	selection_box = { | ||||
| 		type = "fixed", | ||||
|              	type = "fixed", | ||||
| 		fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | ||||
| 	}, | ||||
| 	collision_box = { | ||||
| 		type = "fixed", | ||||
|              	type = "fixed", | ||||
| 		fixed = { -5/16, -4/16, -8/16, 5/16, 5/16, 8/16 } | ||||
| 	}, | ||||
| 	groups = {snappy=3, pipe=1, not_in_creative_inventory=1}, | ||||
| @@ -465,7 +465,7 @@ minetest.register_node(nodename_sensor_empty, { | ||||
| 	end, | ||||
| 	on_construct = function(pos) | ||||
| 		if mesecon then | ||||
| 			mesecon.receptor_off(pos, pipeworks.mesecons_rules) | ||||
| 			mesecon.receptor_off(pos, rules)  | ||||
| 		end | ||||
| 	end, | ||||
| 	selection_box = { | ||||
| @@ -504,7 +504,7 @@ minetest.register_node(nodename_sensor_loaded, { | ||||
| 	end, | ||||
| 	on_construct = function(pos) | ||||
| 		if mesecon then | ||||
| 			mesecon.receptor_on(pos, pipeworks.mesecons_rules) | ||||
| 			mesecon.receptor_on(pos, rules)  | ||||
| 		end | ||||
| 	end, | ||||
| 	selection_box = { | ||||
| @@ -626,7 +626,7 @@ minetest.register_node(nodename_fountain_empty, { | ||||
| 	end, | ||||
| 	on_construct = function(pos) | ||||
| 		if mesecon then | ||||
| 			mesecon.receptor_on(pos, pipeworks.mesecons_rules) | ||||
| 			mesecon.receptor_on(pos, rules)  | ||||
| 		end | ||||
| 	end, | ||||
| 	selection_box = { | ||||
| @@ -661,7 +661,7 @@ minetest.register_node(nodename_fountain_loaded, { | ||||
| 	end, | ||||
| 	on_construct = function(pos) | ||||
| 		if mesecon then | ||||
| 			mesecon.receptor_on(pos, pipeworks.mesecons_rules) | ||||
| 			mesecon.receptor_on(pos, rules)  | ||||
| 		end | ||||
| 	end, | ||||
| 	selection_box = { | ||||
|   | ||||
| @@ -1,6 +1,10 @@ | ||||
| local S = minetest.get_translator("pipeworks") | ||||
| local fs_helpers = pipeworks.fs_helpers | ||||
|  | ||||
| local function delay(x) | ||||
| 	return (function() return x end) | ||||
| end | ||||
|  | ||||
| local function set_filter_infotext(data, meta) | ||||
| 	local infotext = S("@1 Filter-Injector", data.wise_desc) | ||||
| 	if meta:get_int("slotseq_mode") == 2 then | ||||
| @@ -322,8 +326,7 @@ local function punch_filter(data, filtpos, filtnode, msg) | ||||
| 				end | ||||
| 				local pos = vector.add(frompos, vector.multiply(dir, 1.4)) | ||||
| 				local start_pos = vector.add(frompos, dir) | ||||
| 				pipeworks.tube_inject_item(pos, start_pos, dir, item, | ||||
| 					fakePlayer:get_player_name()) | ||||
| 				local item1 = pipeworks.tube_inject_item(pos, start_pos, dir, item, fakePlayer:get_player_name()) | ||||
| 				return true -- only fire one item, please | ||||
| 			end | ||||
| 		end | ||||
|   | ||||
| @@ -60,8 +60,8 @@ pipeworks.check_for_inflows = function(pos,node) | ||||
| 			end | ||||
| 		end | ||||
| 	end | ||||
| 	if newnode then | ||||
| 		minetest.add_node(pos,{name=newnode, param2 = node.param2}) | ||||
| 	if newnode then  | ||||
| 		minetest.add_node(pos,{name=newnode, param2 = node.param2})  | ||||
| 		minetest.get_meta(pos):set_string("source",minetest.pos_to_string(source)) | ||||
| 	end | ||||
| end | ||||
| @@ -75,15 +75,15 @@ pipeworks.check_sources = function(pos,node) | ||||
| 		newnode = string.gsub(node.name,"loaded","empty") | ||||
| 	end | ||||
|  | ||||
| 	if newnode then | ||||
| 		minetest.add_node(pos,{name=newnode, param2 = node.param2}) | ||||
| 	if newnode then  | ||||
| 		minetest.add_node(pos,{name=newnode, param2 = node.param2})  | ||||
| 		minetest.get_meta(pos):set_string("source","") | ||||
| 	end | ||||
| end | ||||
|  | ||||
| pipeworks.spigot_check = function(pos, node) | ||||
| 	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 == "default:water_flowing" or belowname == "default:water_source") then  | ||||
| 		local spigotname = minetest.get_node(pos).name | ||||
| 		local fdir=node.param2 % 4 | ||||
| 		local check = { | ||||
| @@ -113,7 +113,7 @@ end | ||||
|  | ||||
| pipeworks.fountainhead_check = function(pos, node) | ||||
| 	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 == "default:water_flowing" or abovename == "default:water_source") then  | ||||
| 		local fountainhead_name = minetest.get_node(pos).name | ||||
| 		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 | ||||
|   | ||||
							
								
								
									
										2
									
								
								init.lua
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								init.lua
									
									
									
									
									
								
							| @@ -6,6 +6,8 @@ | ||||
|  | ||||
| pipeworks = {} | ||||
|  | ||||
| local DEBUG = false | ||||
|  | ||||
| pipeworks.worldpath = minetest.get_worldpath() | ||||
| pipeworks.modpath = minetest.get_modpath("pipeworks") | ||||
| local S = minetest.get_translator("pipeworks") | ||||
|   | ||||
| @@ -42,7 +42,7 @@ minetest.register_globalstep(function(dtime) | ||||
| 		return | ||||
| 	end | ||||
| 	tube_item_count = {} | ||||
| 	for _, entity in pairs(luaentity.entities) do | ||||
| 	for id, entity in pairs(luaentity.entities) do | ||||
| 		if entity.name == "pipeworks:tubed_item" then | ||||
| 			local h = minetest.hash_node_position(vector.round(entity._pos)) | ||||
| 			tube_item_count[h] = (tube_item_count[h] or 0) + 1 | ||||
| @@ -194,7 +194,6 @@ minetest.register_entity("pipeworks:tubed_item", { | ||||
|  | ||||
| 	from_data = function(self, itemstring) | ||||
| 		local stack = ItemStack(itemstring) | ||||
| 		--[[ | ||||
| 		local itemtable = stack:to_table() | ||||
| 		local itemname = nil | ||||
| 		if itemtable then | ||||
| @@ -206,7 +205,6 @@ minetest.register_entity("pipeworks:tubed_item", { | ||||
| 			item_texture = minetest.registered_items[itemname].inventory_image | ||||
| 			item_type = minetest.registered_items[itemname].type | ||||
| 		end | ||||
| 		--]] | ||||
| 		self.object:set_properties({ | ||||
| 			is_visible = true, | ||||
| 			textures = {stack:get_name()} | ||||
| @@ -393,7 +391,7 @@ if minetest.get_modpath("mesecons_mvps") then | ||||
| 		for _, n in ipairs(moved_nodes) do | ||||
| 			moved[minetest.hash_node_position(n.oldpos)] = vector.subtract(n.pos, n.oldpos) | ||||
| 		end | ||||
| 		for _, entity in pairs(luaentity.entities) do | ||||
| 		for id, entity in pairs(luaentity.entities) do | ||||
| 			if entity.name == "pipeworks:tubed_item" then | ||||
| 				local pos = entity:get_pos() | ||||
| 				local rpos = vector.round(pos) | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| 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.register_abm({ | ||||
| @@ -38,10 +38,10 @@ if not minetest.get_modpath("auto_tree_tap") and | ||||
| 		after_place_node = function (pos, placer) | ||||
| 			pipeworks.scan_for_tube_objects(pos, placer) | ||||
| 			local placer_pos = placer:get_pos() | ||||
|  | ||||
| 		 | ||||
| 			--correct for the player's height | ||||
| 			if placer:is_player() then placer_pos.y = placer_pos.y + 1.5 end | ||||
|  | ||||
| 		 | ||||
| 			--correct for 6d facedir | ||||
| 			if placer_pos then | ||||
| 				local dir = { | ||||
|   | ||||
| @@ -969,7 +969,7 @@ for white  = 0, 1 do | ||||
| 			can_go = function(pos, node, velocity, stack) | ||||
| 				local src = {name = nil} | ||||
| 				-- add color of the incoming tube explicitly; referring to rules, in case they change later | ||||
| 				for _, rule in pairs(rules) do | ||||
| 				for color, rule in pairs(rules) do | ||||
| 					if (-velocity.x == rule.x and -velocity.y == rule.y and -velocity.z == rule.z) then | ||||
| 						src.name = rule.name | ||||
| 						break | ||||
| @@ -993,7 +993,7 @@ for white  = 0, 1 do | ||||
| 		on_blast = function(pos, intensity) | ||||
| 			if not intensity or intensity > 1 + 3^0.5 then | ||||
| 				minetest.remove_node(pos) | ||||
| 				return | ||||
| 				return {string.format("%s_%s", name, dropname)} | ||||
| 			end | ||||
| 			minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) | ||||
| 			pipeworks.scan_for_tube_objects(pos) | ||||
| @@ -1070,7 +1070,7 @@ minetest.register_node(BASENAME .. "_burnt", { | ||||
| 	on_blast = function(pos, intensity) | ||||
| 		if not intensity or intensity > 1 + 3^0.5 then | ||||
| 			minetest.remove_node(pos) | ||||
| 			return | ||||
| 			return {string.format("%s_%s", name, dropname)} | ||||
| 		end | ||||
| 		minetest.swap_node(pos, {name = "pipeworks:broken_tube_1"}) | ||||
| 		pipeworks.scan_for_tube_objects(pos) | ||||
|   | ||||
| @@ -9,16 +9,16 @@ local filename = minetest.get_worldpath().."/luaentities" | ||||
| local function read_file() | ||||
| 	local f = io.open(filename, "r") | ||||
| 	if f == nil then return {} end | ||||
| 	local t = f:read("*all") | ||||
| 	f:close() | ||||
|     	local t = f:read("*all") | ||||
|     	f:close() | ||||
| 	if t == "" or t == nil then return {} end | ||||
| 	return minetest.deserialize(t) or {} | ||||
| end | ||||
|  | ||||
| local function write_file(tbl) | ||||
| 	local f = io.open(filename, "w") | ||||
| 	f:write(minetest.serialize(tbl)) | ||||
| 	f:close() | ||||
|     	f:write(minetest.serialize(tbl)) | ||||
|     	f:close() | ||||
| end | ||||
|  | ||||
| local function read_entities() | ||||
| @@ -36,7 +36,7 @@ local function read_entities() | ||||
| 		y=math.min(30927,y) | ||||
| 		z=math.min(30927,z) | ||||
|  | ||||
| 		entity.start_pos.x = x | ||||
| 		entity.start_pos.x = x                  | ||||
| 		entity.start_pos.y = y | ||||
| 		entity.start_pos.z = z | ||||
|  | ||||
| @@ -211,7 +211,7 @@ local entitydef_default = { | ||||
| 		end | ||||
| 	end, | ||||
| 	get_velocity = function(self) | ||||
| 		return vector.new(self._velocity) | ||||
| 		return vector.new(self._velocity)	 | ||||
| 	end, | ||||
| 	set_velocity = function(self, velocity) | ||||
| 		self._velocity = vector.new(velocity) | ||||
| @@ -289,7 +289,7 @@ function luaentity.add_entity(pos, name) | ||||
| 		_acceleration = {x = 0, y = 0, z = 0}, | ||||
| 		_attached_entities = {}, | ||||
| 	} | ||||
|  | ||||
| 	 | ||||
| 	local prototype = luaentity.registered_entities[name] | ||||
| 	setmetatable(entity, prototype) -- Default to prototype for other methods | ||||
| 	luaentity.entities[index] = entity | ||||
| @@ -318,20 +318,19 @@ end | ||||
| function luaentity.get_objects_inside_radius(pos, radius) | ||||
| 	local objects = {} | ||||
| 	local index = 1 | ||||
| 	for _, entity in pairs(luaentity.entities) do | ||||
| 	for id, entity in pairs(luaentity.entities) do | ||||
| 		if vector.distance(pos, entity:get_pos()) <= radius then | ||||
| 			objects[index] = entity | ||||
| 			index = index + 1 | ||||
| 		end | ||||
| 	end | ||||
| 	return objects | ||||
| end | ||||
|  | ||||
| local move_entities_globalstep_part2 = function(dtime) | ||||
| 	if not luaentity.entities then | ||||
| 		luaentity.entities = read_entities() | ||||
| 	end | ||||
| 	for _, entity in pairs(luaentity.entities) do | ||||
| 	for id, entity in pairs(luaentity.entities) do | ||||
| 		local master = entity._attached_entities_master | ||||
| 		local master_def = master and entity._attached_entities[master] | ||||
| 		local master_entity = master_def and master_def.entity | ||||
|   | ||||
							
								
								
									
										20
									
								
								pipes.lua
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								pipes.lua
									
									
									
									
									
								
							| @@ -11,11 +11,11 @@ local new_flow_logic_register = pipeworks.flowables.register | ||||
| local polys = "" | ||||
| 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}} | ||||
| for index, connects in ipairs(cconnects) do | ||||
| 	local outsel = {} | ||||
|  | ||||
| 	 | ||||
| 	local jx = 0 | ||||
| 	local jy = 0 | ||||
| 	local jz = 0 | ||||
| @@ -30,13 +30,11 @@ for index, connects in ipairs(cconnects) do | ||||
| 		table.insert(outsel, pipeworks.pipe_selectboxes[v]) | ||||
| 	end | ||||
|  | ||||
| 	--[[ | ||||
| 	if #connects == 1 then | ||||
| 		local v = connects[1] | ||||
| 		v = v-1 + 2*(v%2) -- Opposite side | ||||
| 	end | ||||
| 	--]] | ||||
|  | ||||
| 	 | ||||
| 	local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1} | ||||
| 	local pipedesc = S("Pipe Segment").." "..dump(connects) | ||||
|  | ||||
| @@ -44,11 +42,11 @@ for index, connects in ipairs(cconnects) do | ||||
| 		pgroups = {snappy = 3, tube = 1} | ||||
| 		pipedesc = S("Pipe Segment") | ||||
| 	end | ||||
|  | ||||
| 	 | ||||
| 	local outimg_e = { "pipeworks_pipe_plain.png" } | ||||
| 	local outimg_l = { "pipeworks_pipe_plain.png" } | ||||
|  | ||||
| 	if index == 3 then | ||||
| 	if index == 3 then  | ||||
| 		outimg_e = { "pipeworks_pipe_3_empty.png" } | ||||
| 		outimg_l = { "pipeworks_pipe_3_loaded.png" } | ||||
| 	end | ||||
| @@ -90,7 +88,7 @@ for index, connects in ipairs(cconnects) do | ||||
| 		check_for_horiz_pole = pipeworks.check_for_horiz_pipe, | ||||
| 		pipenumber = index | ||||
| 	}) | ||||
|  | ||||
| 	 | ||||
| 	local pgroups = {snappy = 3, pipe = 1, not_in_creative_inventory = 1} | ||||
|  | ||||
| 	minetest.register_node("pipeworks:pipe_"..index.."_loaded", { | ||||
| @@ -125,7 +123,7 @@ for index, connects in ipairs(cconnects) do | ||||
| 		check_for_horiz_pole = pipeworks.check_for_horiz_pipe, | ||||
| 		pipenumber = index | ||||
| 	}) | ||||
|  | ||||
| 	 | ||||
| 	local emptypipe = "pipeworks:pipe_"..index.."_empty" | ||||
| 	local fullpipe = "pipeworks:pipe_"..index.."_loaded" | ||||
| 	table.insert(pipes_empty_nodenames, emptypipe) | ||||
| @@ -241,7 +239,7 @@ minetest.register_abm({ | ||||
| 	nodenames = {"pipeworks:spigot","pipeworks:spigot_pouring"}, | ||||
| 	interval = 1, | ||||
| 	chance = 1, | ||||
| 	action = function(pos, node, active_object_count, active_object_count_wider) | ||||
| 	action = function(pos, node, active_object_count, active_object_count_wider)  | ||||
| 		pipeworks.spigot_check(pos,node) | ||||
| 	end | ||||
| }) | ||||
| @@ -250,7 +248,7 @@ minetest.register_abm({ | ||||
| 	nodenames = {"pipeworks:fountainhead","pipeworks:fountainhead_pouring"}, | ||||
| 	interval = 1, | ||||
| 	chance = 1, | ||||
| 	action = function(pos, node, active_object_count, active_object_count_wider) | ||||
| 	action = function(pos, node, active_object_count, active_object_count_wider)  | ||||
| 		pipeworks.fountainhead_check(pos,node) | ||||
| 	end | ||||
| }) | ||||
|   | ||||
| @@ -29,7 +29,7 @@ end | ||||
|  | ||||
|  | ||||
|  | ||||
| --~ local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..tostring(vec.y)..sep..tostring(vec.z)..")" end | ||||
| local formatvec = function(vec) local sep="," return "("..tostring(vec.x)..sep..tostring(vec.y)..sep..tostring(vec.z)..")" end | ||||
|  | ||||
|  | ||||
|  | ||||
| @@ -39,7 +39,7 @@ end | ||||
| local check_for_liquids_v2 = function(pos, limit) | ||||
| 	local coords = make_coords_offsets(pos, false) | ||||
| 	local total = 0 | ||||
| 	for _, tpos in ipairs(coords) do | ||||
| 	for index, tpos in ipairs(coords) do | ||||
| 		if total >= limit then break end | ||||
| 		local name = minetest.get_node(tpos).name | ||||
| 		if name == "default:water_source" then | ||||
| @@ -69,13 +69,11 @@ end | ||||
|  | ||||
|  | ||||
| -- logging is unreliable when something is crashing... | ||||
| --[[ | ||||
| local nilexplode = function(caller, label, value) | ||||
| 	if value == nil then | ||||
| 		error(caller..": "..label.." was nil") | ||||
| 	end | ||||
| end | ||||
| --]] | ||||
|  | ||||
|  | ||||
|  | ||||
| @@ -153,7 +151,7 @@ local get_neighbour_positions = function(pos, node) | ||||
|  | ||||
| 	-- then, check each possible neighbour to see if they can be reached from this node. | ||||
| 	local connections = {} | ||||
| 	for _, offset in ipairs(candidates) do | ||||
| 	for index, offset in ipairs(candidates) do | ||||
| 		local npos = vector.add(pos, offset) | ||||
| 		local neighbour = minetest.get_node(npos) | ||||
| 		local nodename = neighbour.name | ||||
| @@ -187,12 +185,13 @@ flowlogic.balance_pressure = function(pos, node, currentpressure) | ||||
| 	-- local dname = "flowlogic.balance_pressure()@"..formatvec(pos).." " | ||||
| 	-- 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. | ||||
| 	-- result of averaging will be returned as new pressure for main flow logic callback | ||||
| 	local totalv = currentpressure | ||||
| 	local totalc = 1 | ||||
|  | ||||
| 	-- pressure handles to average over | ||||
| 	local connections = get_neighbour_positions(pos, node) | ||||
|  | ||||
| 	-- for each neighbour, add neighbour's pressure to the total to balance out | ||||
| @@ -288,7 +287,7 @@ flowlogic.run_output = function(pos, node, currentpressure, oldpressure, outputd | ||||
| 	local upper = outputdef.upper | ||||
| 	local lower = outputdef.lower | ||||
| 	local result = currentpressure | ||||
| 	local threshold | ||||
| 	local threshold = nil | ||||
| 	if finitemode then threshold = lower else threshold = upper end | ||||
| 	if currentpressure > threshold then | ||||
| 		local takenpressure = outputdef.outputfn(pos, node, currentpressure, finitemode) | ||||
| @@ -317,7 +316,7 @@ flowlogic.run_transition = function(node, currentpressure) | ||||
| 		local nodename_prev = simplesetdef[1].nodename | ||||
| 		local result_nodename = node.name | ||||
|  | ||||
| 		for _, element in ipairs(simplesetdef) do | ||||
| 		for index, element in ipairs(simplesetdef) do | ||||
| 			-- find the highest element that is below the current pressure. | ||||
| 			local threshold = element.threshold | ||||
| 			if threshold > currentpressure then | ||||
| @@ -339,9 +338,7 @@ flowlogic.run_transition = function(node, currentpressure) | ||||
| 	end | ||||
|  | ||||
| 	if not found then | ||||
| 		pipeworks.logger("flowlogic.run_transition() BUG no transition " .. | ||||
| 			"definitions found! node.name=" .. node.name .. | ||||
| 			" currentpressure=" .. tostring(currentpressure)) | ||||
| 		pipeworks.logger("flowlogic.run_transition() BUG no transition definitions found! nodename="..nodename.." currentpressure="..tostring(currentpressure)) | ||||
| 	end | ||||
|  | ||||
| 	return result | ||||
|   | ||||
| @@ -26,8 +26,8 @@ local insertbase = function(nodename) | ||||
| end | ||||
|  | ||||
| local regwarning = function(kind, nodename) | ||||
| 	--~ local tail = "" | ||||
| 	--~ if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end | ||||
| 	local tail = "" | ||||
| 	if pipeworks.toggles.pipe_mode ~= "pressure" then tail = " but pressure logic not enabled" end | ||||
| 	--pipeworks.logger(kind.." flow logic registry requested for "..nodename..tail) | ||||
| end | ||||
|  | ||||
| @@ -106,7 +106,7 @@ register.directional_horizonal_rotate = function(nodename, doubleended) | ||||
| 	end | ||||
| 	local directionfn = function(node, direction) | ||||
| 		local result = false | ||||
| 		for _, endvec in ipairs(getends(node)) do | ||||
| 		for index, endvec in ipairs(getends(node)) do | ||||
| 			if vector.equals(direction, endvec) then result = true end | ||||
| 		end | ||||
| 		return result | ||||
|   | ||||
| @@ -23,7 +23,7 @@ end | ||||
| local function migrate_tube_db() | ||||
| 		local tmp_db = {} | ||||
| 		tp_tube_db.version = nil | ||||
| 		for _, val in pairs(tp_tube_db) do | ||||
| 		for key, val in pairs(tp_tube_db) do | ||||
| 			if(val.channel ~= "") then -- skip unconfigured tubes | ||||
| 				tmp_db[hash(val)] = val | ||||
| 			end | ||||
| @@ -193,7 +193,7 @@ pipeworks.register_tube("pipeworks:teleport_tube", { | ||||
| 						minetest.chat_send_player(sender_name, S("Sorry, channel '@1' is reserved for exclusive use by @2", | ||||
| 							new_channel, name)) | ||||
| 						return | ||||
|  | ||||
| 				 | ||||
| 					--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 | ||||
| 						minetest.chat_send_player(sender_name, S("Sorry, receiving from channel '@1' is reserved for @2", | ||||
|   | ||||
							
								
								
									
										12
									
								
								trashcan.lua
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								trashcan.lua
									
									
									
									
									
								
							| @@ -1,7 +1,7 @@ | ||||
| local S = minetest.get_translator("pipeworks") | ||||
| minetest.register_node("pipeworks:trashcan", { | ||||
| 	description = S("Trash Can"), | ||||
| 	drawtype = "normal", | ||||
| 	description = S("Trash Can"),  | ||||
| 	drawtype = "normal",  | ||||
| 	tiles = { | ||||
| 		"pipeworks_trashcan_bottom.png", | ||||
| 		"pipeworks_trashcan_bottom.png", | ||||
| @@ -9,15 +9,15 @@ minetest.register_node("pipeworks:trashcan", { | ||||
| 		"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},  | ||||
| 	tube = { | ||||
| 		insert_object = function(pos, node, stack, direction) | ||||
| 			return ItemStack("") | ||||
| 		end, | ||||
| 		connect_sides = {left = 1, right = 1, front = 1, back = 1, top = 1, bottom = 1}, | ||||
| 		priority = 1, -- Lower than anything else | ||||
| 	}, | ||||
| 	},  | ||||
| 	on_construct = function(pos) | ||||
| 		local meta = minetest.get_meta(pos) | ||||
| 		meta:set_string("formspec", | ||||
| @@ -33,7 +33,7 @@ minetest.register_node("pipeworks:trashcan", { | ||||
| 				"listring[]") | ||||
| 		meta:set_string("infotext", S("Trash Can")) | ||||
| 		meta:get_inventory():set_size("trash", 1) | ||||
| 	end, | ||||
| 	end,  | ||||
| 	after_place_node = pipeworks.after_place, | ||||
| 	after_dig_node = pipeworks.after_dig, | ||||
| 	on_metadata_inventory_put = function(pos, listname, index, stack, player) | ||||
|   | ||||
| @@ -1,6 +1,10 @@ | ||||
| local S = minetest.get_translator("pipeworks") | ||||
| 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) | ||||
| 	return (function() return x end) | ||||
| end | ||||
| @@ -349,7 +353,7 @@ if pipeworks.enable_node_breaker then | ||||
| 							{pos=pointed_thing.under, gain=sound.gain}) | ||||
| 					end | ||||
| 					wieldstack = virtplayer:get_wielded_item() | ||||
| 				--~ else | ||||
| 				else | ||||
| 					--pipeworks.logger(dname.."couldn't dig node!") | ||||
| 				end | ||||
| 			end | ||||
|   | ||||
		Reference in New Issue
	
	Block a user