commit | author | age
|
ee0765
|
1 |
-- Solar panels are the building blocks of LV solar arrays |
S |
2 |
-- They can however also be used separately but with reduced efficiency due to the missing transformer. |
|
3 |
-- Individual panels are less efficient than when the panels are combined into full arrays. |
|
4 |
|
be2f30
|
5 |
local S = technic.getter |
S |
6 |
|
83c649
|
7 |
|
S |
8 |
minetest.register_craft({ |
|
9 |
output = 'technic:solar_panel', |
|
10 |
recipe = { |
|
11 |
{'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer', 'technic:doped_silicon_wafer'}, |
44cb8d
|
12 |
{'basic_materials:silver_wire', 'technic:lv_cable', 'mesecons_materials:glue'}, |
VD |
13 |
}, |
|
14 |
replacements = { {"basic_materials:silver_wire", "basic_materials:empty_spool"}, }, |
83c649
|
15 |
}) |
S |
16 |
|
|
17 |
|
563a4c
|
18 |
local run = function(pos, node) |
N |
19 |
-- The action here is to make the solar panel prodice power |
|
20 |
-- Power is dependent on the light level and the height above ground |
|
21 |
-- There are many ways to cheat by using other light sources like lamps. |
|
22 |
-- As there is no way to determine if light is sunlight that is just a shame. |
|
23 |
-- To take care of some of it solar panels do not work outside daylight hours or if |
|
24 |
-- built below 0m |
|
25 |
local pos1 = {x=pos.x, y=pos.y+1, z=pos.z} |
|
26 |
local machine_name = S("Small Solar %s Generator"):format("LV") |
|
27 |
|
|
28 |
local light = minetest.get_node_light(pos1, nil) |
|
29 |
local time_of_day = minetest.get_timeofday() |
|
30 |
local meta = minetest.get_meta(pos) |
|
31 |
if light == nil then light = 0 end |
|
32 |
-- turn on panel only during day time and if sufficient light |
|
33 |
-- I know this is counter intuitive when cheating by using other light sources underground. |
|
34 |
if light >= 12 and time_of_day >= 0.24 and time_of_day <= 0.76 and pos.y > -10 then |
|
35 |
local charge_to_give = math.floor((light + pos1.y) * 3) |
|
36 |
charge_to_give = math.max(charge_to_give, 0) |
|
37 |
charge_to_give = math.min(charge_to_give, 200) |
41f175
|
38 |
meta:set_string("infotext", S("@1 Active (@2)", machine_name, |
H |
39 |
technic.EU_string(charge_to_give))) |
563a4c
|
40 |
meta:set_int("LV_EU_supply", charge_to_give) |
N |
41 |
else |
|
42 |
meta:set_string("infotext", S("%s Idle"):format(machine_name)) |
|
43 |
meta:set_int("LV_EU_supply", 0) |
|
44 |
end |
|
45 |
end |
|
46 |
|
ee0765
|
47 |
minetest.register_node("technic:solar_panel", { |
S |
48 |
tiles = {"technic_solar_panel_top.png", "technic_solar_panel_bottom.png", "technic_solar_panel_side.png", |
|
49 |
"technic_solar_panel_side.png", "technic_solar_panel_side.png", "technic_solar_panel_side.png"}, |
83c649
|
50 |
groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, |
S |
51 |
technic_machine=1, technic_lv=1}, |
|
52 |
connect_sides = {"bottom"}, |
ee0765
|
53 |
sounds = default.node_sound_wood_defaults(), |
a8daa4
|
54 |
description = S("Small Solar %s Generator"):format("LV"), |
ee0765
|
55 |
active = false, |
S |
56 |
drawtype = "nodebox", |
|
57 |
paramtype = "light", |
41f175
|
58 |
is_ground_content = true, |
ee0765
|
59 |
node_box = { |
S |
60 |
type = "fixed", |
|
61 |
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, |
|
62 |
}, |
|
63 |
on_construct = function(pos) |
|
64 |
local meta = minetest.get_meta(pos) |
|
65 |
meta:set_int("LV_EU_supply", 0) |
7c4b70
|
66 |
meta:set_string("infotext", S("Small Solar %s Generator"):format("LV")) |
ee0765
|
67 |
end, |
563a4c
|
68 |
technic_run = run, |
ee0765
|
69 |
}) |
S |
70 |
|
|
71 |
technic.register_machine("LV", "technic:solar_panel", technic.producer) |
|
72 |
|