This commit is contained in:
Joachim Stolberg 2019-06-09 23:35:43 +02:00
parent 8abb6444d3
commit 8b2e0c6ebb
2 changed files with 21 additions and 27 deletions

View File

@ -55,7 +55,6 @@ local function node_timer(pos, elapsed)
mem.burn_cycles = firebox.Burntime[taken:get_name()] / CYCLE_TIME 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 = mem.burn_cycles * 4 / (mem.power_level or 4)
mem.burn_cycles_total = mem.burn_cycles mem.burn_cycles_total = mem.burn_cycles
print("firebox", mem.burn_cycles_total)
else else
mem.running = false mem.running = false
firehole(pos, false) firehole(pos, false)
@ -67,6 +66,15 @@ local function node_timer(pos, elapsed)
end end
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", { minetest.register_node("techage:coalfirebox", {
description = I("TA3 Coal Power Station Firebox"), description = I("TA3 Coal Power Station Firebox"),
inventory_image = "techage_coal_boiler_inv.png", 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) on_metadata_inventory_put = function(pos, listname, index, stack, player)
local mem = tubelib2.get_mem(pos) local mem = tubelib2.get_mem(pos)
mem.running = true start_firebox(pos, mem)
-- activate the formspec fire temporarily M(pos):set_string("formspec", firebox.formspec(mem))
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)
end, end,
}) })
@ -182,7 +182,7 @@ minetest.register_node("techage:coalfirehole_on", {
groups = {not_in_creative_inventory=1}, 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) on_pull_item = function(pos, in_dir, num)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() 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) on_push_item = function(pos, in_dir, stack)
local meta = minetest.get_meta(pos) local meta = minetest.get_meta(pos)
local inv = meta:get_inventory() local inv = meta:get_inventory()
local mem = tubelib2.get_mem(pos)
start_firebox(pos, mem)
return techage.put_items(inv, "fuel", stack) return techage.put_items(inv, "fuel", stack)
end, end,
on_unpull_item = function(pos, in_dir, stack) 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({ minetest.register_lbm({
label = "[techage] Power Station firebox", label = "[techage] Power Station firebox",
name = "techage:steam_engine", name = "techage:steam_engine",

View File

@ -91,8 +91,13 @@ local function on_receive_fields(pos, formname, fields, player)
if minetest.is_protected(pos, player:get_player_name()) then if minetest.is_protected(pos, player:get_player_name()) then
return return
end end
local mem = tubelib2.get_mem(pos) if fields.update then
CRD(pos).State:state_button_event(pos, mem, fields) 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 end
local tiles = {} local tiles = {}