Merge pull request #3 from Athemis/master
[MineClone.git] / mods / farming / pumpkin.lua
blob64ab59f4d466bdfc7ada66758fbe7f2b6ee13aa0
1 LIGHT_MAX = 15
3 minetest.register_craftitem("farming:pumpkin_seed", {
4 description = "Pumpkin Seed",
5 stack_max = 64,
6 inventory_image = "farming_pumpkin_seed.png",
7 on_place = function(itemstack, placer, pointed_thing)
8 local above = minetest.env:get_node(pointed_thing.above)
9 if above.name == "air" then
10 above.name = "farming:pumpkin_1"
11 minetest.env:set_node(pointed_thing.above, above)
12 itemstack:take_item(1)
13 return itemstack
14 end
15 end
18 minetest.register_node("farming:pumpkin_1", {
19 paramtype = "light",
20 walkable = false,
21 drawtype = "plantlike",
22 sunlight_propagates = true,
23 drop = "",
24 tiles = {"farming_tige_1.png"},
25 selection_box = {
26 type = "fixed",
27 fixed = {
28 {-0.5, -0.5, -0.5, 0.5, -0.5+6/16, 0.5}
31 groups = {snappy=3, flammable=2, not_in_creative_inventory=1 ,dig_by_water=1},
32 sounds = default.node_sound_leaves_defaults(),
35 minetest.register_node("farming:pumpkin_2", {
36 paramtype = "light",
37 walkable = false,
38 drawtype = "plantlike",
39 sunlight_propagates = true,
40 drop = "",
41 tiles = {"farming_tige_2.png"},
42 selection_box = {
43 type = "fixed",
44 fixed = {
45 {-0.5, -0.5, -0.5, 0.5, -0.5+9/16, 0.5}
48 groups = {snappy=3, flammable=2, not_in_creative_inventory=1 ,dig_by_water=1},
49 sounds = default.node_sound_leaves_defaults(),
53 minetest.register_node("farming:pumpkin_face", {
54 description = "Pumpkin Face",
55 stack_max = 64,
56 paramtype2 = "facedir",
57 tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face.png"},
58 groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
59 after_dig_node = function(pos, oldnode, oldmetadata, user)
60 local have_change = 0
61 for x=-1,1 do
62 local p = {x=pos.x+x, y=pos.y, z=pos.z}
63 local n = minetest.env:get_node(p)
64 if string.find(n.name, "pumpkintige_linked_") and have_change == 0 then
65 have_change = 1
66 minetest.env:add_node(p, {name="farming:pumpkintige_unconnect"})
67 end
68 end
69 if have_change == 0 then
70 for z=-1,1 do
71 p = {x=pos.x, y=pos.y, z=pos.z+z}
72 local n = minetest.env:get_node(p)
73 if string.find(n.name, "pumpkintige_linked_") and have_change == 0 then
74 have_change = 1
75 minetest.env:add_node(p, {name="farming:pumpkintige_unconnect"})
76 end
77 end
78 end
79 end
82 minetest.register_node("farming:pumpkintige_unconnect", {
83 paramtype = "light",
84 walkable = false,
85 sunlight_propagates = true,
86 drop = "",
87 drawtype = "plantlike",
88 tiles = {"farming_tige_end.png"},
89 groups = {snappy=3, flammable=2, not_in_creative_inventory=1 ,dig_by_water=1},
90 sounds = default.node_sound_leaves_defaults(),
94 minetest.register_node("farming:pumpkintige_linked_r", {
95 paramtype = "light",
96 sunlight_propagates = true,
97 walkable = false,
98 drop = "",
99 drawtype = "nodebox",
100 paramtype = "light",
101 paramtype2 = "wallmounted",
102 legacy_wallmounted = true,
103 node_box = {
104 type = "fixed",
105 fixed = {
106 {-0.5, -0.5, 0, 0.5, 0.5, 0}, -- NodeBox1
109 selection_box = {
110 type = "fixed",
111 fixed = {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2}
113 tiles = {
114 "farming_tige_connnect.png", --top
115 "farming_tige_connnect.png", -- bottom
116 "farming_tige_connnect.png", -- right
117 "farming_tige_connnect.png", -- left
118 "farming_tige_connnect.png", -- back
119 "farming_tige_connnect.png^[transformFX90" --front
121 groups = {snappy=3, flammable=2, not_in_creative_inventory=1 ,dig_by_water=1},
122 sounds = default.node_sound_leaves_defaults(),
125 minetest.register_node("farming:pumpkintige_linked_l", {
126 paramtype = "light",
127 walkable = false,
128 sunlight_propagates = true,
129 drop = "",
130 drawtype = "nodebox",
131 paramtype = "light",
132 paramtype2 = "wallmounted",
133 legacy_wallmounted = true,
134 node_box = {
135 type = "fixed",
136 fixed = {
137 {-0.5, -0.5, 0, 0.5, 0.5, 0}, -- NodeBox1
140 selection_box = {
141 type = "fixed",
142 fixed = {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2}
144 tiles = {
145 "farming_tige_connnect.png", --top
146 "farming_tige_connnect.png", -- bottom
147 "farming_tige_connnect.png", -- right
148 "farming_tige_connnect.png", -- left
149 "farming_tige_connnect.png^[transformFX90", -- back
150 "farming_tige_connnect.png" --front
152 groups = {snappy=3, flammable=2, not_in_creative_inventory=1 ,dig_by_water=1},
153 sounds = default.node_sound_leaves_defaults(),
156 minetest.register_node("farming:pumpkintige_linked_t", {
157 paramtype = "light",
158 walkable = false,
159 sunlight_propagates = true,
160 drop = "",
161 drawtype = "nodebox",
162 paramtype = "light",
163 paramtype2 = "wallmounted",
164 legacy_wallmounted = true,
165 node_box = {
166 type = "fixed",
167 fixed = {
168 {0, -0.5, -0.5, 0, 0.5, 0.5}, -- NodeBox1
171 selection_box = {
172 type = "fixed",
173 fixed = {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2}
175 tiles = {
176 "farming_tige_connnect.png", --top
177 "farming_tige_connnect.png", -- bottom
178 "farming_tige_connnect.png^[transformFX90", -- right
179 "farming_tige_connnect.png", -- left
180 "farming_tige_connnect.png", -- back
181 "farming_tige_connnect.png" --front
183 groups = {snappy=3, flammable=2, not_in_creative_inventory=1 ,dig_by_water=1},
184 sounds = default.node_sound_leaves_defaults(),
187 minetest.register_node("farming:pumpkintige_linked_b", {
188 paramtype = "light",
189 walkable = false,
190 sunlight_propagates = true,
191 drop = "",
192 drawtype = "nodebox",
193 paramtype = "light",
194 paramtype2 = "wallmounted",
195 legacy_wallmounted = true,
196 node_box = {
197 type = "fixed",
198 fixed = {
199 {0, -0.5, -0.5, 0, 0.5, 0.5}, -- NodeBox1
202 selection_box = {
203 type = "fixed",
204 fixed = {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2}
206 tiles = {
207 "farming_tige_connnect.png", --top
208 "farming_tige_connnect.png", -- bottom
209 "farming_tige_connnect.png", -- right
210 "farming_tige_connnect.png^[transformFX90", -- left
211 "farming_tige_connnect.png", -- back
212 "farming_tige_connnect.png" --front
214 groups = {snappy=3, flammable=2, not_in_creative_inventory=1 ,dig_by_water=1},
215 sounds = default.node_sound_leaves_defaults(),
218 farming:add_plant("farming:pumpkintige_unconnect", {"farming:pumpkin_1", "farming:pumpkin_2"}, 80, 20)
221 minetest.register_abm({
222 nodenames = {"farming:pumpkintige_unconnect"},
223 neighbors = {"air"},
224 interval = 30,
225 chance = 15,
226 action = function(pos)
227 local have_change = 0
228 local newpos = {x=pos.x, y=pos.y, z=pos.z}
229 local light = minetest.get_node_light(pos)
230 if light or light > 10 then
231 for x=-1,1 do
232 local p = {x=pos.x+x, y=pos.y-1, z=pos.z}
233 newpos = {x=pos.x+x, y=pos.y, z=pos.z}
234 local n = minetest.env:get_node(p)
235 local nod = minetest.env:get_node(newpos)
236 if n.name=="default:dirt_with_grass" and nod.name=="air" and have_change == 0
237 or n.name=="default:dirt" and nod.name=="air" and have_change == 0
238 or string.find(n.name, "farming:soil") and nod.name=="air" and have_change == 0 then
239 have_change = 1
240 minetest.env:add_node(newpos, {name="farming:pumpkin_face"})
241 if x == 1 then
242 minetest.env:add_node(pos, {name="farming:pumpkintige_linked_r" })
243 else
244 minetest.env:add_node(pos, {name="farming:pumpkintige_linked_l"})
248 if have_change == 0 then
249 for z=-1,1 do
250 p = {x=pos.x, y=pos.y-1, z=pos.z+z}
251 newpos = {x=pos.x, y=pos.y, z=pos.z+z}
252 n = minetest.env:get_node(p)
253 local nod2 = minetest.env:get_node(newpos)
254 if n.name=="default:dirt_with_grass" and nod2.name=="air" and have_change == 0
255 or n.name=="default:dirt" and nod2.name=="air" and have_change == 0
256 or string.find(n.name, "farming:soil") and nod2.name=="air" and have_change == 0 then
257 have_change = 1
258 minetest.env:add_node(newpos, {name="farming:pumpkin_face"})
259 if z == 1 then
260 minetest.env:add_node(pos, {name="farming:pumpkintige_linked_t" })
261 else
262 minetest.env:add_node(pos, {name="farming:pumpkintige_linked_b" })
268 end,
273 minetest.register_node("farming:pumpkin_face_light", {
274 description = "Jack O' Lantern",
275 stack_max = 64,
276 paramtype2 = "facedir",
277 light_source = LIGHT_MAX,
278 tiles = {"farming_pumpkin_top.png", "farming_pumpkin_top.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_side.png", "farming_pumpkin_face_light.png"},
279 groups = {choppy=2, oddly_breakable_by_hand=2, flammable=2},
282 minetest.register_craft({
283 type = "shapeless",
284 output = "farming:pumpkin_face_light",
285 recipe = {"farming:pumpkin_face", "default:torch"}
288 minetest.register_craft({
289 type = "shapeless",
290 output = "farming:pumpkin_seed 4",
291 recipe = {"farming:pumpkin_face"}
295 -- ========= FUEL =========
296 minetest.register_craft({
297 type = "fuel",
298 recipe = "farming:pumpkin_seed",
299 burntime = 1