Browse Source

adding crafting recipes

master
FaceDeer 3 years ago
parent
commit
dd180e1bfb
  1. 92
      crafting.lua
  2. 11
      execute.lua
  3. 5
      init.lua
  4. 3
      nodes.lua

92
crafting.lua

@ -0,0 +1,92 @@
--"waterworks:pipe"
if minetest.get_modpath("pipeworks") then
minetest.register_craft( {
output = "waterworks:pipe 12",
recipe = {
{ "default:steel_ingot", "", "default:steel_ingot" },
{ "default:steel_ingot", "", "default:steel_ingot" },
{ "default:steel_ingot", "", "default:steel_ingot" }
},
})
else
minetest.register_craft( {
output = "waterworks:pipe 12",
recipe = {
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
{ "", "", "" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
},
})
end
--"waterworks:valve_on"
minetest.register_craft( {
output = "waterworks:valve_on",
recipe = {
{ "default:steel_ingot", "", "default:steel_ingot" },
{ "", "waterworks:pipe", "" },
{ "default:steel_ingot", "", "default:steel_ingot" }
},
})
--"waterworks:inlet"
minetest.register_craft( {
output = "waterworks:inlet",
recipe = {
{ "default:steel_ingot", "", "" },
{ "", "waterworks:pipe", "" },
{ "default:steel_ingot", "", "" }
},
})
--"waterworks:pumped_inlet"
minetest.register_craft( {
output = "waterworks:pumped_inlet",
recipe = {
{ "default:steel_ingot", "", "" },
{ "default:mese_crystal_fragment", "waterworks:pipe", "" },
{ "default:steel_ingot", "", "" }
},
})
minetest.register_craft( {
output = "waterworks:pumped_inlet",
recipe = {
{ "default:mese_crystal_fragment", "waterworks:inlet"},
},
})
--"waterworks:outlet"
minetest.register_craft( {
output = "waterworks:outlet",
recipe = {
{ "", "", "default:steel_ingot" },
{ "", "waterworks:pipe", "" },
{ "", "", "default:steel_ingot" }
},
})
--"waterworks:grate"
minetest.register_craft( {
output = "waterworks:grate",
recipe = {
{ "", "default:steel_ingot", "" },
{ "", "waterworks:pipe", "" },
{ "", "default:steel_ingot", "" }
},
})
-- Allow the basic connectors to be cycled through
minetest.register_craft( {
output = "waterworks:inlet",
type = "shapeless",
recipe = { "waterworks:outlet"},
})
minetest.register_craft( {
output = "waterworks:outlet",
type = "shapeless",
recipe = {"waterworks:grate"},
})
minetest.register_craft( {
output = "waterworks:grate",
type = "shapeless",
recipe = {"waterworks:inlet"},
})

11
execute.lua

@ -1,3 +1,5 @@
local pressure_margin = 20
local pipe_cache = {}
local cardinal_dirs = {
@ -124,10 +126,12 @@ waterworks.execute_pipes = function(net_index, net_capacity)
local inlets
local outlets
if net.cache_valid then
if net.cache_valid then
-- We don't need to recalculate, nothing about the pipe network has changed since last time
inlets = pipe_cache[net_index].inlets
outlets = pipe_cache[net_index].outlets
else
-- Find all the inlets and outlets and sort them by pressure
inlets = {}
if net.connected.inlet ~= nil then
for _, inlet_set in pairs(net.connected.inlet) do
@ -148,6 +152,7 @@ waterworks.execute_pipes = function(net_index, net_capacity)
end
table.sort(outlets, sort_by_pressure)
-- Cache the results
pipe_cache[net_index] = {}
pipe_cache[net_index].inlets = inlets
pipe_cache[net_index].outlets = outlets
@ -171,7 +176,9 @@ waterworks.execute_pipes = function(net_index, net_capacity)
--minetest.debug("source: " .. dump(source))
--minetest.debug("sink: " .. dump(sink))
if source.pressure >= sink.pressure then
-- pressure_margin allows us to check sources that are a little bit below sinks,
-- in case the extra pressure from their water depth is sufficient to force water through
if source.pressure + pressure_margin >= sink.pressure then
local source_pos = find_source(source.target)
local sink_pos
if source_pos ~= nil then

5
init.lua

@ -6,6 +6,7 @@ dofile(modpath .. "/globalstep.lua")
dofile(modpath .. "/network.lua")
dofile(modpath .. "/execute.lua")
dofile(modpath .. "/nodes.lua")
dofile(modpath .. "/crafting.lua")
if minetest.settings:get_bool("waterworks_make_default_water_non_renewable") then
local override_def = {liquid_renewable = false}
@ -14,8 +15,8 @@ if minetest.settings:get_bool("waterworks_make_default_water_non_renewable") the
end
-- For test purposes, this rebuilds pipe networks without needing to persist them.
-- May be useful later for fixing broken stuff.
-- This rebuilds pipe networks whenever the map block is loaded.
-- May be useful for fixing broken stuff.
-- Note that this doesn't *remove* pipes that are inappropriately listed in the network,
-- that may be tricky.
--minetest.register_lbm({

3
nodes.lua

@ -88,9 +88,10 @@ minetest.register_node("waterworks:valve_off", {
connect_left = {-0.5, -0.375, -0.375, -0.4375, 0.375, 0.375},
},
paramtype = "light",
drops = "waterworks:valve_on",
is_ground_content = false,
groups = {oddly_breakable_by_hand = 1, waterworks_inert = 1},
groups = {oddly_breakable_by_hand = 1, waterworks_inert = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_metal_defaults(),
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
node.name = "waterworks:valve_on"

Loading…
Cancel
Save