Damage anvil after falling
[MineClone/MineClone2.git] / mods / ITEMS / REDSTONE / mesecons_solarpanel / init.lua
blob1c66b6191045886c59270736d1a6a923b0c35fbc
1 local boxes = { -8/16, -8/16, -8/16, 8/16, -2/16, 8/16 }
3 -- Daylight Sensor
4 minetest.register_node("mesecons_solarpanel:solar_panel_on", {
5 drawtype = "nodebox",
6 tiles = { "jeija_solar_panel.png","jeija_solar_panel.png","jeija_solar_panel_side.png",
7 "jeija_solar_panel_side.png","jeija_solar_panel_side.png","jeija_solar_panel_side.png", },
8 wield_image = "jeija_solar_panel.png",
9 wield_scale = { x=1, y=1, z=3 },
10 paramtype = "light",
11 is_ground_content = false,
12 selection_box = {
13 type = "fixed",
14 fixed = boxes
16 node_box = {
17 type = "fixed",
18 fixed = boxes
20 drop = "mesecons_solarpanel:solar_panel_off",
21 description="Daylight Sensor",
22 _doc_items_create_entry = false,
23 groups = {handy=1,axey=1, not_in_creative_inventory = 1, material_wood=1},
24 sounds = mcl_sounds.node_sound_glass_defaults(),
25 mesecons = {receptor = {
26 state = mesecon.state.on,
27 rules = mesecon.rules.pplate,
28 }},
29 on_rightclick = function(pos, node, clicker, pointed_thing)
30 minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_off"})
31 mesecon.receptor_off(pos, mesecon.rules.pplate)
32 end,
33 _mcl_blast_resistance = 1,
34 _mcl_hardness = 0.2,
37 minetest.register_node("mesecons_solarpanel:solar_panel_off", {
38 drawtype = "nodebox",
39 tiles = { "jeija_solar_panel.png","jeija_solar_panel.png","jeija_solar_panel_side.png",
40 "jeija_solar_panel_side.png","jeija_solar_panel_side.png","jeija_solar_panel_side.png", },
41 wield_image = "jeija_solar_panel.png",
42 wield_scale = { x=1, y=1, z=3 },
43 paramtype = "light",
44 is_ground_content = false,
45 selection_box = {
46 type = "fixed",
47 fixed = boxes
49 node_box = {
50 type = "fixed",
51 fixed = boxes
53 groups = {handy=1,axey=1, material_wood=1},
54 description="Daylight Sensor",
55 _doc_items_longdesc = "Daylight sensors are redstone components which provide redstone power when they are in sunlight and no power otherwise. They can also be inverted.",
56 _doc_items_usagehelp = "Rightclick the daylight sensor to turn it into an inverted daylight sensor, which supplies redstone energy when it is in moonlight.",
57 sounds = mcl_sounds.node_sound_glass_defaults(),
58 mesecons = {receptor = {
59 state = mesecon.state.off,
60 rules = mesecon.rules.pplate,
61 }},
62 on_rightclick = function(pos, node, clicker, pointed_thing)
63 minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_inverted_on"})
64 mesecon.receptor_on(pos, mesecon.rules.pplate)
65 end,
66 _mcl_blast_resistance = 1,
67 _mcl_hardness = 0.2,
70 minetest.register_craft({
71 output = 'mesecons_solarpanel:solar_panel_off',
72 recipe = {
73 {'mcl_core:glass', 'mcl_core:glass', 'mcl_core:glass'},
74 {'mcl_nether:quartz', 'mcl_nether:quartz', 'mcl_nether:quartz'},
75 {'group:wood_slab', 'group:wood_slab', 'group:wood_slab'},
79 minetest.register_abm({
80 label = "Daylight turns on solar panels",
81 nodenames = {"mesecons_solarpanel:solar_panel_off"},
82 interval = 1,
83 chance = 1,
84 action = function(pos, node, active_object_count, active_object_count_wider)
85 local light = minetest.get_node_light(pos, nil)
87 if light >= 12 and minetest.get_timeofday() > 0.2 and minetest.get_timeofday() < 0.8 then
88 minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_on", param2=node.param2})
89 mesecon.receptor_on(pos, mesecon.rules.pplate)
90 end
91 end,
94 minetest.register_abm({
95 label = "Darkness turns off solar panels",
96 nodenames = {"mesecons_solarpanel:solar_panel_on"},
97 interval = 1,
98 chance = 1,
99 action = function(pos, node, active_object_count, active_object_count_wider)
100 local light = minetest.get_node_light(pos, nil)
102 if light < 12 then
103 minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_off", param2=node.param2})
104 mesecon.receptor_off(pos, mesecon.rules.pplate)
106 end,
109 --- Inverted Daylight Sensor
111 minetest.register_node("mesecons_solarpanel:solar_panel_inverted_on", {
112 drawtype = "nodebox",
113 tiles = { "jeija_solar_panel_inverted.png","jeija_solar_panel_inverted.png","jeija_solar_panel_side.png",
114 "jeija_solar_panel_side.png","jeija_solar_panel_side.png","jeija_solar_panel_side.png", },
115 wield_image = "jeija_solar_panel_inverted.png",
116 wield_scale = { x=1, y=1, z=3 },
117 paramtype = "light",
118 is_ground_content = false,
119 selection_box = {
120 type = "fixed",
121 fixed = boxes
123 node_box = {
124 type = "fixed",
125 fixed = boxes
127 drop = "mesecons_solarpanel:solar_panel_off",
128 groups = {handy=1,axey=1, not_in_creative_inventory = 1, material_wood=1},
129 description="Inverted Daylight Sensor",
130 _doc_items_create_entry = false,
131 sounds = mcl_sounds.node_sound_glass_defaults(),
132 mesecons = {receptor = {
133 state = mesecon.state.on,
134 rules = mesecon.rules.pplate,
136 on_rightclick = function(pos, node, clicker, pointed_thing)
137 minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_off"})
138 mesecon.receptor_off(pos, mesecon.rules.pplate)
139 end,
140 _mcl_blast_resistance = 1,
141 _mcl_hardness = 0.2,
144 minetest.register_node("mesecons_solarpanel:solar_panel_inverted_off", {
145 drawtype = "nodebox",
146 tiles = { "jeija_solar_panel_inverted.png","jeija_solar_panel_inverted.png","jeija_solar_panel_side.png",
147 "jeija_solar_panel_side.png","jeija_solar_panel_side.png","jeija_solar_panel_side.png", },
148 wield_image = "jeija_solar_panel_inverted.png",
149 wield_scale = { x=1, y=1, z=3 },
150 paramtype = "light",
151 is_ground_content = false,
152 selection_box = {
153 type = "fixed",
154 fixed = boxes
156 node_box = {
157 type = "fixed",
158 fixed = boxes
160 drop = "mesecons_solarpanel:solar_panel_off",
161 groups = {handy=1,axey=1, not_in_creative_inventory=1, material_wood=1},
162 description="Inverted Daylight Sensor",
163 _doc_items_longdesc = "An inverted daylight sensor is a variant of the daylight sensor. It is a redstone component which provides redstone power when it in moonlight and no power otherwise. It can turned back into an ordinary daylight sensor.",
164 _doc_items_usagehelp = "Rightclick the daylight sensor to turn it into a daylight sensor.",
165 sounds = mcl_sounds.node_sound_glass_defaults(),
166 mesecons = {receptor = {
167 state = mesecon.state.off,
168 rules = mesecon.rules.pplate,
170 on_rightclick = function(pos, node, clicker, pointed_thing)
171 minetest.swap_node(pos, {name = "mesecons_solarpanel:solar_panel_on"})
172 mesecon.receptor_on(pos, mesecon.rules.pplate)
173 end,
174 _mcl_blast_resistance = 1,
175 _mcl_hardness = 0.2,
178 minetest.register_abm({
179 label = "Darkness turns on inverted solar panels",
180 nodenames = {"mesecons_solarpanel:solar_panel_inverted_off"},
181 interval = 1,
182 chance = 1,
183 action = function(pos, node, active_object_count, active_object_count_wider)
184 local light = minetest.get_node_light(pos, nil)
186 if light < 12 then
187 minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_on", param2=node.param2})
188 mesecon.receptor_on(pos, mesecon.rules.pplate)
190 end,
193 minetest.register_abm({
194 label = "Daylight turns off inverted solar panels",
195 nodenames = {"mesecons_solarpanel:solar_panel_inverted_on"},
196 interval = 1,
197 chance = 1,
198 action = function(pos, node, active_object_count, active_object_count_wider)
199 local light = minetest.get_node_light(pos, nil)
201 if light >= 12 and minetest.get_timeofday() > 0.8 and minetest.get_timeofday() < 0.2 then
202 minetest.set_node(pos, {name="mesecons_solarpanel:solar_panel_inverted_off", param2=node.param2})
203 mesecon.receptor_off(pos, mesecon.rules.pplate)
205 end,
208 minetest.register_craft({
209 type = "fuel",
210 recipe = "mesecons_solarpanel:solar_panel_off",
211 burntime = 15
214 if minetest.get_modpath("doc") then
215 doc.add_entry_alias("nodes", "mesecons_solarpanel:solar_panel_off", "nodes", "mesecons_solarpanel:solar_panel_on")
216 doc.add_entry_alias("nodes", "mesecons_solarpanel:solar_panel_inverted_off", "nodes", "mesecons_solarpanel:solar_panel_inverted_on")