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 = { |
|
7 |
{'default:steel_ingot', '', 'default:steel_ingot'}, |
|
8 |
{'', 'default:steel_ingot', ''}, |
|
9 |
{'default:steel_ingot', '', 'default:steel_ingot'}, |
|
10 |
} |
|
11 |
}) |
|
12 |
|
|
13 |
minetest.register_craft({ |
|
14 |
output = 'technic:wind_mill', |
|
15 |
recipe = { |
|
16 |
{'', 'default:steel_ingot', ''}, |
|
17 |
{'default:steel_ingot', 'technic:motor', 'default:steel_ingot'}, |
|
18 |
{'', 'default:steelblock', ''}, |
|
19 |
} |
|
20 |
}) |
|
21 |
|
|
22 |
minetest.register_node("technic:wind_mill_frame", { |
be2f30
|
23 |
description = S("Wind Mill Frame"), |
ee0765
|
24 |
drawtype = "glasslike_framed", |
S |
25 |
tiles = {"default_steel_block.png", "default_glass.png"}, |
|
26 |
sunlight_propagates = true, |
|
27 |
groups = {cracky=3}, |
|
28 |
sounds = default.node_sound_stone_defaults(), |
|
29 |
paramtype = "light", |
|
30 |
}) |
|
31 |
|
|
32 |
minetest.register_node("technic:wind_mill", { |
be2f30
|
33 |
description = S("Wind Mill"), |
ee0765
|
34 |
tiles = {"default_steel_block.png"}, |
S |
35 |
paramtype2 = "facedir", |
|
36 |
groups = {cracky=1}, |
|
37 |
sounds = default.node_sound_stone_defaults(), |
|
38 |
drawtype = "nodebox", |
|
39 |
paramtype = "light", |
|
40 |
node_box = { |
|
41 |
type = "fixed", |
|
42 |
fixed = { |
|
43 |
{-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Main box |
|
44 |
{-0.1, -0.1, -0.5, 0.1, 0.1, -0.6}, -- Shaft |
|
45 |
{-0.1, -1, -0.6, 0.1, 1, -0.7}, -- Vertical blades |
|
46 |
{-1, -0.1, -0.6, 1, 0.1, -0.7}, -- Horizontal blades |
|
47 |
} |
|
48 |
}, |
|
49 |
on_construct = function(pos) |
|
50 |
local meta = minetest.get_meta(pos) |
be2f30
|
51 |
meta:set_string("infotext", S("Wind Mill")) |
ee0765
|
52 |
meta:set_int("MV_EU_supply", 0) |
S |
53 |
end, |
|
54 |
}) |
|
55 |
|
|
56 |
local function check_wind_mill(pos) |
|
57 |
if pos.y < 30 then |
|
58 |
return false |
|
59 |
end |
|
60 |
for i = 1, 20 do |
|
61 |
local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z}) |
|
62 |
if node.name ~= "technic:wind_mill_frame" then |
|
63 |
return false |
|
64 |
end |
|
65 |
end |
|
66 |
return true |
|
67 |
end |
|
68 |
|
|
69 |
minetest.register_abm({ |
|
70 |
nodenames = {"technic:wind_mill"}, |
|
71 |
interval = 1, |
|
72 |
chance = 1, |
|
73 |
action = function(pos, node, active_object_count, active_object_count_wider) |
|
74 |
local meta = minetest.get_meta(pos) |
be2f30
|
75 |
local machine_name = S("Wind Mill") |
ee0765
|
76 |
local power = math.min(pos.y * 100, 5000) |
S |
77 |
|
|
78 |
if not check_wind_mill(pos) then |
|
79 |
meta:set_int("MV_EU_supply", 0) |
be2f30
|
80 |
meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name)) |
ee0765
|
81 |
return |
S |
82 |
else |
|
83 |
meta:set_int("MV_EU_supply", power) |
|
84 |
end |
|
85 |
|
be2f30
|
86 |
meta:set_string("infotext", machine_name.." ("..power.."EU)") |
ee0765
|
87 |
end |
S |
88 |
}) |
|
89 |
|
|
90 |
technic.register_machine("MV", "technic:wind_mill", technic.producer) |
|
91 |
|