bugfixes and improvements
started with the Thermal Energy System, but still deactivated
@ -75,7 +75,7 @@ function techage.firebox.can_dig(pos, player)
|
|||||||
return inv:is_empty("fuel")
|
return inv:is_empty("fuel")
|
||||||
end
|
end
|
||||||
|
|
||||||
function techage.firebox.allow_metadata_inventory(pos, listname, index, stack, player)
|
function techage.firebox.allow_metadata_inventory_put(pos, listname, index, stack, player)
|
||||||
if minetest.is_protected(pos, player:get_player_name()) then
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
@ -85,6 +85,13 @@ function techage.firebox.allow_metadata_inventory(pos, listname, index, stack, p
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function techage.firebox.allow_metadata_inventory_take(pos, listname, index, stack, player)
|
||||||
|
if minetest.is_protected(pos, player:get_player_name()) then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
return stack:get_count()
|
||||||
|
end
|
||||||
|
|
||||||
local PowerLevel = {
|
local PowerLevel = {
|
||||||
["25%"] = 1,
|
["25%"] = 1,
|
||||||
["50%"] = 2,
|
["50%"] = 2,
|
||||||
|
@ -104,35 +104,35 @@ local function formspec_help(player_name)
|
|||||||
local cat, key = get_ref(player_name)
|
local cat, key = get_ref(player_name)
|
||||||
local hdef = HelpPages[cat][key] or DUMMY
|
local hdef = HelpPages[cat][key] or DUMMY
|
||||||
local index = formspec_context[player_name].index or 1
|
local index = formspec_context[player_name].index or 1
|
||||||
local box = "box[8.5,0.9;1,1.1;#BBBBBB]"
|
local box = "box[9.5,0.9;1,1.1;#BBBBBB]"
|
||||||
|
|
||||||
if hdef.item_name == "-" then
|
if hdef.item_name == "-" then
|
||||||
bttn = ""
|
bttn = ""
|
||||||
elseif hdef.item_name == "plan" then
|
elseif hdef.item_name == "plan" then
|
||||||
bttn = "button[8.6,1;1,1;plan;"..S("Plan").."]"
|
bttn = "button[9.6,1;1,1;plan;"..S("Plan").."]"
|
||||||
else
|
else
|
||||||
bttn = box.."item_image[8.6,1;1,1;"..hdef.item_name.."]"
|
bttn = box.."item_image[9.6,1;1,1;"..hdef.item_name.."]"
|
||||||
end
|
end
|
||||||
return "size[10,9]"..
|
return "size[11,9]"..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
"item_image[8.6,0;1,1;techage:construction_board]"..
|
"item_image[9.6,0;1,1;techage:construction_board]"..
|
||||||
bttn..
|
bttn..
|
||||||
"table[0.1,0;8,4;page;"..entries_as_string(player_name)..";"..index.."]"..
|
"table[0.1,0;9,4;page;"..entries_as_string(player_name)..";"..index.."]"..
|
||||||
"textarea[0.3,4.7;10,5.3;help;"..S("Help")..":;"..hdef.text.."]"..
|
"textarea[0.3,4.7;11,5.3;help;"..S("Help")..":;"..hdef.text.."]"..
|
||||||
"box[0,4.75;9.775,4.45;#000000]"
|
"box[0,4.75;10.775,4.45;#000000]"
|
||||||
end
|
end
|
||||||
|
|
||||||
local function formspec_plan(player_name)
|
local function formspec_plan(player_name)
|
||||||
local cat, key = get_ref(player_name)
|
local cat, key = get_ref(player_name)
|
||||||
local hdef = HelpPages[cat][key] or DUMMY
|
local hdef = HelpPages[cat][key] or DUMMY
|
||||||
return "size[10,9]"..
|
return "size[11,9]"..
|
||||||
default.gui_bg..
|
default.gui_bg..
|
||||||
default.gui_bg_img..
|
default.gui_bg_img..
|
||||||
default.gui_slots..
|
default.gui_slots..
|
||||||
"label[0,0;"..hdef.name..":]"..
|
"label[0,0;"..hdef.name..":]"..
|
||||||
"button[9,0;1,0.8;back;<<]"..
|
"button[10,0;1,0.8;back;<<]"..
|
||||||
plan(hdef.images)
|
plan(hdef.images)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -93,8 +93,8 @@ minetest.register_node("techage:coalfirebox", {
|
|||||||
|
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
can_dig = firebox.can_dig,
|
can_dig = firebox.can_dig,
|
||||||
allow_metadata_inventory_put = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_put = firebox.allow_metadata_inventory_put,
|
||||||
allow_metadata_inventory_take = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_take = firebox.allow_metadata_inventory_take,
|
||||||
on_receive_fields = firebox.on_receive_fields,
|
on_receive_fields = firebox.on_receive_fields,
|
||||||
on_rightclick = firebox.on_rightclick,
|
on_rightclick = firebox.on_rightclick,
|
||||||
|
|
||||||
|
176
energy_storage/akkubox.lua
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
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"},
|
||||||
|
},
|
||||||
|
})
|
228
energy_storage/generator.lua
Normal file
@ -0,0 +1,228 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
GPL v3
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Generator
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
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
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
local function on_rightclick(pos)
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("techage:ta4_generator", {
|
||||||
|
description = S("TA4 Generator"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4_top.png",
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||||
|
"techage_filling_ta4.png^techage_appl_hole_electric.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_appl_generator.png",
|
||||||
|
"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)
|
||||||
|
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,
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:ta4_generator_on", {
|
||||||
|
description = S("TA4 Generator"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4_top.png",
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||||
|
"techage_filling_ta4.png^techage_appl_hole_electric.png^techage_frame_ta4.png",
|
||||||
|
"techage_filling_ta4.png^techage_appl_open.png^techage_frame_ta4.png",
|
||||||
|
{
|
||||||
|
image = "techage_filling4_ta4.png^techage_appl_generator4.png^techage_frame4_ta4.png",
|
||||||
|
backface_culling = false,
|
||||||
|
animation = {
|
||||||
|
type = "vertical_frames",
|
||||||
|
aspect_w = 32,
|
||||||
|
aspect_h = 32,
|
||||||
|
length = 0.3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
image = "techage_filling4_ta4.png^techage_appl_generator4.png^[transformFX]^techage_frame4_ta4.png",
|
||||||
|
backface_culling = false,
|
||||||
|
animation = {
|
||||||
|
type = "vertical_frames",
|
||||||
|
aspect_w = 32,
|
||||||
|
aspect_h = 32,
|
||||||
|
length = 0.3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
on_receive_fields = on_receive_fields,
|
||||||
|
on_rightclick = on_rightclick,
|
||||||
|
on_timer = node_timer,
|
||||||
|
|
||||||
|
drop = "",
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {not_in_creative_inventory=1},
|
||||||
|
diggable = false,
|
||||||
|
on_rotate = screwdriver.disallow,
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
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"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.power.register_node({"techage:ta4_generator", "techage:ta4_generator_on"}, {
|
||||||
|
conn_sides = {"R"},
|
||||||
|
power_network = Cable,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- for logical communication
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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")
|
458
energy_storage/heatexchanger.lua
Normal file
@ -0,0 +1,458 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
GPL v3
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Heat Exchanger
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
local P = minetest.string_to_pos
|
||||||
|
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.SteamPipe
|
||||||
|
|
||||||
|
local Water = {
|
||||||
|
["bucket:bucket_river_water"] = true,
|
||||||
|
["bucket:bucket_water"] = true,
|
||||||
|
["bucket:bucket_empty"] = true,
|
||||||
|
}
|
||||||
|
|
||||||
|
local function formspec(self, pos, mem)
|
||||||
|
local temp = mem.temperature or 20
|
||||||
|
local ratio = mem.power_ratio or 0
|
||||||
|
return "size[8,7]"..
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function can_start(pos, mem, state)
|
||||||
|
return mem.temperature and mem.temperature > 80
|
||||||
|
end
|
||||||
|
|
||||||
|
local function start_node(pos, mem, state)
|
||||||
|
mem.running = true
|
||||||
|
mem.power_ratio = 0
|
||||||
|
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"
|
||||||
|
end
|
||||||
|
|
||||||
|
local function place_nodes(pos)
|
||||||
|
local node = minetest.get_node(pos)
|
||||||
|
print("node.param2", node.param2)
|
||||||
|
minetest.set_node({x=pos.x, y=pos.y+1, z=pos.z}, {name = "techage:heatexchanger2", param2 = node.param2})
|
||||||
|
minetest.set_node({x=pos.x, y=pos.y+2, z=pos.z}, {name = "techage:heatexchanger1", param2 = node.param2})
|
||||||
|
end
|
||||||
|
|
||||||
|
local function remove_nodes(pos)
|
||||||
|
minetest.remove_node({x=pos.x, y=pos.y+1, z=pos.z})
|
||||||
|
minetest.remove_node({x=pos.x, y=pos.y+2, z=pos.z})
|
||||||
|
end
|
||||||
|
|
||||||
|
local State = techage.NodeStates:new({
|
||||||
|
node_name_passive = "techage:boiler2",
|
||||||
|
cycle_time = CYCLE_TIME,
|
||||||
|
standby_ticks = STANDBY_TICKS,
|
||||||
|
has_item_meter = false,
|
||||||
|
formspec_func = formspec,
|
||||||
|
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)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
local temp = water_temperature(pos, mem)
|
||||||
|
if State:is_active(mem) then
|
||||||
|
steaming(pos, mem, temp)
|
||||||
|
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))
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Top
|
||||||
|
minetest.register_node("techage:heatexchanger1", {
|
||||||
|
description = S("TA4 Heat Exchanger"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4_top.png",
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||||
|
"techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_hole_biogas.png",
|
||||||
|
"techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_hole_biogas.png",
|
||||||
|
"techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_ribsT.png",
|
||||||
|
"techage_filling_ta4.png^techage_frameT_ta4.png^techage_appl_ribsT.png",
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {0,0,0,0,0,0},
|
||||||
|
},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {crumbly = 2, cracky = 2, snappy = 2, not_in_creative_inventory=1},
|
||||||
|
--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"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_filling_ta4.png^techage_frame_ta4.png",
|
||||||
|
"techage_filling_ta4.png^techage_frame_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",
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {0,0,0,0,0,0},
|
||||||
|
},
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {crumbly = 2, cracky = 2, snappy = 2, not_in_creative_inventory=1},
|
||||||
|
--on_rotate = screwdriver.disallow,
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:heatexchanger3", {
|
||||||
|
description = S("TA4 Heat Exchanger"),
|
||||||
|
inventory_image = "techage_heat_exchanger_inv.png",
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_filling_ta4.png^techage_frame_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",
|
||||||
|
},
|
||||||
|
selection_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-8/16, -8/16, -8/16, 8/16, 40/16, 8/16},
|
||||||
|
},
|
||||||
|
|
||||||
|
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
|
||||||
|
place_nodes(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 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)
|
||||||
|
remove_nodes(pos)
|
||||||
|
end,
|
||||||
|
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {crumbly = 2, cracky = 2, snappy = 2},
|
||||||
|
on_rotate = screwdriver.disallow,
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
-- 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(),
|
||||||
|
--})
|
||||||
|
|
||||||
|
--techage.power.register_node({"techage:boiler2"}, {
|
||||||
|
-- conn_sides = {"U"},
|
||||||
|
-- power_network = Pipe,
|
||||||
|
--})
|
||||||
|
|
||||||
|
--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"},
|
||||||
|
-- },
|
||||||
|
--})
|
||||||
|
|
||||||
|
--techage.register_entry_page("ta2", "boiler1",
|
||||||
|
-- S("TA2 Boiler Base"),
|
||||||
|
-- S("Part of the steam engine. Has to be placed on top of the Firebox and filled with water.@n"..
|
||||||
|
-- "(see Steam Engine)"), "techage:boiler1")
|
||||||
|
|
||||||
|
--techage.register_entry_page("ta2", "boiler2",
|
||||||
|
-- S("TA2 Boiler Top"),
|
||||||
|
-- S("Part of the steam engine. Has to be placed on top of TA2 Boiler Base.@n(see Steam Engine)"),
|
||||||
|
-- "techage:boiler2")
|
||||||
|
|
||||||
|
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(),
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:ta4_tes_inlet", {
|
||||||
|
description = S("TA4 TES Core Element"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_tes_inlet.png",
|
||||||
|
},
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-8/16, -8/16, -8/16, 8/16, -12/32, 8/16},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
groups = {crumbly = 2, cracky = 2, snappy = 2},
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
})
|
55
energy_storage/help.lua
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
GPL v3
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Energy Storage System Help
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
local S = techage.S
|
||||||
|
|
||||||
|
local CONCR = "basic_materials_concrete_block.png"
|
||||||
|
local PIPEH = "techage_gaspipe.png"
|
||||||
|
local PIPEV = "techage_gaspipe.png^[transformR90"
|
||||||
|
local PN000 = "techage_gaspipe_knee.png"
|
||||||
|
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 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 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},
|
||||||
|
}
|
||||||
|
|
||||||
|
techage.register_category_page("ta4es",
|
||||||
|
S("TA4: Energy Storage System"),
|
||||||
|
S("Build a Energy Storage System to the plan with TA4 Heat Exchanger, TA4 Turbine and TA4 Generator.@n"..
|
||||||
|
"- ..."),
|
||||||
|
nil,
|
||||||
|
{},
|
||||||
|
Images)
|
||||||
|
|
181
energy_storage/turbine.lua
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
GPL v3
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Gas Turbine
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
local M = minetest.get_meta
|
||||||
|
local S = techage.S
|
||||||
|
|
||||||
|
local Pipe = techage.SteamPipe
|
||||||
|
|
||||||
|
local function transfer_generator(pos, topic, payload)
|
||||||
|
return techage.transfer(pos, "R", topic, payload, nil,
|
||||||
|
{"techage:ta4_generator", "techage:ta4_generator_on"})
|
||||||
|
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 play_sound(pos)
|
||||||
|
local mem = tubelib2.get_mem(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)
|
||||||
|
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
|
||||||
|
|
||||||
|
-- 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)
|
||||||
|
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.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_appl_turbine.png^techage_frame_ta4.png",
|
||||||
|
"techage_filling_ta4.png^techage_appl_turbine.png^techage_frame_ta4.png",
|
||||||
|
},
|
||||||
|
on_construct = tubelib2.init_mem,
|
||||||
|
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=2, crumbly=2, choppy=2},
|
||||||
|
on_rotate = screwdriver.disallow,
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
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.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",
|
||||||
|
{
|
||||||
|
image = "techage_filling4_ta4.png^techage_appl_turbine4.png^techage_frame4_ta4.png",
|
||||||
|
backface_culling = false,
|
||||||
|
animation = {
|
||||||
|
type = "vertical_frames",
|
||||||
|
aspect_w = 32,
|
||||||
|
aspect_h = 32,
|
||||||
|
length = 0.4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
image = "techage_filling4_ta4.png^techage_appl_turbine4.png^techage_frame4_ta4.png",
|
||||||
|
backface_culling = false,
|
||||||
|
animation = {
|
||||||
|
type = "vertical_frames",
|
||||||
|
aspect_w = 32,
|
||||||
|
aspect_h = 32,
|
||||||
|
length = 0.4,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
after_tube_update = after_tube_update,
|
||||||
|
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {not_in_creative_inventory=1},
|
||||||
|
diggable = false,
|
||||||
|
on_rotate = screwdriver.disallow,
|
||||||
|
is_ground_content = false,
|
||||||
|
sounds = default.node_sound_wood_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
-- for mechanical pipe connections
|
||||||
|
techage.power.register_node({"techage:ta4_turbine", "techage:ta4_turbine_on"}, {
|
||||||
|
conn_sides = {"L", "U"},
|
||||||
|
power_network = Pipe,
|
||||||
|
})
|
||||||
|
|
||||||
|
-- for logical communication
|
||||||
|
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)
|
||||||
|
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
|
||||||
|
elseif topic == "stop" then
|
||||||
|
transfer_cooler(pos, topic, payload)
|
||||||
|
swap_node(pos, "techage:ta4_turbine")
|
||||||
|
mem.running = false
|
||||||
|
stop_sound(pos)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
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"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
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)"),
|
||||||
|
"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
|
||||||
|
})
|
@ -88,8 +88,8 @@ minetest.register_node("techage:furnace_firebox", {
|
|||||||
|
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
can_dig = firebox.can_dig,
|
can_dig = firebox.can_dig,
|
||||||
allow_metadata_inventory_put = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_put = firebox.allow_metadata_inventory_put,
|
||||||
allow_metadata_inventory_take = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_take = firebox.allow_metadata_inventory_take,
|
||||||
on_receive_fields = firebox.on_receive_fields,
|
on_receive_fields = firebox.on_receive_fields,
|
||||||
on_rightclick = firebox.on_rightclick,
|
on_rightclick = firebox.on_rightclick,
|
||||||
|
|
||||||
@ -135,8 +135,8 @@ minetest.register_node("techage:furnace_firebox_on", {
|
|||||||
|
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
can_dig = firebox.can_dig,
|
can_dig = firebox.can_dig,
|
||||||
allow_metadata_inventory_put = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_put = firebox.allow_metadata_inventory_put,
|
||||||
allow_metadata_inventory_take = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_take = firebox.allow_metadata_inventory_take,
|
||||||
on_receive_fields = firebox.on_receive_fields,
|
on_receive_fields = firebox.on_receive_fields,
|
||||||
on_rightclick = firebox.on_rightclick,
|
on_rightclick = firebox.on_rightclick,
|
||||||
})
|
})
|
||||||
|
10
init.lua
@ -59,12 +59,13 @@ else
|
|||||||
dofile(MP.."/power/junction.lua")
|
dofile(MP.."/power/junction.lua")
|
||||||
dofile(MP.."/power/drive_axle.lua")
|
dofile(MP.."/power/drive_axle.lua")
|
||||||
dofile(MP.."/power/steam_pipe.lua")
|
dofile(MP.."/power/steam_pipe.lua")
|
||||||
dofile(MP.."/power/biogas_pipe.lua")
|
|
||||||
dofile(MP.."/power/electric_cable.lua")
|
dofile(MP.."/power/electric_cable.lua")
|
||||||
dofile(MP.."/power/power_line.lua")
|
dofile(MP.."/power/power_line.lua")
|
||||||
dofile(MP.."/power/junctionbox.lua")
|
dofile(MP.."/power/junctionbox.lua")
|
||||||
dofile(MP.."/power/powerswitch.lua")
|
dofile(MP.."/power/powerswitch.lua")
|
||||||
dofile(MP.."/power/protection.lua")
|
dofile(MP.."/power/protection.lua")
|
||||||
|
dofile(MP.."/power/ta4_pipe.lua")
|
||||||
|
dofile(MP.."/power/ta4_junction.lua")
|
||||||
|
|
||||||
-- Iron Age
|
-- Iron Age
|
||||||
dofile(MP.."/iron_age/main.lua")
|
dofile(MP.."/iron_age/main.lua")
|
||||||
@ -183,4 +184,11 @@ else
|
|||||||
dofile(MP.."/wind_turbine/rotor.lua")
|
dofile(MP.."/wind_turbine/rotor.lua")
|
||||||
dofile(MP.."/nodes/pillar.lua")
|
dofile(MP.."/nodes/pillar.lua")
|
||||||
dofile(MP.."/wind_turbine/signallamp.lua")
|
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/help.lua")
|
||||||
|
|
||||||
end
|
end
|
@ -86,10 +86,10 @@ local function eval(pos, mem)
|
|||||||
local res, sts = pcall(mem.code)
|
local res, sts = pcall(mem.code)
|
||||||
if res then
|
if res then
|
||||||
mem.error = "ok"
|
mem.error = "ok"
|
||||||
if sts == true then
|
if sts == true and mem.inp_tbl.outp ~= true then
|
||||||
mem.inp_tbl.outp = sts
|
mem.inp_tbl.outp = sts
|
||||||
return "on"
|
return "on"
|
||||||
elseif sts == false then
|
elseif sts == false and mem.inp_tbl.outp ~= false then
|
||||||
mem.inp_tbl.outp = sts
|
mem.inp_tbl.outp = sts
|
||||||
return "off"
|
return "off"
|
||||||
end
|
end
|
||||||
|
@ -124,7 +124,8 @@ local function command(pos, command, player)
|
|||||||
meta:set_int("public", 0)
|
meta:set_int("public", 0)
|
||||||
output(pos, player..":$ "..command)
|
output(pos, player..":$ "..command)
|
||||||
output(pos, S("Switched to private use!"))
|
output(pos, S("Switched to private use!"))
|
||||||
elseif meta:get_int("public") == 1 or owner == player then
|
elseif meta:get_int("public") == 1 or owner == player or
|
||||||
|
minetest.check_player_privs(player, "server") then
|
||||||
output(pos, "$ "..command)
|
output(pos, "$ "..command)
|
||||||
local own_num = meta:get_string("node_number")
|
local own_num = meta:get_string("node_number")
|
||||||
local num, cmnd, payload = command:match('^cmd%s+([0-9]+)%s+(%w+)%s*(.*)$')
|
local num, cmnd, payload = command:match('^cmd%s+([0-9]+)%s+(%w+)%s*(.*)$')
|
||||||
|
@ -1,201 +0,0 @@
|
|||||||
--[[
|
|
||||||
|
|
||||||
TechAge
|
|
||||||
=======
|
|
||||||
|
|
||||||
Copyright (C) 2019 Joachim Stolberg
|
|
||||||
|
|
||||||
GPL v3
|
|
||||||
See LICENSE.txt for more information
|
|
||||||
|
|
||||||
TA4 Biogas pipes
|
|
||||||
|
|
||||||
]]--
|
|
||||||
|
|
||||||
-- for lazy programmers
|
|
||||||
local P = minetest.string_to_pos
|
|
||||||
local M = minetest.get_meta
|
|
||||||
local S = techage.S
|
|
||||||
|
|
||||||
local Pipe = tubelib2.Tube:new({
|
|
||||||
dirs_to_check = {1,2,3,4,5,6},
|
|
||||||
max_tube_length = 1000,
|
|
||||||
show_infotext = false,
|
|
||||||
tube_type = "biogas_pipe",
|
|
||||||
primary_node_names = {"techage:biogas_pipeS", "techage:biogas_pipeA"},
|
|
||||||
secondary_node_names = {"techage:gasflare", "techage:compressor"},
|
|
||||||
after_place_tube = function(pos, param2, tube_type, num_tubes, tbl)
|
|
||||||
minetest.swap_node(pos, {name = "techage:biogas_pipe"..tube_type, param2 = param2})
|
|
||||||
M(pos):set_int("tl2_param2", param2)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
|
|
||||||
Pipe:register_on_tube_update(function(node, pos, out_dir, peer_pos, peer_in_dir)
|
|
||||||
minetest.registered_nodes[node.name].after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
|
||||||
end)
|
|
||||||
|
|
||||||
techage.BiogasPipe = Pipe
|
|
||||||
|
|
||||||
|
|
||||||
-- Overridden method of tubelib2!
|
|
||||||
function Pipe:get_primary_node_param2(pos, dir)
|
|
||||||
return techage.get_primary_node_param2(pos, dir)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Pipe:is_primary_node(pos, dir)
|
|
||||||
return techage.is_primary_node(pos, dir)
|
|
||||||
end
|
|
||||||
|
|
||||||
Pipe:register_on_tube_update(function(node, pos, out_dir, peer_pos, peer_in_dir)
|
|
||||||
local clbk = minetest.registered_nodes[node.name].after_tube_update
|
|
||||||
if clbk then
|
|
||||||
clbk(node, pos, out_dir, peer_pos, peer_in_dir)
|
|
||||||
else
|
|
||||||
techage.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
minetest.register_node("techage:biogas_pipeS", {
|
|
||||||
description = S("TA3 Biogas Pipe"),
|
|
||||||
tiles = {
|
|
||||||
"techage_gaspipe.png^[transformR90",
|
|
||||||
"techage_gaspipe.png^[transformR90",
|
|
||||||
"techage_gaspipe.png",
|
|
||||||
"techage_gaspipe.png",
|
|
||||||
"techage_gaspipe_hole2.png",
|
|
||||||
"techage_gaspipe_hole2.png",
|
|
||||||
},
|
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
|
||||||
if not Pipe:after_place_tube(pos, placer, pointed_thing) then
|
|
||||||
minetest.remove_node(pos)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end,
|
|
||||||
|
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
||||||
if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then
|
|
||||||
oldnode.param2 = oldmetadata.fields.tl2_param2
|
|
||||||
Pipe:after_dig_tube(pos, oldnode)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
paramtype2 = "facedir", -- important!
|
|
||||||
drawtype = "nodebox",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-1/8, -1/8, -4/8, 1/8, 1/8, 4/8},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
on_rotate = screwdriver.disallow, -- important!
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {crumbly = 3, cracky = 3, snappy = 3, techage_trowel = 1},
|
|
||||||
sounds = default.node_sound_glass_defaults(),
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("techage:biogas_pipeA", {
|
|
||||||
description = S("TA3 Biogas Pipe"),
|
|
||||||
tiles = {
|
|
||||||
"techage_gaspipe_knee2.png",
|
|
||||||
"techage_gaspipe_hole2.png^[transformR180",
|
|
||||||
"techage_gaspipe_knee.png^[transformR270",
|
|
||||||
"techage_gaspipe_knee.png",
|
|
||||||
"techage_gaspipe_knee2.png",
|
|
||||||
"techage_gaspipe_hole2.png",
|
|
||||||
},
|
|
||||||
|
|
||||||
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
||||||
if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then
|
|
||||||
oldnode.param2 = oldmetadata.fields.tl2_param2
|
|
||||||
Pipe:after_dig_tube(pos, oldnode)
|
|
||||||
end
|
|
||||||
end,
|
|
||||||
|
|
||||||
paramtype2 = "facedir", -- important!
|
|
||||||
drawtype = "nodebox",
|
|
||||||
node_box = {
|
|
||||||
type = "fixed",
|
|
||||||
fixed = {
|
|
||||||
{-1/8, -4/8, -1/8, 1/8, 1/8, 1/8},
|
|
||||||
{-2/8, -0.5, -2/8, 2/8, -13/32, 2/8},
|
|
||||||
{-1/8, -1/8, -4/8, 1/8, 1/8, -1/8},
|
|
||||||
{-2/8, -2/8, -0.5, 2/8, 2/8, -13/32},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
on_rotate = screwdriver.disallow, -- important!
|
|
||||||
paramtype = "light",
|
|
||||||
sunlight_propagates = true,
|
|
||||||
is_ground_content = false,
|
|
||||||
groups = {crumbly = 3, cracky = 3, snappy = 3, techage_trowel = 1, not_in_creative_inventory=1},
|
|
||||||
sounds = default.node_sound_glass_defaults(),
|
|
||||||
drop = "techage:biogas_pipeS",
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
local size1 = 1/8
|
|
||||||
local size2 = 2/8
|
|
||||||
local size3 = 13/32
|
|
||||||
local Boxes = {
|
|
||||||
{
|
|
||||||
{-size1, -size1, size1, size1, size1, 0.5 }, -- z+
|
|
||||||
{-size2, -size2, size3, size2, size2, 0.5 }, -- z+
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{-size1, -size1, -size1, 0.5, size1, size1}, -- x+
|
|
||||||
{ size3, -size2, -size2, 0.5, size2, size2}, -- x+
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{-size1, -size1, -0.5, size1, size1, size1}, -- z-
|
|
||||||
{-size2, -size2, -0.5, size2, size2, -size3}, -- z-
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{-0.5, -size1, -size1, size1, size1, size1}, -- x-
|
|
||||||
{-0.5, -size2, -size2, -size3, size2, size2}, -- x-
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{-size1, -0.5, -size1, size1, size1, size1}, -- y-
|
|
||||||
{-size2, -0.5, -size2, size2, -size3, size2}, -- y-
|
|
||||||
},
|
|
||||||
{
|
|
||||||
{-size1, -size1, -size1, size1, 0.5, size1}, -- y+
|
|
||||||
{-size2, size3, -size2, size2, 0.5, size2}, -- y+
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
--techage.register_junction("techage:biogas_junction", 1/8, Boxes, Pipe, {
|
|
||||||
-- description = "TA3 Biogas Junction",
|
|
||||||
-- tiles = {"techage_gaspipe_junction.png"},
|
|
||||||
-- groups = {crumbly = 3, cracky = 3, snappy = 3, techage_trowel = 1},
|
|
||||||
-- sounds = default.node_sound_metal_defaults(),
|
|
||||||
|
|
||||||
-- after_place_node = function(pos, placer, itemstack, pointed_thing)
|
|
||||||
-- local meta = minetest.get_meta(pos)
|
|
||||||
-- meta:set_string("infotext", "Position "..P2S(pos))
|
|
||||||
-- Pipe:after_place_node(pos)
|
|
||||||
-- techage.sink_power_consumption(pos, 0)
|
|
||||||
-- end,
|
|
||||||
|
|
||||||
-- after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
|
|
||||||
-- local conn = minetest.deserialize(M(pos):get_string("connections")) or {}
|
|
||||||
-- conn[out_dir] = peer_pos
|
|
||||||
-- M(pos):set_string("connections", minetest.serialize(conn))
|
|
||||||
-- local name = "techage:biogas_junction"..techage.junction_type(conn)
|
|
||||||
-- minetest.swap_node(pos, {name = name, param2 = 0})
|
|
||||||
-- techage.sink_power_consumption(pos, 0)
|
|
||||||
-- end,
|
|
||||||
|
|
||||||
-- on_destruct = function(pos)
|
|
||||||
-- techage.sink_power_consumption(pos, 0)
|
|
||||||
-- end,
|
|
||||||
|
|
||||||
-- after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
|
||||||
-- Pipe:after_dig_node(pos)
|
|
||||||
-- end,
|
|
||||||
--})
|
|
||||||
|
|
77
power/ta4_junction.lua
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
GPL v3
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Junction Pipes
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
local M = minetest.get_meta
|
||||||
|
local S = techage.S
|
||||||
|
|
||||||
|
local Pipe = techage.BiogasPipe
|
||||||
|
local power = techage.power
|
||||||
|
|
||||||
|
local size1 = 1/8
|
||||||
|
local size2 = 2/8
|
||||||
|
local size3 = 13/32
|
||||||
|
--local size3 = 1/8
|
||||||
|
local Boxes = {
|
||||||
|
{
|
||||||
|
{-size1, -size1, size1, size1, size1, 0.5 }, -- z+
|
||||||
|
{-size2, -size2, size3, size2, size2, 0.5 }, -- z+
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{-size1, -size1, -size1, 0.5, size1, size1}, -- x+
|
||||||
|
{ size3, -size2, -size2, 0.5, size2, size2}, -- x+
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{-size1, -size1, -0.5, size1, size1, size1}, -- z-
|
||||||
|
{-size2, -size2, -0.5, size2, size2, -size3}, -- z-
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{-0.5, -size1, -size1, size1, size1, size1}, -- x-
|
||||||
|
{-0.5, -size2, -size2, -size3, size2, size2}, -- x-
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{-size1, -0.5, -size1, size1, size1, size1}, -- y-
|
||||||
|
{-size2, -0.5, -size2, size2, -size3, size2}, -- y-
|
||||||
|
},
|
||||||
|
{
|
||||||
|
{-size1, -size1, -size1, size1, 0.5, size1}, -- y+
|
||||||
|
{-size2, size3, -size2, size2, 0.5, size2}, -- y+
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
techage.register_junction("techage:ta4_junctionpipe", 1/8, Boxes, Pipe, {
|
||||||
|
description = S("TA4 Junction Pipe"),
|
||||||
|
tiles = {"techage_gaspipe_junction.png"},
|
||||||
|
groups = {crumbly = 2, cracky = 2, snappy = 2, techage_trowel = 1},
|
||||||
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
|
||||||
|
on_construct = tubelib2.init_mem,
|
||||||
|
after_tube_update = function(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||||
|
local name = "techage:ta4_junctionpipe"..techage.junction_type(pos, Pipe)
|
||||||
|
minetest.swap_node(pos, {name = name, param2 = 0})
|
||||||
|
power.network_changed(pos, tubelib2.get_mem(pos))
|
||||||
|
end,
|
||||||
|
is_power_available = function(pos)
|
||||||
|
return techage.power.power_accounting(pos, tubelib2.get_mem(pos))
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "techage:ta4_junctionpipe0 2",
|
||||||
|
recipe = {
|
||||||
|
{"", "techage:ta4_pipeS", ""},
|
||||||
|
{"techage:ta4_pipeS", "", "techage:ta4_pipeS"},
|
||||||
|
{"", "techage:ta4_pipeS", ""},
|
||||||
|
},
|
||||||
|
})
|
161
power/ta4_pipe.lua
Normal file
@ -0,0 +1,161 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
GPL v3
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Biogas/Stream/oil pipes
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
local S2P = minetest.string_to_pos
|
||||||
|
local P2S = minetest.pos_to_string
|
||||||
|
local M = minetest.get_meta
|
||||||
|
local S = techage.S
|
||||||
|
|
||||||
|
local Pipe = tubelib2.Tube:new({
|
||||||
|
dirs_to_check = {1,2,3,4,5,6},
|
||||||
|
max_tube_length = 1000,
|
||||||
|
show_infotext = false,
|
||||||
|
tube_type = "ta4_pipe",
|
||||||
|
primary_node_names = {"techage:ta4_pipeS", "techage:ta4_pipeA"},
|
||||||
|
secondary_node_names = {},
|
||||||
|
after_place_tube = function(pos, param2, tube_type, num_tubes)
|
||||||
|
-- Don't replace "hidden" cable
|
||||||
|
if M(pos):get_string("techage_hidden_nodename") == "" then
|
||||||
|
minetest.swap_node(pos, {name = "techage:ta4_pipe"..tube_type, param2 = param2 % 32})
|
||||||
|
end
|
||||||
|
M(pos):set_int("tl2_param2", param2)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.BiogasPipe = Pipe
|
||||||
|
|
||||||
|
|
||||||
|
-- Overridden method of tubelib2!
|
||||||
|
function Pipe:get_primary_node_param2(pos, dir)
|
||||||
|
return techage.get_primary_node_param2(pos, dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Pipe:is_primary_node(pos, dir)
|
||||||
|
return techage.is_primary_node(pos, dir)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Pipe:get_secondary_node(pos, dir)
|
||||||
|
local npos = vector.add(pos, tubelib2.Dir6dToVector[dir or 0])
|
||||||
|
local node = self:get_node_lvm(npos)
|
||||||
|
if self.secondary_node_names[node.name] or
|
||||||
|
self.secondary_node_names[M(npos):get_string("techage_hidden_nodename")] then
|
||||||
|
return node, npos
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Pipe:is_secondary_node(pos, dir)
|
||||||
|
local npos = vector.add(pos, tubelib2.Dir6dToVector[dir or 0])
|
||||||
|
local node = self:get_node_lvm(npos)
|
||||||
|
return self.secondary_node_names[node.name] or
|
||||||
|
self.secondary_node_names[M(npos):get_string("techage_hidden_nodename")]
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("techage:ta4_pipeS", {
|
||||||
|
description = S("TA4 Pipe"),
|
||||||
|
tiles = {
|
||||||
|
"techage_gaspipe.png^[transformR90",
|
||||||
|
"techage_gaspipe.png^[transformR90",
|
||||||
|
"techage_gaspipe.png",
|
||||||
|
"techage_gaspipe.png",
|
||||||
|
"techage_gaspipe_hole2.png",
|
||||||
|
"techage_gaspipe_hole2.png",
|
||||||
|
},
|
||||||
|
|
||||||
|
after_place_node = function(pos, placer, itemstack, pointed_thing)
|
||||||
|
if not Pipe:after_place_tube(pos, placer, pointed_thing) then
|
||||||
|
minetest.remove_node(pos)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
return false
|
||||||
|
end,
|
||||||
|
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
|
if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then
|
||||||
|
oldnode.param2 = oldmetadata.fields.tl2_param2
|
||||||
|
Pipe:after_dig_tube(pos, oldnode)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
paramtype2 = "facedir", -- important!
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-1/8, -1/8, -4/8, 1/8, 1/8, 4/8},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
on_rotate = screwdriver.disallow, -- important!
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
is_ground_content = false,
|
||||||
|
groups = {crumbly = 2, cracky = 2, snappy = 2, techage_trowel = 1},
|
||||||
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_node("techage:ta4_pipeA", {
|
||||||
|
description = S("TA4 Pipe"),
|
||||||
|
tiles = {
|
||||||
|
"techage_gaspipe_knee2.png",
|
||||||
|
"techage_gaspipe_hole2.png^[transformR180",
|
||||||
|
"techage_gaspipe_knee.png^[transformR270",
|
||||||
|
"techage_gaspipe_knee.png",
|
||||||
|
"techage_gaspipe_knee2.png",
|
||||||
|
"techage_gaspipe_hole2.png",
|
||||||
|
},
|
||||||
|
|
||||||
|
after_dig_node = function(pos, oldnode, oldmetadata, digger)
|
||||||
|
if oldmetadata and oldmetadata.fields and oldmetadata.fields.tl2_param2 then
|
||||||
|
oldnode.param2 = oldmetadata.fields.tl2_param2
|
||||||
|
Pipe:after_dig_tube(pos, oldnode)
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
|
||||||
|
paramtype2 = "facedir", -- important!
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-1/8, -4/8, -1/8, 1/8, 1/8, 1/8},
|
||||||
|
{-2/8, -0.5, -2/8, 2/8, -13/32, 2/8},
|
||||||
|
{-1/8, -1/8, -4/8, 1/8, 1/8, -1/8},
|
||||||
|
{-2/8, -2/8, -0.5, 2/8, 2/8, -13/32},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
on_rotate = screwdriver.disallow, -- important!
|
||||||
|
paramtype = "light",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
is_ground_content = false,
|
||||||
|
groups = {crumbly = 2, cracky = 2, snappy = 2, techage_trowel = 1, not_in_creative_inventory=1},
|
||||||
|
sounds = default.node_sound_metal_defaults(),
|
||||||
|
drop = "techage:ta4_pipeS",
|
||||||
|
})
|
||||||
|
|
||||||
|
Pipe:register_on_tube_update(function(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||||
|
if minetest.registered_nodes[node.name].after_tube_update then
|
||||||
|
minetest.registered_nodes[node.name].after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir)
|
||||||
|
else
|
||||||
|
techage.power.after_tube_update(node, pos, out_dir, peer_pos, peer_in_dir, Cable)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "techage:ta4_pipeS 3",
|
||||||
|
recipe = {
|
||||||
|
{'', '', "default:steel_ingot"},
|
||||||
|
{'dye:yellow', 'techage:meridium_ingot', ''},
|
||||||
|
{"default:steel_ingot", '', ''},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
@ -70,8 +70,8 @@ minetest.register_node("techage:firebox", {
|
|||||||
|
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
can_dig = firebox.can_dig,
|
can_dig = firebox.can_dig,
|
||||||
allow_metadata_inventory_put = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_put = firebox.allow_metadata_inventory_put,
|
||||||
allow_metadata_inventory_take = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_take = firebox.allow_metadata_inventory_take,
|
||||||
on_receive_fields = firebox.on_receive_fields,
|
on_receive_fields = firebox.on_receive_fields,
|
||||||
on_rightclick = firebox.on_rightclick,
|
on_rightclick = firebox.on_rightclick,
|
||||||
|
|
||||||
@ -128,8 +128,8 @@ minetest.register_node("techage:firebox_on", {
|
|||||||
|
|
||||||
on_timer = node_timer,
|
on_timer = node_timer,
|
||||||
can_dig = firebox.can_dig,
|
can_dig = firebox.can_dig,
|
||||||
allow_metadata_inventory_put = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_put = firebox.allow_metadata_inventory_put,
|
||||||
allow_metadata_inventory_take = firebox.allow_metadata_inventory,
|
allow_metadata_inventory_take = firebox.allow_metadata_inventory_take,
|
||||||
on_receive_fields = firebox.on_receive_fields,
|
on_receive_fields = firebox.on_receive_fields,
|
||||||
on_rightclick = firebox.on_rightclick,
|
on_rightclick = firebox.on_rightclick,
|
||||||
})
|
})
|
||||||
|
BIN
textures/techage_appl_ribsB.png
Normal file
After Width: | Height: | Size: 436 B |
BIN
textures/techage_appl_ribsM.png
Normal file
After Width: | Height: | Size: 424 B |
BIN
textures/techage_appl_ribsT.png
Normal file
After Width: | Height: | Size: 440 B |
BIN
textures/techage_appl_tes_core.png
Normal file
After Width: | Height: | Size: 180 B |
BIN
textures/techage_appl_tes_turb.png
Normal file
After Width: | Height: | Size: 197 B |
Before Width: | Height: | Size: 216 B After Width: | Height: | Size: 220 B |
BIN
textures/techage_frameB_ta4.png
Normal file
After Width: | Height: | Size: 242 B |
BIN
textures/techage_frameM_ta4.png
Normal file
After Width: | Height: | Size: 231 B |
BIN
textures/techage_frameT_ta4.png
Normal file
After Width: | Height: | Size: 266 B |
BIN
textures/techage_heat_exchanger_inv.png
Normal file
After Width: | Height: | Size: 619 B |
BIN
textures/techage_tes_core_elem.png
Normal file
After Width: | Height: | Size: 379 B |
BIN
textures/techage_tes_core_elem_top.png
Normal file
After Width: | Height: | Size: 298 B |
BIN
textures/techage_tes_inlet.png
Normal file
After Width: | Height: | Size: 385 B |
BIN
textures/techage_tes_inlet_help.png
Normal file
After Width: | Height: | Size: 220 B |