Kevin Zheng
2013-11-28 7cfb3874a381d5923611242b4cf7756d86049def
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 = {
68ea0a 16         {'',                           'technic:motor',              ''},
Z 17         {'technic:carbon_steel_ingot', 'technic:carbon_steel_block', 'technic:carbon_steel_ingot'},
18         {'',                           'technic:mv_cable0',          ''},
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
36     for i = 1, 20 do
37         local node = minetest.get_node({x=pos.x, y=pos.y-i, z=pos.z})
38         if node.name ~= "technic:wind_mill_frame" then
39             return false
40         end
41     end
42     return true
43 end
44
45 local run = function(pos, node)
46     local meta = minetest.get_meta(pos)
47     local machine_name = S("Wind %s Generator"):format("MV")
48     local power = math.min(pos.y * 100, 5000)
49
50     if not check_wind_mill(pos) then
51         meta:set_int("MV_EU_supply", 0)
52         meta:set_string("infotext", S("%s Improperly Placed"):format(machine_name))
53         return
54     else
55         meta:set_int("MV_EU_supply", power)
56     end
57
58     meta:set_string("infotext", machine_name.." ("..power.."EU)")
59 end
60
ee0765 61 minetest.register_node("technic:wind_mill", {
7c4b70 62     description = S("Wind %s Generator"):format("MV"),
68b7bc 63     tiles = {"technic_carbon_steel_block.png"},
ee0765 64     paramtype2 = "facedir",
563a4c 65     groups = {cracky=1, technic_machine=1},
ee0765 66     sounds = default.node_sound_stone_defaults(),
S 67     drawtype = "nodebox",
68     paramtype = "light",
69     node_box = {
70         type = "fixed",
71         fixed = {
72             {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, -- Main box
73             {-0.1, -0.1, -0.5,  0.1, 0.1, -0.6}, -- Shaft
74             {-0.1, -1,   -0.6,  0.1, 1,   -0.7}, -- Vertical blades
75             {-1,   -0.1, -0.6,  1,   0.1, -0.7}, -- Horizontal blades
76         }
77     },
78     on_construct = function(pos)
79         local meta = minetest.get_meta(pos)
7c4b70 80         meta:set_string("infotext", S("Wind %s Generator"):format("MV"))
ee0765 81         meta:set_int("MV_EU_supply", 0)
563a4c 82     end,
N 83     technic_run = run,
ee0765 84 })
S 85
86 technic.register_machine("MV", "technic:wind_mill", technic.producer)
87