commit | author | age
|
8e03d7
|
1 |
-- The high voltage solar array is an assembly of medium voltage arrays. |
R |
2 |
-- The assembly can deliver high voltage levels and is a 20% less efficient |
|
3 |
-- compared to 5 individual medium voltage arrays due to losses in the transformer. |
|
4 |
-- However high voltage is supplied. |
|
5 |
-- Solar arrays are not able to store large amounts of energy. |
|
6 |
minetest.register_node("technic:solar_array_hv", { |
|
7 |
tiles = {"technic_hv_solar_array_top.png", "technic_hv_solar_array_bottom.png", "technic_hv_solar_array_side.png", |
|
8 |
"technic_hv_solar_array_side.png", "technic_hv_solar_array_side.png", "technic_hv_solar_array_side.png"}, |
|
9 |
groups = {snappy=2,choppy=2,oddly_breakable_by_hand=2}, |
|
10 |
sounds = default.node_sound_wood_defaults(), |
|
11 |
description="HV Solar Array", |
|
12 |
active = false, |
|
13 |
drawtype = "nodebox", |
|
14 |
paramtype = "light", |
|
15 |
is_ground_content = true, |
|
16 |
node_box = { |
|
17 |
type = "fixed", |
|
18 |
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, |
|
19 |
}, |
|
20 |
selection_box = { |
|
21 |
type = "fixed", |
|
22 |
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}, |
|
23 |
}, |
|
24 |
on_construct = function(pos) |
|
25 |
local meta = minetest.env:get_meta(pos) |
|
26 |
meta:set_float("technic_hv_power_machine", 1) |
ee5c6c
|
27 |
meta:set_int("HV_EU_supply", 0) |
8e03d7
|
28 |
meta:set_string("infotext", "HV Solar Array") |
R |
29 |
end, |
|
30 |
}) |
|
31 |
|
ee5c6c
|
32 |
minetest.register_craft( |
K |
33 |
{output = 'technic:solar_array_hv 1', |
|
34 |
recipe = { |
|
35 |
{'technic:solar_array_mv', 'technic:solar_array_mv','technic:solar_array_mv'}, |
|
36 |
{'technic:solar_array_mv', 'technic:hv_transformer','technic:solar_array_mv'}, |
|
37 |
{'default:steel_ingot', 'technic:hv_cable', 'default:steel_ingot'}, |
|
38 |
} |
|
39 |
}) |
8e03d7
|
40 |
|
R |
41 |
minetest.register_abm( |
ee5c6c
|
42 |
{nodenames = {"technic:solar_array_hv"}, |
K |
43 |
interval = 1, |
|
44 |
chance = 1, |
|
45 |
action = function(pos, node, active_object_count, active_object_count_wider) |
8e03d7
|
46 |
-- The action here is to make the solar array produce power |
R |
47 |
-- Power is dependent on the light level and the height above ground |
|
48 |
-- 130m and above is optimal as it would be above cloud level. |
|
49 |
-- Height gives 1/4 of the effect, light 3/4. Max. effect is 2880EU for the array. |
|
50 |
-- There are many ways to cheat by using other light sources like lamps. |
|
51 |
-- As there is no way to determine if light is sunlight that is just a shame. |
|
52 |
-- To take care of some of it solar panels do not work outside daylight hours or if |
|
53 |
-- built below -10m |
|
54 |
local pos1={} |
|
55 |
pos1.y=pos.y+1 |
|
56 |
pos1.x=pos.x |
|
57 |
pos1.z=pos.z |
|
58 |
local light = minetest.env:get_node_light(pos1, nil) |
|
59 |
local time_of_day = minetest.env:get_timeofday() |
|
60 |
local meta = minetest.env:get_meta(pos) |
|
61 |
if light == nil then light = 0 end |
|
62 |
-- turn on array only during day time and if sufficient light |
|
63 |
-- I know this is counter intuitive when cheating by using other light sources. |
|
64 |
if light >= 12 and time_of_day>=0.24 and time_of_day<=0.76 and pos.y > -10 then |
ee5c6c
|
65 |
local charge_to_give = math.floor(light*(light*9.6+pos1.y/130*48)) |
K |
66 |
if charge_to_give<0 then charge_to_give=0 end |
|
67 |
if charge_to_give>160 then charge_to_give=160 end |
|
68 |
meta:set_string("infotext", "Solar Array is active ("..charge_to_give.."EU)") |
|
69 |
meta:set_int("HV_EU_supply", charge_to_give) |
8e03d7
|
70 |
else |
ee5c6c
|
71 |
meta:set_string("infotext", "Solar Array is inactive"); |
K |
72 |
meta:set_int("HV_EU_supply", 0) |
8e03d7
|
73 |
end |
ee5c6c
|
74 |
end, |
K |
75 |
}) |
8e03d7
|
76 |
|
ee5c6c
|
77 |
technic.register_HV_machine ("technic:solar_array_hv","PR") |
19c9a0
|
78 |
|