diff --git a/basis/lib.lua b/basis/lib.lua index 783e4cc..c6466d4 100644 --- a/basis/lib.lua +++ b/basis/lib.lua @@ -74,17 +74,21 @@ function techage.is_primary_node(pos, dir) return param2 ~= 0 end --- returns true, if node can be dug, or false --- Table result can be used to read the node name of the dropped node when dug -function techage.can_node_dig(node, result) - -- don't remove nodes with some intelligence or undiggable nodes - local ndef = minetest.registered_nodes[node.name] - if not ndef or node.name == "air" then return false end - if ndef.drop == "" then return false end +-- returns true, if node can be dug, otherwise false +function techage.can_node_dig(node, ndef) + if not ndef then return false end + if node.name == "ignore" then return false end + if node.name == "air" then return true end + if ndef.buildable_to == true then return true end if ndef.diggable == false then return false end if ndef.after_dig_node then return false end - if result and type(result) == "table" then - result.name = ndef.drop or node.name - end return true end + +-- returns the node name, if node can be dropped, otherwise nil +function techage.dropped_node(node, ndef) + if node.name == "air" then return end + if ndef.buildable_to == true then return end + if ndef.drop == "" then return end + return ndef.drop or node.name +end diff --git a/lamps/lib.lua b/lamps/lib.lua index 579cd24..7275ac5 100644 --- a/lamps/lib.lua +++ b/lamps/lib.lua @@ -3,7 +3,7 @@ local S = function(pos) if pos then return minetest.pos_to_string(pos) end end local P = minetest.string_to_pos local M = minetest.get_meta -local POWER_CONSUMPTION = 1 +local POWER_CONSUMPTION = 0.5 local Power = techage.ElectricCable diff --git a/oil/drillbox.lua b/oil/drillbox.lua index 09373dc..e346102 100644 --- a/oil/drillbox.lua +++ b/oil/drillbox.lua @@ -36,11 +36,13 @@ local formspec0 = "size[5,4]".. local function play_sound(pos) local mem = tubelib2.get_mem(pos) - mem.handle = minetest.sound_play("techage_oildrill", { - pos = pos, - gain = 1, - max_hear_distance = 15}) - minetest.after(4, play_sound, pos) + if mem.techage_state == techage.RUNNING then + mem.handle = minetest.sound_play("techage_oildrill", { + pos = pos, + gain = 1, + max_hear_distance = 15}) + minetest.after(4, play_sound, pos) + end end local function stop_sound(pos) @@ -126,7 +128,7 @@ local function drilling(pos, crd, mem, inv) local depth = M(pos):get_int("depth") local curr_depth = pos.y - (mem.drill_pos or pos).y local node = techage.get_node_lvm(mem.drill_pos) - local dropped_node = {} + local ndef = minetest.registered_nodes[node.name] if not inv:contains_item("src", ItemStack("techage:oil_drillbit")) then crd.State:idle(pos, mem) @@ -138,22 +140,22 @@ local function drilling(pos, crd, mem, inv) 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, dropped_node) then - local item = ItemStack(dropped_node.name) - if inv:room_for_item("dst", item) then + elseif techage.can_node_dig(node, ndef) then + local drop_name = techage.dropped_node(node, ndef) + if drop_name then + local item = ItemStack(drop_name) + if not inv:room_for_item("dst", item) then + crd.State:blocked(pos, mem) + return + end 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 - 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) + else + crd.State:fault(pos, mem) end end diff --git a/oil/pumpjack.lua b/oil/pumpjack.lua index 2fb0612..fcf396f 100644 --- a/oil/pumpjack.lua +++ b/oil/pumpjack.lua @@ -188,7 +188,7 @@ local _, node_name_ta3, _ = is_ground_content = false, sounds = default.node_sound_wood_defaults(), num_items = {0,1,1,1}, - power_consumption = {0,20,20,20}, + power_consumption = {0,16,16,16}, }, {false, false, true, false}) -- TA3 only