cx384
2024-01-22 a08ba2bb93d7683b619a0e6b0bf00e3afd614ae4
commit | author | age
d62371 1 -- LED
BW 2 -- Intended primarily as a core component for LED lamps.
3
4 local S = technic.getter
5
6 local desc = S("@1 LED", S("LV"))
7 local active_desc = S("@1 Active", desc)
8 local unpowered_desc = S("@1 Unpowered", desc)
9 local demand = 5
10
11
12 local function led_run(pos, node)
13     local meta = minetest.get_meta(pos)
14     local eu_input = meta:get_int("LV_EU_input")
15
16     if eu_input < demand and node.name == "technic:lv_led_active" then
17         technic.swap_node(pos, "technic:lv_led")
18         meta:set_string("infotext", unpowered_desc)
19     elseif eu_input >= demand and node.name == "technic:lv_led" then
20         technic.swap_node(pos, "technic:lv_led_active")
21         meta:set_string("infotext", active_desc)
22     end
23 end
24
4775d9 25 local common_fields = {
d62371 26     drawtype = "nodebox",
BW 27     node_box = {
28         type = "fixed",
29         fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5}
30     },
31     tiles = {
32         "technic_lv_led_top.png",
33         "technic_lv_led.png",
34         "technic_lv_led_side.png",
35         "technic_lv_led_side2.png",
36         "technic_lv_led_side2.png",
37         "technic_lv_led_side2.png",
38     },
4775d9 39
d62371 40     connect_sides = {"front", "back", "left", "right", "top", "bottom"},
BW 41     can_dig = technic.machine_can_dig,
42     technic_run = led_run,
4775d9 43 }
S 44
45 local ndef
46
47 ndef = {
48     description = desc,
49     inventory_image = "technic_lv_led_inv.png",
50     sunlight_propagates = true,
51     groups = {cracky = 2, technic_machine = 1, technic_lv = 1},
52
d62371 53     on_construct = function(pos)
BW 54         local meta = minetest.get_meta(pos)
55         meta:set_string("infotext", desc)
56         meta:set_int("LV_EU_demand", demand)
57     end,
4775d9 58 }
d62371 59
4775d9 60 for k, v in pairs(common_fields) do
S 61     ndef[k] = v
62 end
63
64 minetest.register_node("technic:lv_led", ndef)
65
66
67 ndef = {
d62371 68     description = active_desc,
BW 69     paramtype = "light",
70     light_source = 9,
71     drop = "technic:lv_led",
72     groups = {cracky = 2, technic_machine = 1, technic_lv = 1, not_in_creative_inventory = 1},
73     technic_on_disable = function(pos)
74         technic.swap_node(pos, "technic:lv_led")
75     end,
4775d9 76 }
S 77
78 for k, v in pairs(common_fields) do
79     ndef[k] = v
80 end
81
82 minetest.register_node("technic:lv_led_active", ndef)
83
d62371 84
BW 85 technic.register_machine("LV", "technic:lv_led", technic.receiver)
86 technic.register_machine("LV", "technic:lv_led_active", technic.receiver)
87
88 minetest.register_craft({
89     output = "technic:lv_led 2",
90     recipe = {
91         {"", "homedecor:plastic_sheeting", ""},
92         {"homedecor:plastic_sheeting", "technic:doped_silicon_wafer", "homedecor:plastic_sheeting"},
93         {"", "technic:fine_silver_wire", ""},
94     }
95 })