made valves and airtight entry panels work.

Removed "flowing" spigot from creative inventory.
This commit is contained in:
Vanessa Ezekowitz 2013-05-10 17:28:11 -04:00
parent 54a78297bb
commit 9231f9fa01
2 changed files with 130 additions and 15 deletions

View File

@ -124,7 +124,7 @@ for s in ipairs(states) do
local tilex = "pipeworks_valvebody_ends.png" local tilex = "pipeworks_valvebody_ends.png"
local tilez = "pipeworks_valvebody_sides.png" local tilez = "pipeworks_valvebody_sides.png"
minetest.register_node("pipeworks:valve_"..states[s], { minetest.register_node("pipeworks:valve_"..states[s].."_empty", {
description = "Valve", description = "Valve",
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
@ -164,6 +164,51 @@ for s in ipairs(states) do
}) })
end end
local valveboxes = {}
pipe_addbox(valveboxes, pipe_leftstub)
pipe_addbox(valveboxes, pipe_valvebody)
pipe_addbox(valveboxes, pipe_rightstub)
pipe_addbox(valveboxes, pipe_valvehandle_on)
minetest.register_node("pipeworks:valve_on_loaded", {
description = "Valve",
drawtype = "nodebox",
tiles = {
"pipeworks_valvebody_top_on.png",
"pipeworks_valvebody_bottom.png",
"pipeworks_valvebody_ends.png",
"pipeworks_valvebody_ends.png",
"pipeworks_valvebody_sides.png",
"pipeworks_valvebody_sides.png",
},
paramtype = "light",
paramtype2 = "facedir",
selection_box = {
type = "fixed",
fixed = { -8/16, -4/16, -5/16, 8/16, 5/16, 5/16 }
},
node_box = {
type = "fixed",
fixed = valveboxes
},
groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
walkable = true,
pipelike = 1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_int("pipelike",1)
end,
after_place_node = function(pos)
pipe_scanforobjects(pos)
end,
after_dig_node = function(pos)
pipe_scanforobjects(pos)
end,
drop = "pipeworks:valve_off_empty",
pipelike=1,
})
-- grating -- grating
minetest.register_node("pipeworks:grating", { minetest.register_node("pipeworks:grating", {
@ -256,7 +301,7 @@ minetest.register_node("pipeworks:spigot_pouring", {
}, },
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {snappy=3, pipe=1}, groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
walkable = true, walkable = true,
pipelike=1, pipelike=1,
@ -281,8 +326,7 @@ minetest.register_node("pipeworks:spigot_pouring", {
drop = "pipeworks:spigot", drop = "pipeworks:spigot",
}) })
-- sealed pipe entry/exit (horizontal pipe passing through a metal
-- sealed pipe entry/exit (decorative horizontal pipe passing through a metal
-- wall, for use in places where walls should look like they're airtight) -- wall, for use in places where walls should look like they're airtight)
local airtightboxes = {} local airtightboxes = {}
@ -290,7 +334,7 @@ minetest.register_node("pipeworks:spigot_pouring", {
pipe_addbox(airtightboxes, pipe_backstub) pipe_addbox(airtightboxes, pipe_backstub)
pipe_addbox(airtightboxes, entry_panel) pipe_addbox(airtightboxes, entry_panel)
minetest.register_node("pipeworks:entry_panel", { minetest.register_node("pipeworks:entry_panel_empty", {
description = "Airtight Pipe entry/exit", description = "Airtight Pipe entry/exit",
drawtype = "nodebox", drawtype = "nodebox",
tiles = { tiles = {
@ -321,6 +365,53 @@ minetest.register_node("pipeworks:entry_panel", {
type = "fixed", type = "fixed",
fixed = airtightboxes, fixed = airtightboxes,
}, },
selection_box = {
type = "fixed",
fixed = {
{ -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 }
}
}
})
minetest.register_node("pipeworks:entry_panel_loaded", {
description = "Airtight Pipe entry/exit",
drawtype = "nodebox",
tiles = {
"pipeworks_plain.png",
"pipeworks_plain.png",
"pipeworks_plain.png",
"pipeworks_plain.png",
"pipeworks_pipe_end_empty.png",
"pipeworks_pipe_end_empty.png"
},
paramtype = "light",
paramtype2 = "facedir",
groups = {snappy=3, pipe=1, not_in_creative_inventory=1},
sounds = default.node_sound_wood_defaults(),
walkable = true,
after_place_node = function(pos)
pipe_scanforobjects(pos)
end,
after_dig_node = function(pos)
pipe_scanforobjects(pos)
end,
pipelike=1,
on_construct = function(pos)
local meta = minetest.env:get_meta(pos)
meta:set_int("pipelike",1)
end,
node_box = {
type = "fixed",
fixed = airtightboxes,
},
selection_box = {
type = "fixed",
fixed = {
{ -2/16, -2/16, -8/16, 2/16, 2/16, 8/16 },
{ -8/16, -8/16, -1/16, 8/16, 8/16, 1/16 }
}
}
}) })
-- tanks -- tanks
@ -401,18 +492,27 @@ end
-- various actions -- various actions
minetest.register_on_punchnode(function (pos, node) minetest.register_on_punchnode(function (pos, node)
if node.name=="pipeworks:valve_on" then if node.name=="pipeworks:valve_on_empty" then
fdir = minetest.env:get_node(pos).param2 fdir = minetest.env:get_node(pos).param2
minetest.env:add_node(pos, { name = "pipeworks:valve_off", param2 = fdir }) minetest.env:add_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_int("pipelike",0) meta:set_int("pipelike",0)
end end
end) end)
minetest.register_on_punchnode(function (pos, node) minetest.register_on_punchnode(function (pos, node)
if node.name=="pipeworks:valve_off" then if node.name=="pipeworks:valve_on_loaded" then
fdir = minetest.env:get_node(pos).param2 fdir = minetest.env:get_node(pos).param2
minetest.env:add_node(pos, { name = "pipeworks:valve_on", param2 = fdir }) minetest.env:add_node(pos, { name = "pipeworks:valve_off_empty", param2 = fdir })
local meta = minetest.env:get_meta(pos)
meta:set_int("pipelike",0)
end
end)
minetest.register_on_punchnode(function (pos, node)
if node.name=="pipeworks:valve_off_empty" then
fdir = minetest.env:get_node(pos).param2
minetest.env:add_node(pos, { name = "pipeworks:valve_on_empty", param2 = fdir })
local meta = minetest.env:get_meta(pos) local meta = minetest.env:get_meta(pos)
meta:set_int("pipelike",1) meta:set_int("pipelike",1)
end end
@ -444,6 +544,10 @@ minetest.register_alias("pipeworks:valve_off_x", "pipeworks:valve_off")
minetest.register_alias("pipeworks:valve_off_z", "pipeworks:valve_off") minetest.register_alias("pipeworks:valve_off_z", "pipeworks:valve_off")
minetest.register_alias("pipeworks:valve_on_x", "pipeworks:valve_on") minetest.register_alias("pipeworks:valve_on_x", "pipeworks:valve_on")
minetest.register_alias("pipeworks:valve_on_z", "pipeworks:valve_on") minetest.register_alias("pipeworks:valve_on_z", "pipeworks:valve_on")
minetest.register_alias("pipeworks:valve_off", "pipeworks:valve_off_empty")
minetest.register_alias("pipeworks:valve_on", "pipeworks:valve_on_empty")
minetest.register_alias("pipeworks:valve_off_loaded", "pipeworks:valve_off_empty")
minetest.register_alias("pipeworks:entry_panel", "pipeworks:entry_panel_empty")
minetest.register_alias("pipeworks:storage_tank_0_x", "pipeworks:storage_tank_0") minetest.register_alias("pipeworks:storage_tank_0_x", "pipeworks:storage_tank_0")
minetest.register_alias("pipeworks:storage_tank_0_z", "pipeworks:storage_tank_0") minetest.register_alias("pipeworks:storage_tank_0_z", "pipeworks:storage_tank_0")
minetest.register_alias("pipeworks:storage_tank_1_x", "pipeworks:storage_tank_1") minetest.register_alias("pipeworks:storage_tank_1_x", "pipeworks:storage_tank_1")

View File

@ -47,13 +47,14 @@ local check4inflows = function(pos,node)
end end
if newnode then if newnode then
dbg(newnode..' to replace '..node.name) dbg(newnode..' to replace '..node.name)
minetest.env:add_node(pos,{name=newnode}) minetest.env:add_node(pos,{name=newnode, param2 = node.param2})
minetest.env:get_meta(pos):set_string('source',minetest.pos_to_string(source)) minetest.env:get_meta(pos):set_string('source',minetest.pos_to_string(source))
end end
end end
local checksources = function(pos,node) local checksources = function(pos,node)
local sourcepos = minetest.string_to_pos(minetest.env:get_meta(pos):get_string('source')) local sourcepos = minetest.string_to_pos(minetest.env:get_meta(pos):get_string('source'))
if not sourcepos then return end
local source = minetest.env:get_node(sourcepos).name local source = minetest.env:get_node(sourcepos).name
local newnode = false local newnode = false
if not ((source == 'pipeworks:pump_on' and check4liquids(sourcepos)) or string.find(source,'_loaded') or source == 'ignore' ) then if not ((source == 'pipeworks:pump_on' and check4liquids(sourcepos)) or string.find(source,'_loaded') or source == 'ignore' ) then
@ -62,7 +63,7 @@ local checksources = function(pos,node)
if newnode then dbg(newnode..' to replace '..node.name) end if newnode then dbg(newnode..' to replace '..node.name) end
if newnode then if newnode then
minetest.env:add_node(pos,{name=newnode}) minetest.env:add_node(pos,{name=newnode, param2 = node.param2})
minetest.env:get_meta(pos):set_string('source','') minetest.env:get_meta(pos):set_string('source','')
end end
end end
@ -99,6 +100,16 @@ local spigot_check = function(pos,node)
end end
end end
table.insert(pipes_empty_nodenames,"pipeworks:valve_on_empty")
table.insert(pipes_empty_nodenames,"pipeworks:valve_off_empty")
table.insert(pipes_empty_nodenames,"pipeworks:valve_on_loaded")
table.insert(pipes_empty_nodenames,"pipeworks:entry_panel_empty")
table.insert(pipes_full_nodenames,"pipeworks:valve_on_empty")
table.insert(pipes_full_nodenames,"pipeworks:valve_off_empty")
table.insert(pipes_full_nodenames,"pipeworks:valve_on_loaded")
table.insert(pipes_full_nodenames,"pipeworks:entry_panel_loaded")
minetest.register_abm({ minetest.register_abm({
nodenames = pipes_empty_nodenames, nodenames = pipes_empty_nodenames,
interval = 1, interval = 1,