solar panel added
This commit is contained in:
parent
7264439bef
commit
d092bec7c1
8
init.lua
8
init.lua
@ -25,7 +25,8 @@ else
|
|||||||
--pwr = true, -- power distribution
|
--pwr = true, -- power distribution
|
||||||
sts = true, -- status plots
|
sts = true, -- status plots
|
||||||
--dbg = true,
|
--dbg = true,
|
||||||
dbg2 = true,
|
--dbg2 = true,
|
||||||
|
tst = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Basis features
|
-- Basis features
|
||||||
@ -154,4 +155,9 @@ else
|
|||||||
dofile(MP.."/.test/source.lua")
|
dofile(MP.."/.test/source.lua")
|
||||||
dofile(MP.."/.test/akku.lua")
|
dofile(MP.."/.test/akku.lua")
|
||||||
--dofile(MP.."/.test/switch.lua")
|
--dofile(MP.."/.test/switch.lua")
|
||||||
|
|
||||||
|
-- Solar
|
||||||
|
dofile(MP.."/nodes/silicon.lua")
|
||||||
|
dofile(MP.."/solar/minicell.lua")
|
||||||
|
|
||||||
end
|
end
|
28
nodes/silicon.lua
Normal file
28
nodes/silicon.lua
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
LGPLv2.1+
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Silicon Wafer
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
local S = techage.S
|
||||||
|
|
||||||
|
minetest.register_craftitem("techage:ta4_silicon_wafer", {
|
||||||
|
description = S("TA4 Silicon Wafer"),
|
||||||
|
inventory_image = "techage_silicon_wafer.png",
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.furnace.register_recipe({
|
||||||
|
output = "techage:ta4_silicon_wafer 8",
|
||||||
|
recipe = {
|
||||||
|
"basic_materials:silicon",
|
||||||
|
},
|
||||||
|
time = 6,
|
||||||
|
})
|
@ -449,7 +449,7 @@ function techage.power.generator_alive(pos, mem)
|
|||||||
if mem.pwr_is_master then
|
if mem.pwr_is_master then
|
||||||
power_distribution(pos, mem, 1)
|
power_distribution(pos, mem, 1)
|
||||||
end
|
end
|
||||||
return mem.pwr_provided
|
return mem.pwr_provided or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
--
|
--
|
||||||
|
135
solar/minicell.lua
Normal file
135
solar/minicell.lua
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
--[[
|
||||||
|
|
||||||
|
TechAge
|
||||||
|
=======
|
||||||
|
|
||||||
|
Copyright (C) 2019 Joachim Stolberg
|
||||||
|
|
||||||
|
LGPLv2.1+
|
||||||
|
See LICENSE.txt for more information
|
||||||
|
|
||||||
|
TA4 Streetlamp Solar Cell
|
||||||
|
|
||||||
|
]]--
|
||||||
|
|
||||||
|
-- for lazy programmers
|
||||||
|
local P = minetest.string_to_pos
|
||||||
|
local M = minetest.get_meta
|
||||||
|
|
||||||
|
local S = techage.S
|
||||||
|
|
||||||
|
local CYCLE_TIME = 2
|
||||||
|
local PWR_PERF = 1
|
||||||
|
local PWR_CAPA = 30 * 20 -- default day
|
||||||
|
|
||||||
|
minetest.after(2, function()
|
||||||
|
-- calculate the capacity depending on the day duration
|
||||||
|
PWR_CAPA = math.max(minetest.get_gametime() / minetest.get_day_count() / 2, PWR_CAPA)
|
||||||
|
end)
|
||||||
|
|
||||||
|
local Cable = techage.ElectricCable
|
||||||
|
local power = techage.power
|
||||||
|
|
||||||
|
local function node_timer(pos, elapsed)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.capa = mem.capa or 0
|
||||||
|
pos.y = pos.y + 1
|
||||||
|
local light = minetest.get_node_light(pos)
|
||||||
|
pos.y = pos.y - 1
|
||||||
|
|
||||||
|
if light >= (minetest.LIGHT_MAX - 1) then
|
||||||
|
if mem.providing then
|
||||||
|
power.generator_stop(pos, mem)
|
||||||
|
mem.providing = false
|
||||||
|
mem.provided = 0
|
||||||
|
end
|
||||||
|
mem.capa = math.min(mem.capa + PWR_PERF * 1.2, PWR_CAPA)
|
||||||
|
else
|
||||||
|
if mem.capa > 0 then
|
||||||
|
if not mem.providing then
|
||||||
|
power.generator_start(pos, mem, PWR_PERF)
|
||||||
|
mem.providing = true
|
||||||
|
end
|
||||||
|
mem.provided = power.generator_alive(pos, mem)
|
||||||
|
mem.capa = mem.capa - mem.provided
|
||||||
|
else
|
||||||
|
power.generator_stop(pos, mem)
|
||||||
|
mem.providing = false
|
||||||
|
mem.provided = 0
|
||||||
|
mem.capa = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
mydbg("tst", "PWR_CAPA = "..PWR_CAPA..", mem.capa = "..mem.capa..", light = "..light)
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("techage:ta4_solar_minicell", {
|
||||||
|
description = S("TA4 Streetlamp Solar Cell"),
|
||||||
|
tiles = {
|
||||||
|
-- up, down, right, left, back, front
|
||||||
|
"techage_solar_cell_mini_top.png",
|
||||||
|
"techage_solar_cell_mini_bottom.png",
|
||||||
|
"techage_solar_cell_mini_side.png",
|
||||||
|
},
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {
|
||||||
|
{-14/32, -8/32, -14/32, 14/32, -6/32, 14/32},
|
||||||
|
{-7/32, -16/32, -7/32, 7/32, -8/32, 7/32},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
after_place_node = function(pos)
|
||||||
|
local meta = minetest.get_meta(pos)
|
||||||
|
local number = techage.add_node(pos, "techage:ta4_solar_minicell")
|
||||||
|
meta:set_string("number", number)
|
||||||
|
meta:set_string("infotext", S("TA4 Streetlamp Solar Cell").." "..number)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
mem.capa = 0
|
||||||
|
mem.providing = false
|
||||||
|
minetest.get_node_timer(pos):start(CYCLE_TIME)
|
||||||
|
end,
|
||||||
|
|
||||||
|
after_dig_node = function(pos)
|
||||||
|
techage.remove_node(pos)
|
||||||
|
end,
|
||||||
|
|
||||||
|
paramtype2 = "facedir",
|
||||||
|
groups = {cracky=2, crumbly=2, choppy=2},
|
||||||
|
is_ground_content = false,
|
||||||
|
on_timer = node_timer,
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.power.register_node({"techage:ta4_solar_minicell"}, {
|
||||||
|
power_network = Cable,
|
||||||
|
})
|
||||||
|
|
||||||
|
techage.register_node({"techage:ta4_solar_minicell"}, {
|
||||||
|
on_recv_message = function(pos, topic, payload)
|
||||||
|
local mem = tubelib2.get_mem(pos)
|
||||||
|
if topic == "state" then
|
||||||
|
if mem.providing then
|
||||||
|
if (mem.provided or 0) > 0 then
|
||||||
|
return "discharging"
|
||||||
|
else
|
||||||
|
return "unused"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return "charging"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return "unsupported"
|
||||||
|
end
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_craft({
|
||||||
|
output = "techage:ta4_solar_minicell",
|
||||||
|
recipe = {
|
||||||
|
{"", "", ""},
|
||||||
|
{"techage:ta4_silicon_wafer", "techage:ta4_silicon_wafer", "techage:ta4_silicon_wafer"},
|
||||||
|
{"default:tin_ingot", "techage:iron_ingot", "default:copper_ingot"},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
BIN
textures/techage_silicon_wafer.png
Normal file
BIN
textures/techage_silicon_wafer.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
textures/techage_solar_cell_mini_bottom.png
Normal file
BIN
textures/techage_solar_cell_mini_bottom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 322 B |
BIN
textures/techage_solar_cell_mini_side.png
Normal file
BIN
textures/techage_solar_cell_mini_side.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 269 B |
BIN
textures/techage_solar_cell_mini_top.png
Normal file
BIN
textures/techage_solar_cell_mini_top.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 261 B |
Loading…
Reference in New Issue
Block a user