diff --git a/crafts.lua b/crafts.lua index 569712a..252c9eb 100644 --- a/crafts.lua +++ b/crafts.lua @@ -3,7 +3,7 @@ -- pipes minetest.register_craft({ - output = "bitumen:pipe 6", + output = "bitumen:pipe 12", recipe = { {"default:steel_ingot", "default:steel_ingot", "default:steel_ingot"}, {"", "", ""}, @@ -28,7 +28,7 @@ minetest.register_craft({ -- drilling minetest.register_craft({ - output = 'bitumen:drill_pipe 6', + output = 'bitumen:drill_pipe 12', recipe = { {'', 'default:steel_ingot', ''}, {'', 'default:steel_ingot', ''}, diff --git a/pipes.lua b/pipes.lua index a816992..a978b99 100644 --- a/pipes.lua +++ b/pipes.lua @@ -460,7 +460,7 @@ minetest.register_node("bitumen:intake", { if found_net == 0 then local hash = minetest.hash_node_position(pos) local net = new_network(pos) - net.in_pressure = pos.z + net.in_pressure = pos.y net.inputs[hash] = 1 end diff --git a/wells.lua b/wells.lua index 5f400fe..078bbff 100644 --- a/wells.lua +++ b/wells.lua @@ -127,6 +127,106 @@ minetest.register_node("bitumen:well_siphon", { }) + + + +local function pushpos(t, v, p) + local h = minetest.hash_node_position(p) + if v[h] == nil then + table.insert(t, p) + end +end + + +local function find_blob_extent(startpos) + + local blob = {} + local stack = {} + local visited = {} + local future = {} +-- local shell = {} + + + local node = minetest.get_node(startpos) + if node.name == "air" then + return nil + end + + local bname = node.name + + table.insert(stack, startpos) + + while #stack > 0 do + + local p = table.remove(stack) + local ph = minetest.hash_node_position(p) + + --print("visiting "..minetest.pos_to_string(p)) + if p.x < startpos.x - 50 + or p.x > startpos.x + 50 + or p.y < startpos.y - 50 + or p.y > startpos.y + 50 + or p.z < startpos.z - 50 + or p.z > startpos.z + 50 + then + print("got to extent") + visited[ph] = 1 + end + + if visited[ph] == nil then + + print("visiting "..minetest.pos_to_string(p)) + + local pn = minetest.get_node(p) + if pn then + if pn.name == "bitumen:crude_oil" or pn.name == "bitumen:crude_oil_full" then + blob[ph] = {x=p.x, y=p.y, z=p.z} + + pushpos(stack, visited, {x=p.x+1, y=p.y, z=p.z}) + pushpos(stack, visited, {x=p.x-1, y=p.y, z=p.z}) + pushpos(stack, visited, {x=p.x, y=p.y+1, z=p.z}) + pushpos(stack, visited, {x=p.x, y=p.y-1, z=p.z}) + pushpos(stack, visited, {x=p.x, y=p.y, z=p.z+1}) + pushpos(stack, visited, {x=p.x, y=p.y, z=p.z-1}) + + visited[ph] = 1 + elseif pn.name == "ignore" then + if minetest.forceload_block(p, false) then + print("forceload successful: ".. minetest.pos_to_string(p)) + else + print("forceload failed: ".. minetest.pos_to_string(p)) + end + + table.insert(future, p) + end + else + print("failed to get node") + end + end + end + + + for _,p in pairs(blob) do + print("blob "..minetest.pos_to_string(p)) + end + +-- for n,v in pairs(shell) do +-- print("shell "..n.." - ".. v) +-- end + + + return blob--, shell +end + + + + +local function forceload_deposit(pos) +-- minetest.emerge_area(dp, {x=dp.x, y=dp.y - 20, z=dp.z}) + find_blob_extent(pos) +end + + local function drill(pos) local meta = minetest.get_meta(pos) @@ -206,6 +306,8 @@ minetest.register_node("bitumen:drill_controls", { cmd = "retract" elseif fields.stop then cmd = "stop" + elseif fields.pump then + cmd = "pump" elseif fields.up then cmd = "up" elseif fields.down then @@ -400,7 +502,7 @@ minetest.register_node("bitumen:drill_rig", { bitumen.magic.set_nodes(pos, "bitumen:drill_pipe_chest", {pipe_chest_delta}) bitumen.magic.set_nodes(pos, "bitumen:drill_mud_injector", {mud_injector_delta}) bitumen.magic.set_nodes(pos, "bitumen:drill_mud_extractor", {mud_extractor_delta}) - + local function add(p, d) return {x=p.x + d[1], y=p.y + d[2], z=p.z + d[3]} end @@ -413,6 +515,26 @@ minetest.register_node("bitumen:drill_rig", { } + local pcmeta = minetest.get_meta(altnodes.pipe_chest) + local pcinv = pcmeta:get_inventory() + pcinv:set_size("main", 8*32) + + + local pipe_chest_formspec = + "size[8,9;]" .. + default.gui_bg .. + default.gui_bg_img .. + default.gui_slots .. + "list[context;main;0,0.3;8,4;]" .. + "list[current_player;main;0,4.85;8,1;]" .. + "list[current_player;main;0,6.08;8,3;8]" .. + "listring[context;main]" .. + "listring[current_player;main]" .. + default.get_hotbar_bg(0, 4.85) + + pcmeta:set_string("formspec", pipe_chest_formspec) + + local state = { state = "idle", command = "none", @@ -440,29 +562,40 @@ local function get_controls_formspec(state) local up_down = "" if state.state == "idle" then - up_down = "button[5,3;6,1;up;Up One]" .. - "button[5,4;6,1;down;Down One]" + up_down = "button[5,3;4,1;up;Up One]" .. + "button[5,4;4,1;down;Down One]" end local stop = "" if state.state ~= "idle" then - stop = "button[5,0;5,1;stop;Stop]" + stop = "button[5,0;4,1;stop;Stop]" end local drill = "" if state.state ~= "drilling" then - drill = "button[5,1;5,1;drill;Drill]" + drill = "button[5,1;4,1;drill;Drill]" end local retract= "" if state.state ~= "retracting" then - retract = "button[5,2;6,1;retract;Retract Pipe]" + retract = "button[5,2;4,1;retract;Retract Pipe]" + end + + local forceload= "" + if state.state ~= "forceload" then + forceload = "button[5,3;4,1;forceload;Forceload]" + end + + local pump= "" + if state.state ~= "pump" then + pump = "button[5,4;4,1;pump;Pump]" end local state_strings = { drilling = "Drilling", retracting = "Retracting", idle = "Idle", + pump = "Pumping", } local state_str = state_strings[state.state] or "None" @@ -480,6 +613,8 @@ local function get_controls_formspec(state) drill .. retract .. up_down .. + forceload .. + pump .. "" end @@ -533,6 +668,21 @@ local function retract(pos) end +local function pump_oil(pos) + + local dp = check_drill_stack(pos) + + local n = minetest.get_node(dp) + + if n.name == "bitumen:crude_oil" then + minetest.set_node(dp, {name="air"}) + + pos.x = pos.x + 1 + minetest.set_node(pos, {name="bitumen:crude_oil"}) + minetest.set_node_level(pos, 64) + end +end + minetest.register_abm({ nodenames = {"bitumen:drill_rig"}, interval = 2, @@ -562,6 +712,7 @@ minetest.register_abm({ elseif state.command == "stop" then state.state = "idle" elseif state.command == "pump" then + print("set to pump") state.state = "pump" elseif state.command == "explore" then state.state = "idle" @@ -570,6 +721,7 @@ minetest.register_abm({ elseif state.command == "forceload" then state.state = "idle" + forceload_deposit({x=pos.x, y = state.depth - 1, z=pos.z}) -- do forceload elseif state.command == "un_forceload" then state.state = "idle" @@ -595,15 +747,26 @@ minetest.register_abm({ if state.state == "drilling" or inch == -1 then - local n, y, hit_oil = drill(pos) - if n then - state.last_drilled_node = n - state.depth = y - state.max_depth = math.min(y, state.max_depth or y) - - if hit_oil and inch == 0 then - state.state = "idle" + local pcmeta = minetest.get_meta(alts.pipe_chest) + local pcinv = pcmeta:get_inventory() + + if pcinv:contains_item("main", "bitumen:drill_pipe 1") then + + local n, y, hit_oil = drill(pos) + if n then + state.last_drilled_node = n + state.depth = y + state.max_depth = math.min(y, state.max_depth or y) + + pcinv:remove_item("main", "bitumen:drill_pipe 1") + + if hit_oil and inch == 0 then + state.state = "idle" + end end + else + -- out of pipe + state.state = "idle" end elseif state.state == "retracting" or inch == 1 then local y, removed, ended @@ -623,12 +786,27 @@ minetest.register_abm({ elseif state.state == "pump" then local expos = alts.mud_extractor + expos.x = expos.x + 1 local exnet = bitumen.pipes.get_net(expos) - if exnet.fluid == "bitumen:crude_oil" then + if exnet and (exnet.fluid == "bitumen:crude_oil" or exnet.fluid == "air") then -- pump oil + local dp = {x=pos.x, y = state.depth - 1, z=pos.z} + local n = minetest.get_node(dp) + + if n.name == "bitumen:crude_oil" or n.name == "bitumen:crude_oil_full" then +-- minetest.set_node(dp, {name="air"}) + +-- local expos = alts.mud_extractor +-- expos.x = expos.x + 1 + local p = bitumen.pipes.push_fluid(expos, "bitumen:crude_oil", 5, 20) + --print("pushed " .. p) + end + + else -- must empty the mud out of the pipe first + print("well not connected " .. dump(exnet)) end end @@ -642,20 +820,7 @@ minetest.register_abm({ }) -local function pump_oil(pos) - - local dp = check_drill_stack(pos) - - local n = minetest.get_node(dp) - - if n.name == "bitumen:crude_oil" then - minetest.set_node(dp, {name="air"}) - - pos.x = pos.x + 1 - minetest.set_node(pos, {name="bitumen:crude_oil"}) - minetest.set_node_level(pos, 64) - end -end + @@ -678,3 +843,111 @@ minetest.register_node("bitumen:well_pump", { }) + + + + + + + + + + + + + + +local rig_builder_formspec = + "size[10,8;]" .. + default.gui_bg .. + default.gui_bg_img .. + default.gui_slots .. + "list[context;main;0,0.3;4,3;]" .. + "button[5,1;1,4;build;Build]" .. + "list[current_player;main;0,3.85;8,1;]" .. + "list[current_player;main;0,5.08;8,3;8]" .. + "listring[context;main]" .. + "listring[current_player;main]" .. + default.get_hotbar_bg(0, 3.85) + + + + +minetest.register_node("bitumen:oil_rig_constructor", { + description = "Oil Rig Constructor", + drawtype = "normal", + paramtype2 = "facedir", + on_rotate = screwdriver.rotate_simple, + groups = {cracky=1}, + tiles = { + "default_copper_block.png","default_tin_block.png", + }, + + on_construct = function(pos) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + inv:set_size("main", 12) + + meta:set_string("formspec", rig_builder_formspec); + end, + + + on_receive_fields = function(pos, form, fields, player) + + local meta = minetest.get_meta(pos) + + if fields.build then + -- tanks can only be built on thick foundations +--[[ + local ret = check_foundation( + {x = pos.x - 9, y = pos.y - 3, z = pos.z - 9}, + {x = pos.x + 9, y = pos.y - 1, z = pos.z + 9}, + { + ["default:stone"] = 1, + ["bitumen:concrete"] = 1, + } + ) + + if ret == false then + minetest.chat_send_player(player:get_player_name(), "Foundation is incomplete: 10x10x3") + return + else + minetest.chat_send_player(player:get_player_name(), "Foundation is complete.") + end + ]] +-- local inv = meta:get_inventory(); +-- +-- if inv:contains_item("main", "default:steelblock 8") then +-- +-- inv:remove_item("main", "default:steelblock 8") +-- else +-- minetest.chat_send_player(player:get_player_name(), "Not enough materials: 8x SteelBlock") +-- return +-- end + + -- ready to go + minetest.chat_send_player(player:get_player_name(), "Clear area, construction starting...") + + minetest.after(5, function() + minetest.set_node({x=pos.x, y=pos.y + 2, z=pos.z}, {name="bitumen:drill_rig"}) + end) + end + end, +}) + + +bitumen.register_blueprint({name="bitumen:drill_rig"}) + + +minetest.register_craft({ + output = 'bitumen:oil_rig_constructor', + recipe = { + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + {'default:steelblock', 'bitumen:drill_rig_blueprint', 'default:steelblock'}, + {'default:steelblock', 'default:steelblock', 'default:steelblock'}, + } +}) + + + +