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