diff --git a/basis/assemble.lua b/basis/assemble.lua index 8a39207..45e09b4 100644 --- a/basis/assemble.lua +++ b/basis/assemble.lua @@ -81,7 +81,7 @@ local function check_space(pos, param2, AssemblyPlan, player_name) local node = techage.get_node_lvm(pos1) local ndef = minetest.registered_nodes[node.name] - if not ndef or ndef.walkable and node.name ~= node_name then + if not ndef or not ndef.buildable_to and node.name ~= node_name then minetest.chat_send_player(player_name, S("[TA] Not enough space!")) return false end diff --git a/basis/firebox_lib.lua b/basis/firebox_lib.lua index a465807..294d2e6 100644 --- a/basis/firebox_lib.lua +++ b/basis/firebox_lib.lua @@ -118,3 +118,34 @@ function techage.firebox.has_fuel(pos) local items = inv:get_stack("fuel", 1) return items:get_count() > 0 end + +function techage.firebox.is_free_position(pos, player_name) + local pos2 = techage.get_pos(pos, 'F') + if minetest.is_protected(pos2, player_name) then + minetest.chat_send_player(player_name, S("[TA] Area is protected!")) + return false + end + local node = techage.get_node_lvm(pos2) + local ndef = minetest.registered_nodes[node.name] + if not ndef or not ndef.buildable_to then + minetest.chat_send_player(player_name, S("[TA] Not enough space!")) + return false + end + return true +end + +function techage.firebox.set_firehole(pos, on) + local param2 = techage.get_node_lvm(pos).param2 + local pos2 = techage.get_pos(pos, 'F') + if on == true then + minetest.swap_node(pos2, {name="techage:coalfirehole_on", param2 = param2}) + elseif on == false then + minetest.swap_node(pos2, {name="techage:coalfirehole", param2 = param2}) + else + local node = techage.get_node_lvm(pos2) + if node.name == "techage:coalfirehole" or node.name == "techage:coalfirehole_on" then + minetest.swap_node(pos2, {name="air"}) + end + end +end + diff --git a/basis/tubes.lua b/basis/tubes.lua index d3848ff..a31ef48 100644 --- a/basis/tubes.lua +++ b/basis/tubes.lua @@ -90,7 +90,7 @@ minetest.register_node("techage:tubeS", { paramtype = "light", sunlight_propagates = true, is_ground_content = false, - groups = {choppy=2, cracky=3, stone=1}, + groups = {choppy=2, cracky=3}, sounds = default.node_sound_wood_defaults(), }) @@ -130,7 +130,7 @@ minetest.register_node("techage:tubeA", { paramtype = "light", sunlight_propagates = true, is_ground_content = false, - groups = {choppy=2, cracky=3, stone=1, not_in_creative_inventory=1}, + groups = {choppy=2, cracky=3, not_in_creative_inventory=1}, sounds = default.node_sound_wood_defaults(), drop = "techage:tubeS", }) diff --git a/basis/tubes_ta4.lua b/basis/tubes_ta4.lua index 14bb6f0..0178c8f 100644 --- a/basis/tubes_ta4.lua +++ b/basis/tubes_ta4.lua @@ -57,7 +57,7 @@ minetest.register_node("techage:ta4_tubeS", { paramtype = "light", sunlight_propagates = true, is_ground_content = false, - groups = {choppy=2, cracky=3, stone=1}, + groups = {choppy=2, cracky=3}, sounds = default.node_sound_wood_defaults(), }) @@ -97,7 +97,7 @@ minetest.register_node("techage:ta4_tubeA", { paramtype = "light", sunlight_propagates = true, is_ground_content = false, - groups = {choppy=2, cracky=3, stone=1, not_in_creative_inventory=1}, + groups = {choppy=2, cracky=3, not_in_creative_inventory=1}, sounds = default.node_sound_wood_defaults(), drop = "techage:ta4_tubeS", }) diff --git a/coal_power_station/firebox.lua b/coal_power_station/firebox.lua index 70547ac..467c05e 100644 --- a/coal_power_station/firebox.lua +++ b/coal_power_station/firebox.lua @@ -22,18 +22,6 @@ local firebox = techage.firebox local CYCLE_TIME = 2 local BURN_CYCLE_FACTOR = 0.5 -local function firehole(pos, on) - local param2 = techage.get_node_lvm(pos).param2 - local pos2 = techage.get_pos(pos, 'F') - if on == true then - minetest.swap_node(pos2, {name="techage:coalfirehole_on", param2 = param2}) - elseif on == false then - minetest.swap_node(pos2, {name="techage:coalfirehole", param2 = param2}) - else - minetest.swap_node(pos2, {name="air"}) - end -end - local function node_timer(pos, elapsed) local nvm = techage.get_nvm(pos) local power = techage.transfer( @@ -52,7 +40,7 @@ local function node_timer(pos, elapsed) nvm.burn_cycles_total = nvm.burn_cycles else nvm.running = false - firehole(pos, false) + firebox.set_firehole(pos, false) M(pos):set_string("formspec", firebox.formspec(nvm)) return false end @@ -67,7 +55,7 @@ local function start_firebox(pos, nvm) if not nvm.running then nvm.running = true node_timer(pos, 0) - firehole(pos, true) + firebox.set_firehole(pos, true) minetest.get_node_timer(pos):start(CYCLE_TIME) end end @@ -96,20 +84,25 @@ minetest.register_node("techage:coalfirebox", { allow_metadata_inventory_take = firebox.allow_metadata_inventory_take, on_rightclick = firebox.on_rightclick, - on_construct = function(pos) - techage.add_node(pos, "techage:coalfirebox") - local nvm = techage.get_nvm(pos) - nvm.running = false - nvm.burn_cycles = 0 - local meta = M(pos) - meta:set_string("formspec", firebox.formspec(nvm)) - local inv = meta:get_inventory() - inv:set_size('fuel', 1) - firehole(pos, false) + after_place_node = function(pos, placer) + if firebox.is_free_position(pos, placer:get_player_name()) then + techage.add_node(pos, "techage:coalfirebox") + local nvm = techage.get_nvm(pos) + nvm.running = false + nvm.burn_cycles = 0 + local meta = M(pos) + meta:set_string("formspec", firebox.formspec(nvm)) + local inv = meta:get_inventory() + inv:set_size('fuel', 1) + firebox.set_firehole(pos, false) + else + minetest.remove_node(pos) + return true + end end, on_destruct = function(pos) - firehole(pos, nil) + firebox.set_firehole(pos, nil) end, on_metadata_inventory_put = function(pos, listname, index, stack, player) diff --git a/coal_power_station/oilfirebox.lua b/coal_power_station/oilfirebox.lua index 6c45912..7de649b 100644 --- a/coal_power_station/oilfirebox.lua +++ b/coal_power_station/oilfirebox.lua @@ -25,18 +25,6 @@ local liquid = techage.liquid local CYCLE_TIME = 2 local BURN_CYCLE_FACTOR = 0.5 -local function firehole(pos, on) - local param2 = techage.get_node_lvm(pos).param2 - local pos2 = techage.get_pos(pos, 'F') - if on == true then - minetest.swap_node(pos2, {name="techage:coalfirehole_on", param2 = param2}) - elseif on == false then - minetest.swap_node(pos2, {name="techage:coalfirehole", param2 = param2}) - else - minetest.swap_node(pos2, {name="air"}) - end -end - local function node_timer(pos, elapsed) local nvm = techage.get_nvm(pos) local power = techage.transfer( @@ -55,7 +43,7 @@ local function node_timer(pos, elapsed) nvm.burn_cycles_total = nvm.burn_cycles else nvm.running = false - firehole(pos, false) + firebox.set_firehole(pos, false) M(pos):set_string("formspec", fuel.formspec(nvm)) return false end @@ -70,7 +58,7 @@ local function start_firebox(pos, nvm) if not nvm.running and fuel.has_fuel(nvm) then nvm.running = true node_timer(pos, 0) - firehole(pos, true) + firebox.set_firehole(pos, true) minetest.get_node_timer(pos):start(CYCLE_TIME) end end @@ -98,21 +86,26 @@ minetest.register_node("techage:oilfirebox", { on_rightclick = fuel.on_rightclick, on_receive_fields = fuel.on_receive_fields, - on_construct = function(pos) - techage.add_node(pos, "techage:oilfirebox") - local nvm = techage.get_nvm(pos) - nvm.running = false - nvm.burn_cycles = 0 - nvm.liquid = {} - nvm.liquid.amount = 0 - local meta = M(pos) - meta:set_string("formspec", fuel.formspec(nvm)) - local inv = meta:get_inventory() - firehole(pos, false) + after_place_node = function(pos, placer) + if firebox.is_free_position(pos, placer:get_player_name()) then + techage.add_node(pos, "techage:oilfirebox") + local nvm = techage.get_nvm(pos) + nvm.running = false + nvm.burn_cycles = 0 + nvm.liquid = {} + nvm.liquid.amount = 0 + local meta = M(pos) + meta:set_string("formspec", fuel.formspec(nvm)) + local inv = meta:get_inventory() + firebox.set_firehole(pos, false) + else + minetest.remove_node(pos) + return true + end end, - + on_destruct = function(pos) - firehole(pos, nil) + firebox.set_firehole(pos, nil) end, on_punch = function(pos, node, puncher, pointed_thing)