oil tower added
This commit is contained in:
parent
9b0c84c4d7
commit
a067e77723
@ -53,24 +53,6 @@ local function chat(player, text)
|
|||||||
minetest.chat_send_player(player:get_player_name(), "[Techage] "..text)
|
minetest.chat_send_player(player:get_player_name(), "[Techage] "..text)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_node_lvm(pos)
|
|
||||||
local node = minetest.get_node_or_nil(pos)
|
|
||||||
if node then
|
|
||||||
return node
|
|
||||||
end
|
|
||||||
local vm = minetest.get_voxel_manip()
|
|
||||||
local MinEdge, MaxEdge = vm:read_from_map(pos, pos)
|
|
||||||
local data = vm:get_data()
|
|
||||||
local param2_data = vm:get_param2_data()
|
|
||||||
local area = VoxelArea:new({MinEdge = MinEdge, MaxEdge = MaxEdge})
|
|
||||||
local idx = area:index(pos.x, pos.y, pos.z)
|
|
||||||
node = {
|
|
||||||
name = minetest.get_name_from_content_id(data[idx]),
|
|
||||||
param2 = param2_data[idx]
|
|
||||||
}
|
|
||||||
return node
|
|
||||||
end
|
|
||||||
|
|
||||||
local function add_pos(pos, player)
|
local function add_pos(pos, player)
|
||||||
local lPos = minetest.deserialize(player:get_attribute("techage_forceload_blocks")) or {}
|
local lPos = minetest.deserialize(player:get_attribute("techage_forceload_blocks")) or {}
|
||||||
if not in_list(lPos, pos) and #lPos < techage.max_num_forceload_blocks then
|
if not in_list(lPos, pos) and #lPos < techage.max_num_forceload_blocks then
|
||||||
@ -202,7 +184,7 @@ end
|
|||||||
minetest.register_on_joinplayer(function(player)
|
minetest.register_on_joinplayer(function(player)
|
||||||
local lPos = {}
|
local lPos = {}
|
||||||
for _,pos in ipairs(get_pos_list(player)) do
|
for _,pos in ipairs(get_pos_list(player)) do
|
||||||
local node = get_node_lvm(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
if node.name == "techage:forceload" then
|
if node.name == "techage:forceload" then
|
||||||
minetest.forceload_block(pos, true)
|
minetest.forceload_block(pos, true)
|
||||||
lPos[#lPos+1] = pos
|
lPos[#lPos+1] = pos
|
||||||
|
@ -316,7 +316,7 @@ end
|
|||||||
function techage.transfer(pos, outdir, topic, payload, network, nodenames)
|
function techage.transfer(pos, outdir, topic, payload, network, nodenames)
|
||||||
-- determine out-dir
|
-- determine out-dir
|
||||||
if outdir and type(outdir) == "string" then
|
if outdir and type(outdir) == "string" then
|
||||||
local param2 = Tube:get_node_lvm(pos).param2
|
local param2 = techage.get_node_lvm(pos).param2
|
||||||
outdir = side_to_dir(outdir, param2)
|
outdir = side_to_dir(outdir, param2)
|
||||||
end
|
end
|
||||||
-- determine destination pos
|
-- determine destination pos
|
||||||
@ -327,7 +327,7 @@ function techage.transfer(pos, outdir, topic, payload, network, nodenames)
|
|||||||
dpos, indir = tubelib2.get_pos(pos, outdir)
|
dpos, indir = tubelib2.get_pos(pos, outdir)
|
||||||
end
|
end
|
||||||
-- check node name
|
-- check node name
|
||||||
local name = Tube:get_node_lvm(dpos).name
|
local name = techage.get_node_lvm(dpos).name
|
||||||
if nodenames and not in_list(nodenames, name) then
|
if nodenames and not in_list(nodenames, name) then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
@ -56,7 +56,7 @@ local function on_power_pass2(pos, mem, sum)
|
|||||||
if sum > 0 and state == techage.NOPOWER then
|
if sum > 0 and state == techage.NOPOWER then
|
||||||
crd.State:start(pos, mem)
|
crd.State:start(pos, mem)
|
||||||
return 0
|
return 0
|
||||||
elseif sum <= 0 and ValidPowerConsumingStates[state] then
|
elseif sum <= 0 and ValidPowerConsumingStates[state] or state == techage.STANDBY then
|
||||||
crd.State:nopower(pos, mem)
|
crd.State:nopower(pos, mem)
|
||||||
return -crd.power_consumption
|
return -crd.power_consumption
|
||||||
end
|
end
|
||||||
|
@ -35,6 +35,26 @@ function techage.one_of(val, selection)
|
|||||||
return selection[1]
|
return selection[1]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function techage.get_node_lvm(pos)
|
||||||
|
local node = minetest.get_node_or_nil(pos)
|
||||||
|
if node then
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
local vm = minetest.get_voxel_manip()
|
||||||
|
local MinEdge, MaxEdge = vm:read_from_map(pos, pos)
|
||||||
|
local data = vm:get_data()
|
||||||
|
local param2_data = vm:get_param2_data()
|
||||||
|
local area = VoxelArea:new({MinEdge = MinEdge, MaxEdge = MaxEdge})
|
||||||
|
local idx = area:index(pos.x, pos.y, pos.z)
|
||||||
|
node = {
|
||||||
|
name = minetest.get_name_from_content_id(data[idx]),
|
||||||
|
param2 = param2_data[idx]
|
||||||
|
}
|
||||||
|
return node
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Functions used to hide electric cable and biogas pipes
|
-- Functions used to hide electric cable and biogas pipes
|
||||||
--
|
--
|
||||||
|
@ -29,7 +29,7 @@ local function rotate(param2)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function swap_node(pos, postfix)
|
local function swap_node(pos, postfix)
|
||||||
local node = Power:get_node_lvm(pos)
|
local node = techage.get_node_lvm(pos)
|
||||||
local parts = string.split(node.name, "_")
|
local parts = string.split(node.name, "_")
|
||||||
if postfix == parts[2] then
|
if postfix == parts[2] then
|
||||||
return
|
return
|
||||||
|
@ -36,7 +36,7 @@ local formspec0 = "size[5,4]"..
|
|||||||
|
|
||||||
local function play_sound(pos)
|
local function play_sound(pos)
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
if mem.techage_state == techage.RUNNING then
|
if CRD(pos).State:is_active(mem) then
|
||||||
mem.handle = minetest.sound_play("techage_oildrill", {
|
mem.handle = minetest.sound_play("techage_oildrill", {
|
||||||
pos = pos,
|
pos = pos,
|
||||||
gain = 1,
|
gain = 1,
|
||||||
@ -47,7 +47,7 @@ end
|
|||||||
|
|
||||||
local function stop_sound(pos)
|
local function stop_sound(pos)
|
||||||
local mem = tubelib2.get_mem(pos)
|
local mem = tubelib2.get_mem(pos)
|
||||||
if mem.techage_state ~= techage.RUNNING and mem.handle then
|
if mem.handle then
|
||||||
minetest.sound_stop(mem.handle)
|
minetest.sound_stop(mem.handle)
|
||||||
mem.handle = nil
|
mem.handle = nil
|
||||||
end
|
end
|
||||||
@ -117,41 +117,41 @@ end
|
|||||||
|
|
||||||
local function drilling(pos, crd, mem, inv)
|
local function drilling(pos, crd, mem, inv)
|
||||||
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
|
M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem))
|
||||||
print("drilling")
|
mem.drill_pos = mem.drill_pos or {x=pos.x, y=pos.y-1, z=pos.z}
|
||||||
if inv:contains_item("src", ItemStack("techage:oil_drillbit")) then
|
|
||||||
mem.drill_pos = mem.drill_pos or {x=pos.x, y=pos.y, z=pos.z}
|
|
||||||
mem.drill_pos.y = mem.drill_pos.y-1
|
|
||||||
local owner = M(pos):get_string("owner")
|
local owner = M(pos):get_string("owner")
|
||||||
local depth = M(pos):get_int("depth")
|
local depth = M(pos):get_int("depth")
|
||||||
if mem.drill_pos.y > -depth then
|
local curr_depth = pos.y - (mem.drill_pos or pos).y
|
||||||
if not minetest.is_protected(mem.drill_pos, owner) then
|
local node = techage.get_node_lvm(mem.drill_pos)
|
||||||
local node = minetest.get_node(mem.drill_pos)
|
|
||||||
if node.name ~= "techage:oil_drillbit2" then
|
|
||||||
local item = ItemStack(node.name)
|
local item = ItemStack(node.name)
|
||||||
if techage.can_node_dig(node) then
|
|
||||||
if inv:room_for_item("dst", item) then
|
if not inv:contains_item("src", ItemStack("techage:oil_drillbit")) then
|
||||||
inv:add_item("dst", item)
|
crd.State:idle(pos, mem)
|
||||||
else
|
elseif curr_depth >= depth then
|
||||||
stop_sound(pos)
|
|
||||||
crd.State:blocked(pos, mem)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
minetest.swap_node(mem.drill_pos, {name = "techage:oil_drillbit2"})
|
|
||||||
inv:remove_item("src", ItemStack("techage:oil_drillbit"))
|
|
||||||
end
|
|
||||||
else
|
|
||||||
stop_sound(pos)
|
|
||||||
crd.State:fault(pos, mem)
|
|
||||||
end
|
|
||||||
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
|
|
||||||
return
|
|
||||||
else
|
|
||||||
M(pos):set_string("oil_found", "true")
|
M(pos):set_string("oil_found", "true")
|
||||||
stop_sound(pos)
|
stop_sound(pos)
|
||||||
crd.State:stop(pos, mem)
|
crd.State:stop(pos, mem)
|
||||||
|
elseif minetest.is_protected(mem.drill_pos, owner) then
|
||||||
|
stop_sound(pos)
|
||||||
|
crd.State:fault(pos, mem)
|
||||||
|
elseif node.name == "techage:oil_drillbit2" then
|
||||||
|
mem.drill_pos.y = mem.drill_pos.y-1
|
||||||
|
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
|
||||||
|
elseif techage.can_node_dig(node) then
|
||||||
|
if inv:room_for_item("dst", item) then
|
||||||
|
inv:add_item("dst", item)
|
||||||
|
minetest.swap_node(mem.drill_pos, {name = "techage:oil_drillbit2"})
|
||||||
|
inv:remove_item("src", ItemStack("techage:oil_drillbit"))
|
||||||
|
mem.drill_pos.y = mem.drill_pos.y-1
|
||||||
|
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
|
||||||
|
else
|
||||||
|
crd.State:blocked(pos, mem)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
minetest.swap_node(mem.drill_pos, {name = "techage:oil_drillbit2"})
|
||||||
|
inv:remove_item("src", ItemStack("techage:oil_drillbit"))
|
||||||
|
mem.drill_pos.y = mem.drill_pos.y-1
|
||||||
|
crd.State:keep_running(pos, mem, COUNTDOWN_TICKS)
|
||||||
end
|
end
|
||||||
crd.State:idle(pos, mem)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local function keep_running(pos, elapsed)
|
local function keep_running(pos, elapsed)
|
||||||
|
@ -188,7 +188,9 @@ minetest.register_node("techage:oilexplorer", {
|
|||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
||||||
emerge_area(pos, node, clicker:get_player_name())
|
emerge_area(pos, node, clicker:get_player_name())
|
||||||
end,
|
end,
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
|
techage.unmark_region(digger:get_player_name())
|
||||||
|
end,
|
||||||
is_ground_content = false,
|
is_ground_content = false,
|
||||||
groups = {snappy=2,cracky=2,oddly_breakable_by_hand=2},
|
groups = {snappy=2,cracky=2,oddly_breakable_by_hand=2},
|
||||||
sounds = default.node_sound_wood_defaults(),
|
sounds = default.node_sound_wood_defaults(),
|
||||||
@ -347,8 +349,8 @@ function techage.explore.get_oil_info(pos)
|
|||||||
while amount == 0 and depth < DEPTH_MAX do
|
while amount == 0 and depth < DEPTH_MAX do
|
||||||
depth = depth + DEPTH_STEP
|
depth = depth + DEPTH_STEP
|
||||||
local posC = {x = center(pos.x), y = center(-depth), z = center(pos.z)}
|
local posC = {x = center(pos.x), y = center(-depth), z = center(pos.z)}
|
||||||
amount = oil_amount(posC)
|
amount = get_oil_amount(posC)
|
||||||
end
|
end
|
||||||
return {depth = center(depth) - 2 + pos.y, amount = amount}
|
return {depth = center(depth) - 1 + pos.y, amount = amount}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user