TA4 Energy Storage System added
This commit is contained in:
parent
232f41d2dd
commit
2575976616
@ -431,9 +431,9 @@ function NodeStates:on_receive_message(pos, topic, payload)
|
||||
elseif topic == "state" then
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == "ignore" then -- unloaded node?
|
||||
return "blocked"
|
||||
return "unloaded"
|
||||
end
|
||||
return self:get_state_string(tubelib2.get_mem(pos))
|
||||
return techage.get_state_string(tubelib2.get_mem(pos))
|
||||
elseif topic == "counter" then
|
||||
return mem.techage_item_meter or 1
|
||||
elseif topic == "clear_counter" then
|
||||
|
@ -18,7 +18,7 @@ local S = techage.S
|
||||
|
||||
local CYCLE_TIME = 2
|
||||
local PWR_PERF = 10
|
||||
local PWR_CAPA = 3000
|
||||
local PWR_CAPA = 2000
|
||||
|
||||
local Power = techage.ElectricCable
|
||||
local power = techage.power
|
||||
@ -130,9 +130,13 @@ minetest.register_node("techage:ta3_akku", {
|
||||
on_construct = tubelib2.init_mem,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
local meta = M(pos)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State:node_init(pos, mem, "")
|
||||
local own_num = techage.add_node(pos, "techage:ta3_akku")
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
meta:set_string("infotext", S("TA3 Akku Box").." "..own_num)
|
||||
State:node_init(pos, mem, own_num)
|
||||
mem.capa = get_capa(itemstack)
|
||||
on_rightclick(pos)
|
||||
end,
|
||||
@ -159,6 +163,26 @@ techage.power.register_node({"techage:ta3_akku"}, {
|
||||
power_network = Power,
|
||||
})
|
||||
|
||||
-- for logical communication
|
||||
techage.register_node({"techage:ta3_akku"}, {
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if topic == "capa" then
|
||||
return techage.power.percent(PWR_CAPA, mem.capa)
|
||||
else
|
||||
return State:on_receive_message(pos, topic, payload)
|
||||
end
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
local meta = M(pos)
|
||||
if meta:get_string("node_number") == "" then
|
||||
local own_num = techage.add_node(pos, "techage:ta3_akku")
|
||||
meta:set_string("node_number", own_num)
|
||||
meta:set_string("infotext", S("TA3 Akku Box").." "..own_num)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
techage.register_entry_page("ta3ps", "akku",
|
||||
S("TA3 Akku Box"),
|
||||
S("Used to store electrical energy. Charged in about 10 min, provides energy for 10 min.@n"..
|
||||
|
@ -17,6 +17,8 @@ local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
|
||||
local BLOCKING_TIME = 2
|
||||
|
||||
local Param2ToDir = {
|
||||
[0] = 6,
|
||||
[1] = 5,
|
||||
@ -57,6 +59,9 @@ local function formspec(pos)
|
||||
"button[1.5,3.3;2,1;update;"..S("Update").."]"
|
||||
end
|
||||
|
||||
local function update_formspec(pos)
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
end
|
||||
|
||||
minetest.register_node("techage:ta3_power_terminal", {
|
||||
description = S("TA3 Power Terminal"),
|
||||
@ -81,16 +86,23 @@ minetest.register_node("techage:ta3_power_terminal", {
|
||||
local node = minetest.get_node(pos)
|
||||
local outdir = techage.side_to_outdir("B", node.param2)
|
||||
local jpos = tubelib2.get_pos(pos, outdir)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
mem.blocked_until = 0
|
||||
local meta = M(pos)
|
||||
meta:set_string("junction_pos", minetest.serialize(jpos))
|
||||
meta:set_string("formspec", formspec(pos))
|
||||
end,
|
||||
|
||||
on_receive_fields = function(pos, formname, fields, player)
|
||||
if fields.update then
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.blocked_until = mem.blocked_until or minetest.get_gametime()
|
||||
if fields.update and mem.blocked_until < minetest.get_gametime() then
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
mem.blocked_until = minetest.get_gametime() + BLOCKING_TIME
|
||||
minetest.after(BLOCKING_TIME + 1, update_formspec, pos)
|
||||
end
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos, node, clicker)
|
||||
M(pos):set_string("formspec", formspec(pos))
|
||||
end,
|
||||
|
@ -1,176 +0,0 @@
|
||||
--[[
|
||||
|
||||
TechAge
|
||||
=======
|
||||
|
||||
Copyright (C) 2019 Joachim Stolberg
|
||||
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA3 Akku Box
|
||||
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
|
||||
local CYCLE_TIME = 2
|
||||
local PWR_PERF = 10
|
||||
local PWR_CAPA = 3000
|
||||
|
||||
local Power = techage.ElectricCable
|
||||
local power = techage.power
|
||||
|
||||
local function in_range(val, min, max)
|
||||
if val < min then return min end
|
||||
if val > max then return max end
|
||||
return val
|
||||
end
|
||||
|
||||
local function formspec(self, pos, mem)
|
||||
return "size[5,3]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"image[0,0.5;1,2;"..techage.power.formspec_power_bar(PWR_CAPA, mem.capa).."]"..
|
||||
"label[0.2,2.5;Load]"..
|
||||
"button[1.1,1;1.8,1;update;"..S("Update").."]"..
|
||||
"image_button[3,1;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
|
||||
"image[4,0.5;1,2;"..techage.power.formspec_load_bar(-(mem.delivered or 0), PWR_PERF).."]"..
|
||||
"label[4.2,2.5;Flow]"
|
||||
end
|
||||
|
||||
|
||||
local function start_node(pos, mem, state)
|
||||
mem.running = true
|
||||
mem.delivered = 0
|
||||
power.secondary_start(pos, mem, PWR_PERF, PWR_PERF)
|
||||
end
|
||||
|
||||
local function stop_node(pos, mem, state)
|
||||
mem.running = false
|
||||
mem.delivered = 0
|
||||
power.secondary_stop(pos, mem)
|
||||
end
|
||||
|
||||
local State = techage.NodeStates:new({
|
||||
node_name_passive = "techage:ta3_akku",
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = 0,
|
||||
formspec_func = formspec,
|
||||
start_node = start_node,
|
||||
stop_node = stop_node,
|
||||
})
|
||||
|
||||
local function node_timer(pos, elapsed)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if mem.running then
|
||||
mem.delivered = power.secondary_alive(pos, mem, mem.capa, PWR_CAPA)
|
||||
mem.capa = mem.capa - mem.delivered
|
||||
mem.capa = in_range(mem.capa, 0, PWR_CAPA)
|
||||
end
|
||||
return mem.running
|
||||
end
|
||||
|
||||
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)
|
||||
State:state_button_event(pos, mem, fields)
|
||||
|
||||
if fields.update then
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||
end
|
||||
end
|
||||
|
||||
local function on_rightclick(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||
end
|
||||
|
||||
local function get_capa(itemstack)
|
||||
local meta = itemstack:get_meta()
|
||||
if meta then
|
||||
return in_range(meta:get_int("capa") * (PWR_CAPA/100), 0, 3000)
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
local function set_capa(pos, oldnode, digger, capa)
|
||||
local node = ItemStack(oldnode.name)
|
||||
local meta = node:get_meta()
|
||||
capa = techage.power.percent(PWR_CAPA, capa)
|
||||
capa = (math.floor((capa or 0) / 5)) * 5
|
||||
meta:set_int("capa", capa)
|
||||
local text = S("TA3 Akku Box").." ("..capa.." %)"
|
||||
meta:set_string("description", text)
|
||||
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
|
||||
local left_over = inv:add_item("main", node)
|
||||
if left_over:get_count() > 0 then
|
||||
minetest.add_item(pos, node)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("techage:ta3_akku", {
|
||||
description = S("TA3 Akku Box"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta3.png^techage_frame_ta3_top.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_hole_electric.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_source.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_source.png",
|
||||
"techage_filling_ta3.png^techage_frame_ta3.png^techage_appl_source.png",
|
||||
},
|
||||
|
||||
on_construct = tubelib2.init_mem,
|
||||
|
||||
after_place_node = function(pos, placer, itemstack)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State:node_init(pos, mem, "")
|
||||
mem.capa = get_capa(itemstack)
|
||||
on_rightclick(pos)
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
set_capa(pos, oldnode, digger, mem.capa)
|
||||
end,
|
||||
|
||||
on_receive_fields = on_receive_fields,
|
||||
on_rightclick = on_rightclick,
|
||||
on_timer = node_timer,
|
||||
|
||||
drop = "", -- don't remove, item will be added via 'set_capa'
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
on_rotate = screwdriver.disallow,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_wood_defaults(),
|
||||
})
|
||||
|
||||
techage.power.register_node({"techage:ta3_akku"}, {
|
||||
conn_sides = {"R"},
|
||||
power_network = Power,
|
||||
})
|
||||
|
||||
techage.register_entry_page("ta3ps", "akku",
|
||||
S("TA3 Akku Box"),
|
||||
S("Used to store electrical energy. Charged in about 10 min, provides energy for 10 min.@n"..
|
||||
"It take and deliver up to 10 units electrical power."),
|
||||
"techage:ta3_akku")
|
||||
|
||||
|
||||
minetest.register_craft({
|
||||
output = "techage:ta3_akku",
|
||||
recipe = {
|
||||
{"default:tin_ingot", "default:tin_ingot", "default:wood"},
|
||||
{"default:copper_ingot", "default:copper_ingot", "techage:electric_cableS"},
|
||||
{"techage:iron_ingot", "techage:iron_ingot", "default:wood"},
|
||||
},
|
||||
})
|
@ -8,7 +8,7 @@
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 Generator
|
||||
TA4 Dummy Generator for the TES
|
||||
|
||||
]]--
|
||||
|
||||
@ -16,88 +16,29 @@
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
|
||||
local STANDBY_TICKS = 4
|
||||
local COUNTDOWN_TICKS = 4
|
||||
local CYCLE_TIME = 2
|
||||
local PWR_CAPA = 80
|
||||
|
||||
local Cable = techage.ElectricCable
|
||||
local power = techage.power
|
||||
|
||||
local function formspec(self, pos, mem)
|
||||
return "size[8,7]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"image[6,0.5;1,2;"..power.formspec_power_bar(PWR_CAPA, mem.provided).."]"..
|
||||
"image_button[5,1;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
|
||||
"button[2,1.5;2,1;update;"..S("Update").."]"..
|
||||
"list[current_player;main;0,3;8,4;]"..
|
||||
default.get_hotbar_bg(0, 3)
|
||||
end
|
||||
|
||||
local function can_start(pos, mem, state)
|
||||
return (mem.firebox_trigger or 0) > 0 -- by means of firebox
|
||||
end
|
||||
|
||||
local function start_node(pos, mem, state)
|
||||
mem.generating = true -- needed for power distribution
|
||||
power.generator_start(pos, mem, PWR_CAPA)
|
||||
end
|
||||
|
||||
local function stop_node(pos, mem, state)
|
||||
mem.generating = false
|
||||
power.generator_stop(pos, mem)
|
||||
mem.provided = 0
|
||||
end
|
||||
|
||||
local State = techage.NodeStates:new({
|
||||
node_name_passive = "techage:generator",
|
||||
node_name_active = "techage:generator_on",
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = STANDBY_TICKS,
|
||||
formspec_func = formspec,
|
||||
infotext_name = S("TA3 Generator"),
|
||||
can_start = can_start,
|
||||
start_node = start_node,
|
||||
stop_node = stop_node,
|
||||
})
|
||||
|
||||
local function node_timer(pos, elapsed)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if mem.generating then
|
||||
mem.firebox_trigger = (mem.firebox_trigger or 0) - 1
|
||||
if mem.firebox_trigger <= 0 then
|
||||
State:nopower(pos, mem)
|
||||
mem.generating = false
|
||||
power.generator_stop(pos, mem)
|
||||
mem.provided = 0
|
||||
else
|
||||
mem.provided = power.generator_alive(pos, mem)
|
||||
State:keep_running(pos, mem, COUNTDOWN_TICKS)
|
||||
end
|
||||
end
|
||||
return State:is_active(mem)
|
||||
end
|
||||
|
||||
local function on_receive_fields(pos, formname, fields, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
local function swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State:state_button_event(pos, mem, fields)
|
||||
|
||||
if fields.update then
|
||||
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||
end
|
||||
node.name = name
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function on_rightclick(pos)
|
||||
-- to detect the missing turbine
|
||||
local function node_timer(pos, elapsed)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||
if mem.generating then
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
mem.remote_trigger = (mem.remote_trigger or 0) - 1
|
||||
if mem.remote_trigger <= 0 then
|
||||
swap_node(pos, "techage:ta4_generator")
|
||||
mem.running = false
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
minetest.register_node("techage:ta4_generator", {
|
||||
@ -112,20 +53,13 @@ minetest.register_node("techage:ta4_generator", {
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_generator.png^[transformFX]",
|
||||
},
|
||||
|
||||
on_construct = tubelib2.init_mem,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local number = techage.add_node(pos, "techage:generator")
|
||||
State:node_init(pos, mem, number)
|
||||
on_rightclick(pos)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
mem.running = false
|
||||
mem.remote_trigger = 0
|
||||
end,
|
||||
|
||||
on_receive_fields = on_receive_fields,
|
||||
on_rightclick = on_rightclick,
|
||||
on_timer = node_timer,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
on_rotate = screwdriver.disallow,
|
||||
@ -163,10 +97,11 @@ minetest.register_node("techage:ta4_generator_on", {
|
||||
},
|
||||
},
|
||||
|
||||
on_receive_fields = on_receive_fields,
|
||||
on_rightclick = on_rightclick,
|
||||
on_rightclick = function(pos)
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
end,
|
||||
|
||||
on_timer = node_timer,
|
||||
|
||||
drop = "",
|
||||
paramtype2 = "facedir",
|
||||
groups = {not_in_creative_inventory=1},
|
||||
@ -179,50 +114,46 @@ minetest.register_node("techage:ta4_generator_on", {
|
||||
minetest.register_craft({
|
||||
output = "techage:ta4_generator",
|
||||
recipe = {
|
||||
{"basic_materials:steel_bar", "dye:green", "default:wood"},
|
||||
{"", "basic_materials:gear_steel", "techage:electric_cableS"},
|
||||
{"default:wood", "techage:iron_ingot", "basic_materials:steel_bar"},
|
||||
{"", "dye:blue", ""},
|
||||
{"", "techage:generator", ""},
|
||||
{"", "techage:ta4_wlanchip", ""},
|
||||
},
|
||||
})
|
||||
|
||||
-- need a dummy power connection
|
||||
techage.power.register_node({"techage:ta4_generator", "techage:ta4_generator_on"}, {
|
||||
conn_sides = {"R"},
|
||||
power_network = Cable,
|
||||
})
|
||||
|
||||
-- for logical communication
|
||||
-- controlled by the turbine
|
||||
techage.register_node({"techage:ta4_generator", "techage:ta4_generator_on"}, {
|
||||
on_transfer = function(pos, in_dir, topic, payload)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if topic == "power_level" then
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.power_level = payload
|
||||
if topic == "power" then
|
||||
mem.remote_trigger = 2
|
||||
return techage.power.power_available(pos, mem, 0)
|
||||
elseif topic == "start" then
|
||||
mem.remote_trigger = 2
|
||||
swap_node(pos, "techage:ta4_generator_on")
|
||||
mem.running = true
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
return true
|
||||
elseif topic == "stop" then
|
||||
swap_node(pos, "techage:ta4_generator")
|
||||
mem.running = false
|
||||
mem.remote_trigger = 0
|
||||
minetest.get_node_timer(pos):stop()
|
||||
return true
|
||||
elseif topic == "trigger" then
|
||||
mem.firebox_trigger = 3
|
||||
mem.power_level = payload
|
||||
if mem.generating then
|
||||
return math.max((mem.provided or PWR_CAPA) / PWR_CAPA, 0.02)
|
||||
else
|
||||
return 0
|
||||
end
|
||||
mem.remote_trigger = 2
|
||||
return true
|
||||
end
|
||||
end,
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if topic == "load" then
|
||||
return techage.power.percent(PWR_CAPA, mem.provided)
|
||||
else
|
||||
return State:on_receive_message(pos, topic, payload)
|
||||
end
|
||||
end,
|
||||
on_node_load = function(pos)
|
||||
State:on_node_load(pos)
|
||||
end,
|
||||
})
|
||||
|
||||
techage.register_entry_page("ta4es", "ta4_generator",
|
||||
S("TA3 Generator"),
|
||||
S("Part of the Power Station. Has to be placed side by side with the TA3 Turbine. "..
|
||||
"Connect the Generator with your TA3 machines by means of Electric Cables and Junction Boxes@n"..
|
||||
"(see TA3 Power Station)"),
|
||||
"techage:generator")
|
||||
S("TA4 Generator"),
|
||||
S("Part of TA4 Energy Systems. Has to be placed side by side with the TA4 Turbine. "..
|
||||
"Connect the Generator with your power network@n"),
|
||||
"techage:ta4_generator")
|
||||
|
@ -13,208 +13,189 @@
|
||||
]]--
|
||||
|
||||
-- for lazy programmers
|
||||
local P = minetest.string_to_pos
|
||||
local S2P = minetest.string_to_pos
|
||||
local P2S = minetest.pos_to_string
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
|
||||
local CYCLE_TIME = 4
|
||||
local STANDBY_TICKS = 2
|
||||
local COUNTDOWN_TICKS = 2
|
||||
local HEAT_STEP = 10
|
||||
local WATER_CONSUMPTION = 0.5
|
||||
local MAX_WATER = 10
|
||||
|
||||
local Pipe = techage.BiogasPipe
|
||||
|
||||
local Water = {
|
||||
["bucket:bucket_river_water"] = true,
|
||||
["bucket:bucket_water"] = true,
|
||||
["bucket:bucket_empty"] = true,
|
||||
local CYCLE_TIME = 2
|
||||
local PWR_PERF = 60
|
||||
local GRVL_CAPA = 1333
|
||||
local PWR_CAPA = {
|
||||
[3] = GRVL_CAPA * 3 * 3 * 3, -- ~0.5 days
|
||||
[4] = GRVL_CAPA * 5 * 5 * 5, -- ~2.5 days
|
||||
[5] = GRVL_CAPA * 7 * 7 * 7, -- ~6 days
|
||||
}
|
||||
|
||||
local Cable = techage.ElectricCable
|
||||
local Pipe = techage.BiogasPipe
|
||||
local power = techage.power
|
||||
|
||||
local function in_range(val, min, max)
|
||||
if val < min then return min end
|
||||
if val > max then return max end
|
||||
return val
|
||||
end
|
||||
|
||||
-- commands for 'techage:heatexchanger1'
|
||||
local function turbine_cmnd(pos, cmnd)
|
||||
return techage.transfer(
|
||||
pos,
|
||||
"R", -- outdir
|
||||
cmnd, -- topic
|
||||
nil, -- payload
|
||||
Pipe, -- Pipe
|
||||
{"techage:ta4_turbine", "techage:ta4_turbine_on"})
|
||||
end
|
||||
|
||||
local function heatexchanger3_cmnd(pos, cmnd)
|
||||
return techage.transfer(
|
||||
{x = pos.x, y = pos.y + 1, z = pos.z},
|
||||
"U", -- outdir
|
||||
cmnd, -- topic
|
||||
nil, -- payload
|
||||
nil, -- Pipe
|
||||
{"techage:heatexchanger3"})
|
||||
end
|
||||
|
||||
local function inlet_cmnd(pos, cmnd, payload)
|
||||
return techage.transfer(
|
||||
pos,
|
||||
"L", -- outdir
|
||||
cmnd, -- topic
|
||||
payload, -- payload
|
||||
Pipe, -- Pipe
|
||||
{"techage:ta4_pipe_inlet"})
|
||||
end
|
||||
|
||||
local function play_sound(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if mem.running then
|
||||
mem.handle = minetest.sound_play("techage_booster", {
|
||||
pos = pos,
|
||||
gain = 0.5,
|
||||
max_hear_distance = 10})
|
||||
end
|
||||
end
|
||||
|
||||
local function stop_sound(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if mem.running and mem.handle then
|
||||
minetest.sound_stop(mem.handle)
|
||||
mem.handle = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == name then
|
||||
return
|
||||
end
|
||||
node.name = name
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function charging(pos, mem, is_charging)
|
||||
if mem.capa >= mem.capa_max then
|
||||
return
|
||||
end
|
||||
if is_charging ~= mem.was_charging then
|
||||
mem.was_charging = is_charging
|
||||
if is_charging then
|
||||
turbine_cmnd(pos, "stop")
|
||||
play_sound(pos)
|
||||
else
|
||||
turbine_cmnd(pos, "start")
|
||||
stop_sound(pos)
|
||||
end
|
||||
elseif is_charging then
|
||||
play_sound(pos)
|
||||
end
|
||||
end
|
||||
|
||||
local function glowing(pos, mem, should_glow)
|
||||
print("glowing", P2S(mem.win_pos), should_glow)
|
||||
if mem.win_pos then
|
||||
if should_glow then
|
||||
swap_node(mem.win_pos, "techage:glow_gravel")
|
||||
else
|
||||
swap_node(mem.win_pos, "default:gravel")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function formspec(self, pos, mem)
|
||||
local temp = mem.temperature or 20
|
||||
local ratio = mem.power_ratio or 0
|
||||
return "size[8,7]"..
|
||||
return "size[5,3]"..
|
||||
default.gui_bg..
|
||||
default.gui_bg_img..
|
||||
default.gui_slots..
|
||||
"image_button[0,0.2;1,1;techage_form_inventory.png;storage;;true;false;]"..
|
||||
"list[context;water;1,0.2;1,1;]"..
|
||||
"image_button[0,1.6;1,1;techage_form_input.png;input;;true;false;]"..
|
||||
"list[context;input;1,1.6;1,1;]"..
|
||||
"image[1,1.6;1,1;bucket_water.png]"..
|
||||
"image[1,1.6;1,1;techage_form_mask.png]"..
|
||||
"image[2,0.5;1,2;techage_form_temp_bg.png^[lowpart:"..
|
||||
temp..":techage_form_temp_fg.png]"..
|
||||
"image[7,0.5;1,2;"..techage.power.formspec_power_bar(1, ratio).."]"..
|
||||
"image_button[6,1;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
|
||||
"button[3,1.5;2,1;update;"..S("Update").."]"..
|
||||
"list[current_player;main;0,3;8,4;]"..
|
||||
"listring[current_name;water]"..
|
||||
"listring[current_player;main]"..
|
||||
default.get_hotbar_bg(0, 3)
|
||||
"image[0,0.5;1,2;"..techage.power.formspec_power_bar(mem.capa_max, mem.capa).."]"..
|
||||
"label[0.2,2.5;Load]"..
|
||||
"button[1.1,1;1.8,1;update;"..S("Update").."]"..
|
||||
"image_button[3,1;1,1;".. self:get_state_button_image(mem) ..";state_button;]"..
|
||||
"image[4,0.5;1,2;"..techage.power.formspec_load_bar(-(mem.delivered or 0), PWR_PERF).."]"..
|
||||
"label[4.2,2.5;Flow]"
|
||||
end
|
||||
|
||||
local function can_start(pos, mem, state)
|
||||
return mem.temperature and mem.temperature > 80
|
||||
print("can_start")
|
||||
if turbine_cmnd(pos, "power") then
|
||||
local radius = inlet_cmnd(pos, "radius")
|
||||
print("radius = "..radius)
|
||||
if radius then
|
||||
mem.capa_max = PWR_CAPA[tonumber(radius)] or 0
|
||||
local owner = M(pos):get_string("owner") or ""
|
||||
return inlet_cmnd(pos, "volume", owner)
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function start_node(pos, mem, state)
|
||||
print("start_node", P2S(pos))
|
||||
mem.running = true
|
||||
mem.power_ratio = 0
|
||||
mem.delivered = 0
|
||||
mem.was_charging = true
|
||||
play_sound(pos)
|
||||
mem.win_pos = inlet_cmnd(pos, "window")
|
||||
power.secondary_start(pos, mem, PWR_PERF, PWR_PERF)
|
||||
end
|
||||
|
||||
local function stop_node(pos, mem, state)
|
||||
mem.running = false
|
||||
mem.power_ratio = 0
|
||||
end
|
||||
|
||||
-- check the positions above
|
||||
local function no_space(pos)
|
||||
local node1 = minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||
local node2 = minetest.get_node({x=pos.x, y=pos.y+2, z=pos.z})
|
||||
return node1.name ~= "air" or node2.name ~= "air"
|
||||
mem.delivered = 0
|
||||
turbine_cmnd(pos, "stop")
|
||||
power.secondary_stop(pos, mem)
|
||||
end
|
||||
|
||||
local State = techage.NodeStates:new({
|
||||
node_name_passive = "techage:boiler2",
|
||||
node_name_passive = "techage:heatexchanger1",
|
||||
cycle_time = CYCLE_TIME,
|
||||
standby_ticks = STANDBY_TICKS,
|
||||
has_item_meter = false,
|
||||
formspec_func = formspec,
|
||||
standby_ticks = 0,
|
||||
can_start = can_start,
|
||||
start_node = start_node,
|
||||
stop_node = stop_node,
|
||||
})
|
||||
|
||||
local function get_water(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
local items = inv:get_stack("water", 1)
|
||||
if items:get_count() > 0 then
|
||||
local taken = items:take_item(1)
|
||||
inv:set_stack("water", 1, items)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function water_temperature(pos, mem)
|
||||
mem.temperature = mem.temperature or 20
|
||||
if mem.fire_trigger then
|
||||
mem.temperature = math.min(mem.temperature + HEAT_STEP, 100)
|
||||
else
|
||||
mem.temperature = math.max(mem.temperature - HEAT_STEP, 20)
|
||||
end
|
||||
mem.fire_trigger = false
|
||||
|
||||
if mem.water_level == 0 then
|
||||
if get_water(pos) then
|
||||
mem.water_level = 100
|
||||
else
|
||||
mem.temperature = 20
|
||||
end
|
||||
end
|
||||
return mem.temperature
|
||||
end
|
||||
|
||||
local function steaming(pos, mem, temp)
|
||||
local wc = WATER_CONSUMPTION * (mem.power_ratio or 1)
|
||||
mem.water_level = math.max((mem.water_level or 0) - wc, 0)
|
||||
if temp >= 80 then
|
||||
if mem.running then
|
||||
State:keep_running(pos, mem, COUNTDOWN_TICKS)
|
||||
else
|
||||
State:fault(pos, mem)
|
||||
end
|
||||
else
|
||||
State:stop(pos, mem)
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
end
|
||||
end
|
||||
|
||||
local function node_timer(pos, elapsed)
|
||||
print("node_timer1")
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local temp = water_temperature(pos, mem)
|
||||
if State:is_active(mem) then
|
||||
steaming(pos, mem, temp)
|
||||
if mem.running and turbine_cmnd(pos, "power") then
|
||||
mem.capa = mem.capa or 0
|
||||
mem.capa_max = mem.capa_max or 0
|
||||
mem.delivered = mem.delivered or 0
|
||||
mem.delivered = power.secondary_alive(pos, mem, mem.capa, mem.capa_max)
|
||||
mem.capa = mem.capa - mem.delivered
|
||||
mem.capa = in_range(mem.capa, 0, mem.capa_max)
|
||||
glowing(pos, mem, mem.capa > mem.capa_max * 0.8)
|
||||
charging(pos, mem, mem.delivered < 0)
|
||||
end
|
||||
return mem.temperature > 20
|
||||
end
|
||||
|
||||
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)
|
||||
mem.temperature = mem.temperature or 20
|
||||
State:state_button_event(pos, mem, fields)
|
||||
|
||||
if fields.update then
|
||||
if mem.temperature > 20 then
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
end
|
||||
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function on_rightclick(pos)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
M(pos):set_string("formspec", formspec(State, pos, mem))
|
||||
return mem.running
|
||||
end
|
||||
|
||||
local function can_dig(pos, player)
|
||||
local inv = M(pos):get_inventory()
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
return inv:is_empty("input") and not mem.running
|
||||
end
|
||||
|
||||
local function move_to_water(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
local water_stack = inv:get_stack("water", 1)
|
||||
local input_stack = inv:get_stack("input", 1)
|
||||
|
||||
if input_stack:get_name() == "bucket:bucket_empty" then
|
||||
if input_stack:get_count() == 1 then
|
||||
if water_stack:get_count() > 0 then
|
||||
water_stack:set_count(water_stack:get_count() - 1)
|
||||
input_stack = ItemStack("bucket:bucket_water")
|
||||
inv:set_stack("water", 1, water_stack)
|
||||
inv:set_stack("input", 1, input_stack)
|
||||
end
|
||||
end
|
||||
elseif water_stack:get_count() < MAX_WATER then
|
||||
if water_stack:get_count() == 0 then
|
||||
water_stack = ItemStack("default:water_source")
|
||||
else
|
||||
water_stack:set_count(water_stack:get_count() + 1)
|
||||
end
|
||||
input_stack = ItemStack("bucket:bucket_empty")
|
||||
inv:set_stack("water", 1, water_stack)
|
||||
inv:set_stack("input", 1, input_stack)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
if listname == "input" and Water[stack:get_name()] then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
local function allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return 0
|
||||
end
|
||||
if listname == "input" then
|
||||
return stack:get_count()
|
||||
end
|
||||
return 0
|
||||
return not mem.running
|
||||
end
|
||||
|
||||
local function orientate_node(pos, name)
|
||||
@ -242,73 +223,10 @@ minetest.register_node("techage:heatexchanger3", {
|
||||
"techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_ribsT.png",
|
||||
"techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_ribsT.png",
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
return orientate_node(pos, "techage:heatexchanger2")
|
||||
end,
|
||||
paramtype2 = "facedir",
|
||||
groups = {crumbly = 2, cracky = 2, snappy = 2},
|
||||
--on_rotate = screwdriver.disallow,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
-- Middle
|
||||
minetest.register_node("techage:heatexchanger2", {
|
||||
description = S("TA4 Heat Exchanger 2"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_hole_ta4.png",
|
||||
"techage_hole_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_tes_turb.png",
|
||||
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_tes_core.png",
|
||||
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_ribsM.png",
|
||||
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_ribsM.png",
|
||||
},
|
||||
after_place_node = function(pos, placer)
|
||||
return orientate_node(pos, "techage:heatexchanger1")
|
||||
end,
|
||||
paramtype2 = "facedir",
|
||||
groups = {crumbly = 2, cracky = 2, snappy = 2},
|
||||
--on_rotate = screwdriver.disallow,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:heatexchanger1", {
|
||||
description = S("TA4 Heat Exchanger 1"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_hole_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_biogas.png",
|
||||
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_biogas.png",
|
||||
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_ribsB.png",
|
||||
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_ribsB.png",
|
||||
},
|
||||
|
||||
on_construct = function(pos)
|
||||
tubelib2.init_mem(pos)
|
||||
local inv = M(pos):get_inventory()
|
||||
inv:set_size('water', 1)
|
||||
inv:set_size('input', 1)
|
||||
end,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
if no_space(pos) then
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
State:node_init(pos, mem, "")
|
||||
local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
||||
if node.name == "techage:boiler1" then
|
||||
on_rightclick(pos)
|
||||
end
|
||||
end,
|
||||
|
||||
after_dig_node = function(pos)
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {crumbly = 2, cracky = 2, snappy = 2},
|
||||
@ -317,99 +235,137 @@ minetest.register_node("techage:heatexchanger1", {
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
techage.power.register_node({"techage:heatexchanger1", "techage:heatexchanger3"}, {
|
||||
conn_sides = {"R", "L"},
|
||||
power_network = Pipe,
|
||||
-- Middle node with the formspec from the bottom node
|
||||
minetest.register_node("techage:heatexchanger2", {
|
||||
description = S("TA4 Heat Exchanger 2"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_hole_ta4.png",
|
||||
"techage_hole_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_tes_turb.png",
|
||||
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_tes_core.png",
|
||||
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_ribsB.png",
|
||||
"techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_ribsB.png",
|
||||
},
|
||||
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {-1/2, -1.5/2, -1/2, 1/2, 1/2, 1/2},
|
||||
},
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
if orientate_node(pos, "techage:heatexchanger1") then
|
||||
return true
|
||||
end
|
||||
local pos1 = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
local mem = tubelib2.get_mem(pos1)
|
||||
local own_num = M(pos1):get_string("node_number")
|
||||
M(pos):set_string("formspec", formspec(State, pos1, mem))
|
||||
M(pos):set_string("infotext", S("TA4 Heat Exchanger").." "..own_num)
|
||||
end,
|
||||
|
||||
on_rightclick = function(pos)
|
||||
local pos1 = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
local mem = tubelib2.get_mem(pos1)
|
||||
M(pos):set_string("formspec", formspec(State, pos1, mem))
|
||||
end,
|
||||
|
||||
on_receive_fields = function(pos, formname, fields, player)
|
||||
if minetest.is_protected(pos, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local pos1 = {x = pos.x, y = pos.y - 1, z = pos.z}
|
||||
local mem = tubelib2.get_mem(pos1)
|
||||
State:state_button_event(pos1, mem, fields)
|
||||
M(pos):set_string("formspec", formspec(State, pos1, mem))
|
||||
end,
|
||||
|
||||
paramtype2 = "facedir",
|
||||
groups = {crumbly = 2, cracky = 2, snappy = 2},
|
||||
on_rotate = screwdriver.disallow,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
-- Base
|
||||
minetest.register_node("techage:heatexchanger1", {
|
||||
description = S("TA4 Heat Exchanger 1"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_hole_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_biogas.png",
|
||||
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_biogas.png",
|
||||
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_electric.png",
|
||||
"techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_electric.png",
|
||||
},
|
||||
|
||||
on_construct = tubelib2.init_mem,
|
||||
|
||||
after_place_node = function(pos, placer)
|
||||
-- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
local meta = M(pos)
|
||||
local own_num = techage.add_node(pos, "techage:heatexchanger1")
|
||||
meta:set_string("owner", placer:get_player_name())
|
||||
State:node_init(pos, mem, own_num)
|
||||
mem.capa = 0
|
||||
end,
|
||||
|
||||
on_timer = node_timer,
|
||||
paramtype2 = "facedir",
|
||||
groups = {crumbly = 2, cracky = 2, snappy = 2},
|
||||
on_rotate = screwdriver.disallow,
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
techage.power.register_node({"techage:heatexchanger1"}, {
|
||||
conn_sides = {"F", "B"},
|
||||
power_network = Cable,
|
||||
})
|
||||
|
||||
Cable:add_secondary_node_names({"techage:heatexchanger1", "techage:heatexchanger3"})
|
||||
|
||||
-- for logical communication
|
||||
techage.register_node({"techage:heatexchanger1"}, {
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if topic == "capa" then
|
||||
return mem.capa or 0
|
||||
else
|
||||
return State:on_receive_message(pos, topic, payload)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
|
||||
-- boiler2: Main part, needed as generator
|
||||
--minetest.register_node("techage:heatexchanger3", {
|
||||
-- description = S("TA4 Heat Exchanger"),
|
||||
-- tiles = {"techage_boiler2.png"},
|
||||
-- drawtype = "mesh",
|
||||
-- mesh = "techage_boiler.obj",
|
||||
-- selection_box = {
|
||||
-- type = "fixed",
|
||||
-- fixed = {-10/32, -48/32, -10/32, 10/32, 16/32, 10/32},
|
||||
-- },
|
||||
|
||||
-- can_dig = can_dig,
|
||||
-- on_timer = node_timer,
|
||||
-- allow_metadata_inventory_put = allow_metadata_inventory_put,
|
||||
-- allow_metadata_inventory_take = allow_metadata_inventory_take,
|
||||
-- allow_metadata_inventory_move = function(pos) return 0 end,
|
||||
-- on_receive_fields = on_receive_fields,
|
||||
-- on_rightclick = on_rightclick,
|
||||
|
||||
-- on_construct = function(pos)
|
||||
-- tubelib2.init_mem(pos)
|
||||
-- local inv = M(pos):get_inventory()
|
||||
-- inv:set_size('water', 1)
|
||||
-- inv:set_size('input', 1)
|
||||
-- end,
|
||||
|
||||
-- after_place_node = function(pos, placer)
|
||||
-- -- secondary 'after_place_node', called by power. Don't use tubelib2.init_mem(pos)!!!
|
||||
-- local mem = tubelib2.get_mem(pos)
|
||||
-- State:node_init(pos, mem, "")
|
||||
-- local node = minetest.get_node({x=pos.x, y=pos.y-1, z=pos.z})
|
||||
-- if node.name == "techage:boiler1" then
|
||||
-- on_rightclick(pos)
|
||||
-- end
|
||||
-- end,
|
||||
|
||||
-- on_metadata_inventory_put = function(pos)
|
||||
-- minetest.after(0.5, move_to_water, pos)
|
||||
-- end,
|
||||
|
||||
-- groups = {cracky=1},
|
||||
-- on_rotate = screwdriver.disallow,
|
||||
-- is_ground_content = false,
|
||||
-- sounds = default.node_sound_metal_defaults(),
|
||||
--})
|
||||
minetest.register_craft({
|
||||
output = "techage:heatexchanger1",
|
||||
recipe = {
|
||||
{"default:tin_ingot", "techage:electric_cableS", "default:steel_ingot"},
|
||||
{"techage:ta4_pipeS", "basic_materials:gear_steel", "techage:ta4_pipeS"},
|
||||
{"", "techage:baborium_ingot", ""},
|
||||
},
|
||||
})
|
||||
|
||||
--techage.power.register_node({"techage:boiler2"}, {
|
||||
-- conn_sides = {"U"},
|
||||
-- power_network = Pipe,
|
||||
--})
|
||||
minetest.register_craft({
|
||||
output = "techage:heatexchanger2",
|
||||
recipe = {
|
||||
{"default:tin_ingot", "", "default:steel_ingot"},
|
||||
{"", "techage:ta4_wlanchip", ""},
|
||||
{"", "techage:baborium_ingot", ""},
|
||||
},
|
||||
})
|
||||
|
||||
--techage.register_node({"techage:boiler2"}, {
|
||||
-- on_transfer = function(pos, in_dir, topic, payload)
|
||||
-- if topic == "trigger" then
|
||||
-- local mem = tubelib2.get_mem(pos)
|
||||
-- mem.fire_trigger = true
|
||||
-- if not minetest.get_node_timer(pos):is_started() then
|
||||
-- minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
-- end
|
||||
-- if mem.running then
|
||||
-- mem.power_ratio = techage.transfer(pos, 6, "trigger", nil, Pipe, {
|
||||
-- "techage:cylinder", "techage:cylinder_on"}) or 0
|
||||
-- return mem.power_ratio
|
||||
-- else
|
||||
-- return 0
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
--})
|
||||
|
||||
--minetest.register_craft({
|
||||
-- output = "techage:boiler1",
|
||||
-- recipe = {
|
||||
-- {"techage:iron_ingot", "", "techage:iron_ingot"},
|
||||
-- {"default:bronze_ingot", "", "default:bronze_ingot"},
|
||||
-- {"techage:iron_ingot", "default:bronze_ingot", "techage:iron_ingot"},
|
||||
-- },
|
||||
--})
|
||||
|
||||
--minetest.register_craft({
|
||||
-- output = "techage:boiler2",
|
||||
-- recipe = {
|
||||
-- {"techage:iron_ingot", "techage:steam_pipeS", "techage:iron_ingot"},
|
||||
-- {"default:bronze_ingot", "", "default:bronze_ingot"},
|
||||
-- {"techage:iron_ingot", "", "techage:iron_ingot"},
|
||||
-- },
|
||||
--})
|
||||
minetest.register_craft({
|
||||
output = "techage:heatexchanger3",
|
||||
recipe = {
|
||||
{"default:tin_ingot", "dye:blue", "default:steel_ingot"},
|
||||
{"techage:ta4_pipeS", "basic_materials:gear_steel", "techage:ta4_pipeS"},
|
||||
{"", "techage:baborium_ingot", ""},
|
||||
},
|
||||
})
|
||||
|
||||
--techage.register_entry_page("ta2", "boiler1",
|
||||
-- S("TA2 Boiler Base"),
|
||||
|
@ -22,27 +22,23 @@ local PN090 = "techage_gaspipe_knee.png^[transformR90"
|
||||
local PN180 = "techage_gaspipe_knee.png^[transformR180"
|
||||
local PN270 = "techage_gaspipe_knee.png^[transformR270"
|
||||
local HEXR1 = "techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_ribsT.png"
|
||||
local HEXR2 = "techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_ribsM.png"
|
||||
local HEXR3 = "techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_ribsB.png"
|
||||
local HEXR2 = "techage_filling_ta4.png^techage_frameM_ta4.png^techage_appl_ribsB.png"
|
||||
local HEXR3 = "techage_filling_ta4.png^techage_frameB_ta4.png^techage_appl_hole_electric.png"
|
||||
local TURBN = "techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta4.png"
|
||||
local GENER = "techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_generator.png^[transformFX]"
|
||||
local GRAVL = "default_gravel.png"
|
||||
local FAN = "techage_filling_ta4.png^techage_appl_compressor.png^techage_frame_ta4.png"
|
||||
local COREE = "techage_tes_core_elem.png"
|
||||
local INLET = "techage_tes_inlet_help.png"
|
||||
local CPI00 = "basic_materials_concrete_block.png^techage_gaspipe.png"
|
||||
local CPI90 = "basic_materials_concrete_block.png^techage_gaspipe.png^[transformR90"
|
||||
local INLET = "basic_materials_concrete_block.png^techage_gaspipe.png^[transformR90"
|
||||
local GLASS = "default_obsidian_glass.png"
|
||||
|
||||
local Images = {
|
||||
{false, false, false, false, false, false, false, false, false, false, false, false},
|
||||
{CONCR, CONCR, CONCR, CONCR, CONCR, CONCR, CONCR, false, false, false, false, false},
|
||||
{CONCR, GRAVL, GRAVL, GRAVL, GRAVL, GRAVL, CONCR, false, false, false, false, false},
|
||||
{CONCR, GRAVL, GRAVL, PN000, PIPEH, PIPEH, CPI00, PIPEH, HEXR1, PIPEH, PN270, false},
|
||||
{CONCR, GRAVL, GRAVL, COREE, GRAVL, GRAVL, CONCR, false, HEXR2, false, PIPEV, false},
|
||||
{CONCR, GRAVL, GRAVL, PN090, PIPEH, PIPEH, CPI00, PIPEH, HEXR3, PIPEH, TURBN, GENER},
|
||||
{CONCR, GRAVL, GRAVL, INLET, GRAVL, GRAVL, CONCR, false, false, false, false, false},
|
||||
{CONCR, CONCR, CONCR, CPI90, CONCR, CONCR, CONCR, false, PN000, FAN, false, false},
|
||||
{false, false, false, PN090, PIPEH, PIPEH, PIPEH, PIPEH, PN180, false, false, false},
|
||||
{false, false, false, false, false, false, false, false, false, false, false},
|
||||
{false, false, false, PN000, PIPEH, PIPEH, PN270, false, false, false, false},
|
||||
{false, CONCR, CONCR, INLET, CONCR, CONCR, PIPEV, false, false, false, false},
|
||||
{false, CONCR, GRAVL, GRAVL, GRAVL, CONCR, PN090, HEXR1, PIPEH, PN270, false},
|
||||
{false, GLASS, GRAVL, GRAVL, GRAVL, CONCR, false, HEXR2, false, PIPEV, false},
|
||||
{false, CONCR, GRAVL, GRAVL, GRAVL, CONCR, PN000, HEXR3, PIPEH, TURBN, GENER},
|
||||
{false, CONCR, CONCR, INLET, CONCR, CONCR, PIPEV, false, false, false, false},
|
||||
{false, false, false, PN090, PIPEH, PIPEH, PN180, false, false, false, false},
|
||||
}
|
||||
|
||||
techage.register_category_page("ta4es",
|
||||
|
@ -106,6 +106,25 @@ local function check_volume(pos, in_dir, owner)
|
||||
return true
|
||||
end
|
||||
|
||||
-- provide position behind the obsidian_glass
|
||||
local function check_window(pos, in_dir)
|
||||
local radius = get_radius(pos, in_dir)
|
||||
if radius then
|
||||
local dir = tubelib2.Dir6dToVector[in_dir]
|
||||
local cpos = vector.add(pos, vector.multiply(dir, radius))
|
||||
-- calculate size
|
||||
local pos1 = {x = cpos.x - radius, y = cpos.y - radius, z = cpos.z - radius}
|
||||
local pos2 = {x = cpos.x + radius, y = cpos.y + radius, z = cpos.z + radius}
|
||||
local poses,_ = minetest.find_nodes_in_area(pos1, pos2, {"default:obsidian_glass"})
|
||||
if #poses == 1 then
|
||||
local ndir = vector.direction(poses[1], cpos)
|
||||
ndir = vector.normalize(ndir)
|
||||
local npos = vector.add(poses[1], ndir)
|
||||
return npos
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- for logical communication
|
||||
techage.register_node({"techage:ta4_pipe_inlet"}, {
|
||||
on_transfer = function(pos, in_dir, topic, payload)
|
||||
@ -113,6 +132,8 @@ techage.register_node({"techage:ta4_pipe_inlet"}, {
|
||||
return get_radius(pos, in_dir)
|
||||
elseif topic == "volume" then
|
||||
return check_volume(pos, in_dir, payload)
|
||||
elseif topic == "window" then
|
||||
return check_window(pos, in_dir)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
@ -8,7 +8,7 @@
|
||||
GPL v3
|
||||
See LICENSE.txt for more information
|
||||
|
||||
TA4 Heat Exchanger
|
||||
TA4 Nodes
|
||||
|
||||
]]--
|
||||
|
||||
@ -17,10 +17,8 @@ local P = minetest.string_to_pos
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
|
||||
local Pipe = techage.BiogasPipe
|
||||
|
||||
minetest.register_node("techage:glow_gravel", {
|
||||
description = "Techage Gravel",
|
||||
description = S("Techage Gravel"),
|
||||
tiles = {{
|
||||
name = "techage_gravel4.png",
|
||||
animation = {
|
||||
@ -37,16 +35,3 @@ minetest.register_node("techage:glow_gravel", {
|
||||
drop = "",
|
||||
})
|
||||
|
||||
minetest.register_node("techage:ta4_tes_coreelem", {
|
||||
description = S("TA4 TES Core Element"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_tes_core_elem_top.png",
|
||||
"techage_tes_core_elem_top.png",
|
||||
"techage_tes_core_elem.png",
|
||||
},
|
||||
groups = {crumbly = 2, cracky = 2, snappy = 2},
|
||||
is_ground_content = false,
|
||||
sounds = default.node_sound_metal_defaults(),
|
||||
})
|
||||
|
||||
|
@ -16,12 +16,9 @@
|
||||
local M = minetest.get_meta
|
||||
local S = techage.S
|
||||
|
||||
local Pipe = techage.SteamPipe
|
||||
local CYCLE_TIME = 2
|
||||
|
||||
local function transfer_generator(pos, topic, payload)
|
||||
return techage.transfer(pos, "R", topic, payload, nil,
|
||||
{"techage:ta4_generator", "techage:ta4_generator_on"})
|
||||
end
|
||||
local Pipe = techage.BiogasPipe
|
||||
|
||||
local function swap_node(pos, name)
|
||||
local node = minetest.get_node(pos)
|
||||
@ -37,9 +34,8 @@ local function play_sound(pos)
|
||||
if mem.running then
|
||||
mem.handle = minetest.sound_play("techage_turbine", {
|
||||
pos = pos,
|
||||
gain = 1,
|
||||
max_hear_distance = 15})
|
||||
minetest.after(2, play_sound, pos)
|
||||
gain = 0.5,
|
||||
max_hear_distance = 10})
|
||||
end
|
||||
end
|
||||
|
||||
@ -51,27 +47,48 @@ local function stop_sound(pos)
|
||||
end
|
||||
end
|
||||
|
||||
-- called with any pipe change
|
||||
local function after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
swap_node(pos, "techage:ta4_turbine")
|
||||
mem.running = false
|
||||
stop_sound(pos)
|
||||
local function generator_cmnd(pos, cmnd)
|
||||
return techage.transfer(
|
||||
pos,
|
||||
"R", -- outdir
|
||||
cmnd, -- topic
|
||||
nil, -- payload
|
||||
nil, -- network
|
||||
{"techage:ta4_generator", "techage:ta4_generator_on"})
|
||||
end
|
||||
|
||||
-- to detect the missing "steam pressure"
|
||||
local function node_timer(pos, elapsed)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
mem.remote_trigger = (mem.remote_trigger or 0) - 1
|
||||
if mem.remote_trigger <= 0 then
|
||||
swap_node(pos, "techage:ta4_turbine")
|
||||
stop_sound(pos)
|
||||
mem.running = false
|
||||
end
|
||||
play_sound(pos)
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
minetest.register_node("techage:ta4_turbine", {
|
||||
description = S("TA4 Turbine"),
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_steam_hole.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_biogas.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_steam_hole.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_biogas.png",
|
||||
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta4.png",
|
||||
},
|
||||
on_construct = tubelib2.init_mem,
|
||||
after_place_node = function(pos, placer)
|
||||
local mem = tubelib2.init_mem(pos)
|
||||
mem.running = false
|
||||
mem.remote_trigger = 0
|
||||
end,
|
||||
|
||||
on_timer = node_timer,
|
||||
paramtype2 = "facedir",
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
on_rotate = screwdriver.disallow,
|
||||
@ -82,10 +99,10 @@ minetest.register_node("techage:ta4_turbine", {
|
||||
minetest.register_node("techage:ta4_turbine_on", {
|
||||
tiles = {
|
||||
-- up, down, right, left, back, front
|
||||
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_steam_hole.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4_top.png^techage_appl_hole_biogas.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta4.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_steam_hole.png",
|
||||
"techage_filling_ta4.png^techage_frame_ta4.png^techage_appl_hole_biogas.png",
|
||||
{
|
||||
image = "techage_filling4_ta4.png^techage_appl_turbine4.png^techage_frame4_ta4.png",
|
||||
backface_culling = false,
|
||||
@ -107,8 +124,13 @@ minetest.register_node("techage:ta4_turbine_on", {
|
||||
},
|
||||
},
|
||||
},
|
||||
after_tube_update = after_tube_update,
|
||||
|
||||
on_rightclick = function(pos)
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
end,
|
||||
|
||||
on_timer = node_timer,
|
||||
drop = "",
|
||||
paramtype2 = "facedir",
|
||||
groups = {not_in_creative_inventory=1},
|
||||
diggable = false,
|
||||
@ -127,30 +149,26 @@ techage.power.register_node({"techage:ta4_turbine", "techage:ta4_turbine_on"}, {
|
||||
techage.register_node({"techage:ta4_turbine", "techage:ta4_turbine_on"}, {
|
||||
on_transfer = function(pos, in_dir, topic, payload)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
if topic == "trigger" then
|
||||
return transfer_generator(pos, topic, payload)
|
||||
if topic == "power" then
|
||||
mem.remote_trigger = 2
|
||||
return generator_cmnd(pos, topic)
|
||||
elseif topic == "start" then
|
||||
if transfer_cooler(pos, topic, payload) then
|
||||
swap_node(pos, "techage:ta4_turbine_on")
|
||||
mem.running = true
|
||||
play_sound(pos)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
elseif topic == "running" then
|
||||
if not transfer_cooler(pos, topic, payload) then
|
||||
swap_node(pos, "techage:ta4_turbine")
|
||||
mem.running = false
|
||||
stop_sound(pos)
|
||||
return false
|
||||
end
|
||||
return true
|
||||
mem.remote_trigger = 2
|
||||
swap_node(pos, "techage:ta4_turbine_on")
|
||||
mem.running = true
|
||||
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||
play_sound(pos)
|
||||
return generator_cmnd(pos, topic)
|
||||
elseif topic == "stop" then
|
||||
transfer_cooler(pos, topic, payload)
|
||||
swap_node(pos, "techage:ta4_turbine")
|
||||
mem.running = false
|
||||
mem.remote_trigger = 0
|
||||
minetest.get_node_timer(pos):stop()
|
||||
stop_sound(pos)
|
||||
return true
|
||||
return generator_cmnd(pos, topic)
|
||||
elseif topic == "trigger" then
|
||||
mem.remote_trigger = 2
|
||||
return generator_cmnd(pos, topic)
|
||||
end
|
||||
end
|
||||
})
|
||||
@ -158,24 +176,13 @@ techage.register_node({"techage:ta4_turbine", "techage:ta4_turbine_on"}, {
|
||||
minetest.register_craft({
|
||||
output = "techage:ta4_turbine",
|
||||
recipe = {
|
||||
{"basic_materials:steel_bar", "techage:steam_pipeS", "default:wood"},
|
||||
{"techage:steam_pipeS", "basic_materials:gear_steel", ""},
|
||||
{"default:wood", "techage:iron_ingot", "basic_materials:steel_bar"},
|
||||
{"", "dye:blue", ""},
|
||||
{"", "techage:turbine", ""},
|
||||
{"", "techage:ta4_wlanchip", ""},
|
||||
},
|
||||
})
|
||||
|
||||
techage.register_entry_page("ta4es", "turbine",
|
||||
S("TA3 Turbine"),
|
||||
S("Part of the Power Station. Has to be placed side by side with the TA3 Generator.@n"..
|
||||
"(see TA3 Power Station)"),
|
||||
S("TA4 Turbine"),
|
||||
S("Part of TA4 Energy Systems. Has to be placed side by side with the TA4 Generator.@n"),
|
||||
"techage:ta4_turbine")
|
||||
|
||||
minetest.register_lbm({
|
||||
label = "[techage] Turbine sound",
|
||||
name = "techage:power_station",
|
||||
nodenames = {"techage:ta4_turbine_on"},
|
||||
run_at_every_load = true,
|
||||
action = function(pos, node)
|
||||
play_sound(pos)
|
||||
end
|
||||
})
|
||||
|
12
init.lua
12
init.lua
@ -194,11 +194,11 @@ else
|
||||
dofile(MP.."/wind_turbine/signallamp.lua")
|
||||
|
||||
-- TA4 Energy Storage
|
||||
-- dofile(MP.."/energy_storage/heatexchanger.lua")
|
||||
-- dofile(MP.."/energy_storage/generator.lua")
|
||||
-- dofile(MP.."/energy_storage/turbine.lua")
|
||||
-- dofile(MP.."/energy_storage/inlet.lua")
|
||||
-- dofile(MP.."/energy_storage/nodes.lua")
|
||||
-- dofile(MP.."/energy_storage/help.lua")
|
||||
dofile(MP.."/energy_storage/heatexchanger.lua")
|
||||
dofile(MP.."/energy_storage/generator.lua")
|
||||
dofile(MP.."/energy_storage/turbine.lua")
|
||||
dofile(MP.."/energy_storage/inlet.lua")
|
||||
dofile(MP.."/energy_storage/nodes.lua")
|
||||
dofile(MP.."/energy_storage/help.lua")
|
||||
|
||||
end
|
@ -67,7 +67,7 @@ function techage.register_junction(name, size, boxes, network, node, index)
|
||||
ndef.paramtype = "light"
|
||||
ndef.sunlight_propagates = true
|
||||
ndef.is_ground_content = false
|
||||
ndef.drop = name.."0"
|
||||
ndef.drop = name..(index or "0")
|
||||
minetest.register_node(name..idx, ndef)
|
||||
-- Register in addition for power distribution
|
||||
techage.power.register_node({name..idx}, {power_network = network})
|
||||
|
@ -508,7 +508,8 @@ end
|
||||
|
||||
-- Power terminal function
|
||||
function techage.power.power_accounting(pos, mem)
|
||||
if mem.pwr_master_pos then
|
||||
if mem.pwr_master_pos and (mem.pwr_power_provided_cnt or 0) > 0 then
|
||||
mem.pwr_power_provided_cnt = (mem.pwr_power_provided_cnt or 0) - 1
|
||||
mem = tubelib2.get_mem(mem.pwr_master_pos)
|
||||
return {
|
||||
prim_available = mem.mst_available1 or 0,
|
||||
|
@ -163,8 +163,7 @@ minetest.register_node("techage:power_lineA", {
|
||||
})
|
||||
|
||||
minetest.register_node("techage:power_pole", {
|
||||
description = S("TA Power Pole Top 4"),
|
||||
--tiles = {"techage_power_pole.png"},
|
||||
description = S("TA Power Pole Top (for up to 6 connections)"),
|
||||
tiles = {
|
||||
"default_wood.png^techage_power_pole_top.png",
|
||||
"default_wood.png^techage_power_pole_top.png",
|
||||
@ -191,7 +190,43 @@ minetest.register_node("techage:power_pole", {
|
||||
minetest.remove_node(pos)
|
||||
return true
|
||||
end
|
||||
local node = minetest.get_node(pos)
|
||||
node.name = "techage:power_pole_conn"
|
||||
minetest.swap_node(pos, node)
|
||||
end,
|
||||
|
||||
on_rotate = screwdriver.disallow, -- important!
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
})
|
||||
|
||||
minetest.register_node("techage:power_pole_conn", {
|
||||
description = S("TA Power Pole Top 4 conn"),
|
||||
tiles = {
|
||||
"default_wood.png^techage_power_pole_top.png",
|
||||
"default_wood.png^techage_power_pole_top.png",
|
||||
"default_wood.png^techage_power_pole.png"
|
||||
},
|
||||
|
||||
paramtype2 = "facedir", -- important!
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "connected",
|
||||
fixed = {{ -4/32, -16/32, -4/32, 4/32, 16/32, 4/32}},
|
||||
|
||||
connect_left = {{-16/32, -6/32, -1/32, 1/32, -4/32, 1/32},
|
||||
{-16/32, -4/32, -2/32, -12/32, 4/32, 2/32}},
|
||||
connect_right = {{ -1/32, -6/32, -1/32, 16/32, -4/32, 1/32},
|
||||
{12/32, -4/32, -2/32, 16/32, 4/32, 2/32}},
|
||||
connect_back = {{-1/32, -6/32, -1/32, 1/32, -4/32, 16/32},
|
||||
{-2/32, -4/32, 12/32, 2/32, 4/32, 16/32}},
|
||||
connect_front = {{-1/32, -6/32, -16/32, 1/32, -4/32, 1/32},
|
||||
{-2/32, -4/32, -16/32, 2/32, 4/32, -12/32}},
|
||||
},
|
||||
connects_to = {"techage:power_line", "techage:power_lineS", "techage:power_lineA"},
|
||||
|
||||
can_dig = function(pos, digger)
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_string("owner") == digger:get_player_name() then
|
||||
@ -203,17 +238,17 @@ minetest.register_node("techage:power_pole", {
|
||||
return false
|
||||
end,
|
||||
|
||||
drop = "techage:power_pole",
|
||||
on_rotate = screwdriver.disallow, -- important!
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
is_ground_content = false,
|
||||
groups = {cracky=2, crumbly=2, choppy=2},
|
||||
groups = {cracky=2, crumbly=2, choppy=2, not_in_creative_inventory = 1},
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
minetest.register_node("techage:power_pole2", {
|
||||
description = S("TA Power Pole Top 2"),
|
||||
--tiles = {"techage_power_pole.png"},
|
||||
description = S("TA Power Pole Top 2 (for landlines)"),
|
||||
tiles = {
|
||||
"default_wood.png^techage_power_pole_top.png",
|
||||
"default_wood.png^techage_power_pole_top.png",
|
||||
@ -296,7 +331,7 @@ minetest.register_node("techage:power_pole3", {
|
||||
sounds = default.node_sound_defaults(),
|
||||
})
|
||||
|
||||
techage.power.register_node({"techage:power_pole"}, {
|
||||
techage.power.register_node({"techage:power_pole", "techage:power_pole_conn"}, {
|
||||
power_network = Cable,
|
||||
})
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 165 B After Width: | Height: | Size: 222 B |
@ -72,9 +72,9 @@ local function read_state(itemstack, user, pointed_thing)
|
||||
if load and load ~= "" and load ~= "unsupported" then
|
||||
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": load = "..load.." % ")
|
||||
end
|
||||
local power = techage.send_single("0", number, "power", nil)
|
||||
if power and power ~= "" and power ~= "unsupported" then
|
||||
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": power = "..power.." % ")
|
||||
local capa = techage.send_single("0", number, "capa", nil)
|
||||
if capa and capa ~= "" and capa ~= "unsupported" then
|
||||
minetest.chat_send_player(user:get_player_name(), ndef.description.." "..number..": capa = "..capa.." % ")
|
||||
end
|
||||
local owner = M(pos):get_string("owner") or ""
|
||||
if owner ~= "" then
|
||||
|
@ -235,8 +235,11 @@ techage.power.register_node({"techage:ta4_wind_turbine"}, {
|
||||
techage.register_node({"techage:ta4_wind_turbine"}, {
|
||||
on_recv_message = function(pos, src, topic, payload)
|
||||
local mem = tubelib2.get_mem(pos)
|
||||
print("on_recv_message", topic)
|
||||
if topic == "state" then
|
||||
local node = minetest.get_node(pos)
|
||||
if node.name == "ignore" then -- unloaded node?
|
||||
return "unloaded"
|
||||
end
|
||||
if mem.error then
|
||||
return "error"
|
||||
elseif mem.running and mem.providing then
|
||||
|
Loading…
Reference in New Issue
Block a user