commit | author | age
|
ee0765
|
1 |
|
be2f30
|
2 |
local S = technic.getter |
S |
3 |
|
ee0765
|
4 |
minetest.register_craft({ |
S |
5 |
output = 'technic:wind_mill_frame 5', |
|
6 |
recipe = { |
68b7bc
|
7 |
{'technic:carbon_steel_ingot', '', 'technic:carbon_steel_ingot'}, |
Z |
8 |
{'', 'technic:carbon_steel_ingot', ''}, |
|
9 |
{'technic:carbon_steel_ingot', '', 'technic:carbon_steel_ingot'}, |
ee0765
|
10 |
} |
S |
11 |
}) |
|
12 |
|
|
13 |
minetest.register_craft({ |
|
14 |
output = 'technic:wind_mill', |
|
15 |
recipe = { |
44cb8d
|
16 |
{'', 'basic_materials:motor', ''}, |
68ea0a
|
17 |
{'technic:carbon_steel_ingot', 'technic:carbon_steel_block', 'technic:carbon_steel_ingot'}, |
83c649
|
18 |
{'', 'technic:mv_cable', ''}, |
ee0765
|
19 |
} |
S |
20 |
}) |
|
21 |
|
|
22 |
minetest.register_node("technic:wind_mill_frame", { |
be2f30
|
23 |
description = S("Wind Mill Frame"), |
ee0765
|
24 |
drawtype = "glasslike_framed", |
68b7bc
|
25 |
tiles = {"technic_carbon_steel_block.png", "default_glass.png"}, |
ee0765
|
26 |
sunlight_propagates = true, |
S |
27 |
groups = {cracky=3}, |
|
28 |
sounds = default.node_sound_stone_defaults(), |
|
29 |
paramtype = "light", |
|
30 |
}) |
|
31 |
|
563a4c
|
32 |
local function check_wind_mill(pos) |
N |
33 |
if pos.y < 30 then |
|
34 |
return false |
|
35 |
end |
d39797
|
36 |
pos = {x=pos.x, y=pos.y, z=pos.z} |
563a4c
|
37 |
for i = 1, 20 do |
d39797
|
38 |
pos.y = pos.y - 1 |
T |
39 |
local node = minetest.get_node_or_nil(pos) |
|
40 |
if not node then |
|
41 |
-- we reached CONTENT_IGNORE, we can assume, that nothing changed |
|
42 |
-- as the user will have to load the block to change it |
|
43 |
return |
|
44 |
end |
563a4c
|
45 |
if node.name ~= "technic:wind_mill_frame" then |
N |
46 |
return false |
|
47 |
end |
|
48 |
end |
|
49 |
return true |
|
50 |
end |
|
51 |
|
|
52 |
local run = function(pos, node) |
|
53 |
local meta = minetest.get_meta(pos) |
|
54 |
local machine_name = S("Wind %s Generator"):format("MV") |
|
55 |
|
d39797
|
56 |
local check = check_wind_mill(pos) |
T |
57 |
if check == false then |
563a4c
|
58 |
meta:set_int("MV_EU_supply", 0) |
N |
59 |
meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name)) |
d39797
|
60 |
elseif check == true then |
T |
61 |
local power = math.min(pos.y * 100, 5000) |
563a4c
|
62 |
meta:set_int("MV_EU_supply", power) |
41f175
|
63 |
meta:set_string("infotext", S("@1 (@2)", machine_name, |
H |
64 |
technic.EU_string(power))) |
563a4c
|
65 |
end |
d39797
|
66 |
-- check == nil: assume nothing has changed |
563a4c
|
67 |
end |
N |
68 |
|
ee0765
|
69 |
minetest.register_node("technic:wind_mill", { |
7c4b70
|
70 |
description = S("Wind %s Generator"):format("MV"), |
68b7bc
|
71 |
tiles = {"technic_carbon_steel_block.png"}, |
ee0765
|
72 |
paramtype2 = "facedir", |
83c649
|
73 |
groups = {cracky=1, technic_machine=1, technic_mv=1}, |
S |
74 |
connect_sides = {"top", "bottom", "back", "left", "right"}, |
ee0765
|
75 |
sounds = default.node_sound_stone_defaults(), |
S |
76 |
drawtype = "nodebox", |
|
77 |
paramtype = "light", |
|
78 |
node_box = { |
|
79 |
type = "fixed", |
|
80 |
fixed = { |
|
81 |
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Main box |
|
82 |
{-0.1, -0.1, -0.5, 0.1, 0.1, -0.6}, -- Shaft |
|
83 |
{-0.1, -1, -0.6, 0.1, 1, -0.7}, -- Vertical blades |
|
84 |
{-1, -0.1, -0.6, 1, 0.1, -0.7}, -- Horizontal blades |
|
85 |
} |
|
86 |
}, |
|
87 |
on_construct = function(pos) |
|
88 |
local meta = minetest.get_meta(pos) |
7c4b70
|
89 |
meta:set_string("infotext", S("Wind %s Generator"):format("MV")) |
ee0765
|
90 |
meta:set_int("MV_EU_supply", 0) |
563a4c
|
91 |
end, |
N |
92 |
technic_run = run, |
ee0765
|
93 |
}) |
S |
94 |
|
|
95 |
technic.register_machine("MV", "technic:wind_mill", technic.producer) |
|
96 |
|