diff --git a/coal_power_station/firebox.lua b/coal_power_station/firebox.lua index f9d63c4..19c3fd1 100644 --- a/coal_power_station/firebox.lua +++ b/coal_power_station/firebox.lua @@ -55,7 +55,6 @@ local function node_timer(pos, elapsed) mem.burn_cycles = firebox.Burntime[taken:get_name()] / CYCLE_TIME mem.burn_cycles = mem.burn_cycles * 4 / (mem.power_level or 4) mem.burn_cycles_total = mem.burn_cycles - print("firebox", mem.burn_cycles_total) else mem.running = false firehole(pos, false) @@ -67,6 +66,15 @@ local function node_timer(pos, elapsed) end end +local function start_firebox(pos, mem) + if not mem.running then + mem.running = true + node_timer(pos, 0) + firehole(pos, true) + minetest.get_node_timer(pos):start(CYCLE_TIME) + end +end + minetest.register_node("techage:coalfirebox", { description = I("TA3 Coal Power Station Firebox"), inventory_image = "techage_coal_boiler_inv.png", @@ -108,16 +116,8 @@ minetest.register_node("techage:coalfirebox", { on_metadata_inventory_put = function(pos, listname, index, stack, player) local mem = tubelib2.get_mem(pos) - mem.running = true - -- activate the formspec fire temporarily - if not mem.burn_cycles or mem.burn_cycles == 0 then - mem.burn_cycles = firebox.Burntime[stack:get_name()] / CYCLE_TIME - mem.burn_cycles = mem.burn_cycles * 4 / (mem.power_level or 4) - mem.burn_cycles_total = mem.burn_cycles - M(pos):set_string("formspec", firebox.formspec(mem)) - end - firehole(pos, true) - minetest.get_node_timer(pos):start(CYCLE_TIME) + start_firebox(pos, mem) + M(pos):set_string("formspec", firebox.formspec(mem)) end, }) @@ -182,7 +182,7 @@ minetest.register_node("techage:coalfirehole_on", { groups = {not_in_creative_inventory=1}, }) -techage.register_node({"techage:coalfirehole", "techage:coalfirehole_on"}, { +techage.register_node({"techage:coalfirebox"}, { on_pull_item = function(pos, in_dir, num) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() @@ -191,6 +191,8 @@ techage.register_node({"techage:coalfirehole", "techage:coalfirehole_on"}, { on_push_item = function(pos, in_dir, stack) local meta = minetest.get_meta(pos) local inv = meta:get_inventory() + local mem = tubelib2.get_mem(pos) + start_firebox(pos, mem) return techage.put_items(inv, "fuel", stack) end, on_unpull_item = function(pos, in_dir, stack) @@ -218,19 +220,6 @@ minetest.register_craft({ }, }) -techage.register_node({"techage:coalfirebox"}, { - on_push_item = function(pos, in_dir, stack) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - if inv:room_for_item("fuel", stack) then - inv:add_item("fuel", stack) - minetest.get_node_timer(pos):start(CYCLE_TIME) - return true - end - return false - end, -}) - minetest.register_lbm({ label = "[techage] Power Station firebox", name = "techage:steam_engine", diff --git a/oil/pumpjack.lua b/oil/pumpjack.lua index fcf396f..99f2107 100644 --- a/oil/pumpjack.lua +++ b/oil/pumpjack.lua @@ -91,8 +91,13 @@ local function on_receive_fields(pos, formname, fields, player) if minetest.is_protected(pos, player:get_player_name()) then return end - local mem = tubelib2.get_mem(pos) - CRD(pos).State:state_button_event(pos, mem, fields) + if fields.update then + local mem = tubelib2.get_mem(pos) + M(pos):set_string("formspec", formspec(CRD(pos).State, pos, mem)) + else + local mem = tubelib2.get_mem(pos) + CRD(pos).State:state_button_event(pos, mem, fields) + end end local tiles = {}