mirror of
https://github.com/mt-mods/pipeworks.git
synced 2025-05-25 20:30:28 +02:00
make water flow
This commit is contained in:
parent
70d478934d
commit
96d8a5d00b
@ -83,7 +83,7 @@ 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 == pipeworks.liquids.water.flowing or belowname == pipeworks.liquids.water.source) then
|
||||
local spigotname = minetest.get_node(pos).name
|
||||
local fdir=node.param2 % 4
|
||||
local check = {
|
||||
@ -96,14 +96,14 @@ pipeworks.spigot_check = function(pos, node)
|
||||
if near_node and string.find(near_node.name, "_loaded") then
|
||||
if spigotname and spigotname == "pipeworks:spigot" then
|
||||
minetest.add_node(pos,{name = "pipeworks:spigot_pouring", param2 = fdir})
|
||||
if finitewater or belowname ~= "default:water_source" then
|
||||
minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = "default:water_source"})
|
||||
if finitewater or belowname ~= pipeworks.liquids.water.source then
|
||||
minetest.add_node({x=pos.x,y=pos.y-1,z=pos.z},{name = pipeworks.liquids.water.source})
|
||||
end
|
||||
end
|
||||
else
|
||||
if spigotname == "pipeworks:spigot_pouring" then
|
||||
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})
|
||||
end
|
||||
end
|
||||
@ -113,20 +113,20 @@ 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 == pipeworks.liquids.water.flowing or abovename == pipeworks.liquids.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
|
||||
if fountainhead_name and fountainhead_name == "pipeworks:fountainhead" then
|
||||
minetest.add_node(pos,{name = "pipeworks:fountainhead_pouring"})
|
||||
if finitewater or abovename ~= "default:water_source" then
|
||||
minetest.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "default:water_source"})
|
||||
if finitewater or abovename ~= pipeworks.liquids.water.source then
|
||||
minetest.add_node({x=pos.x,y=pos.y+1,z=pos.z},{name = pipeworks.liquids.water.source})
|
||||
end
|
||||
end
|
||||
else
|
||||
if fountainhead_name == "pipeworks:fountainhead_pouring" then
|
||||
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})
|
||||
end
|
||||
end
|
||||
|
10
init.lua
10
init.lua
@ -11,6 +11,16 @@ pipeworks.worldpath = minetest.get_worldpath()
|
||||
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")
|
||||
-- Read the external config file if it exists.
|
||||
local worldsettingspath = pipeworks.worldpath.."/pipeworks_settings.txt"
|
||||
|
2
mod.conf
2
mod.conf
@ -2,5 +2,5 @@ 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 = default, basic_materials, screwdriver
|
||||
depends = basic_materials
|
||||
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver
|
||||
optional_depends = mesecons, mesecons_mvps, digilines, signs_lib, unified_inventory, default, screwdriver, fl_mapgen
|
||||
min_minetest_version = 5.2.0
|
||||
|
@ -42,7 +42,7 @@ local check_for_liquids_v2 = function(pos, limit)
|
||||
for _, tpos in ipairs(coords) do
|
||||
if total >= limit then break end
|
||||
local name = minetest.get_node(tpos).name
|
||||
if name == "default:water_source" then
|
||||
if name == pipeworks.liquids.water.source then
|
||||
minetest.remove_node(tpos)
|
||||
total = total + 1
|
||||
end
|
||||
@ -247,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.
|
||||
-- so in non-finite mode, placing water is dependent on the target node;
|
||||
-- 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
|
||||
minetest.swap_node(npos, {name="default:water_source"})
|
||||
minetest.swap_node(npos, {name=pipeworks.liquids.water.source})
|
||||
end
|
||||
if (not finitemode) or canplace then
|
||||
taken = taken + 1
|
||||
@ -268,7 +268,7 @@ flowlogic.helpers.make_neighbour_cleanup_fixed = function(neighbours)
|
||||
for _, offset in pairs(neighbours) do
|
||||
local npos = vector.add(pos, offset)
|
||||
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))
|
||||
minetest.remove_node(npos)
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user