1 minetest
.register_node("farming:melon", {
3 paramtype2
= "facedir",
5 tiles
= {"farming_melon_top.png", "farming_melon_top.png", "farming_melon_side.png", "farming_melon_side.png", "farming_melon_side.png", "farming_melon_side.png"},
6 groups
= {choppy
=2, oddly_breakable_by_hand
=2},
10 { items
= {'farming:melon_item 3'} },
11 { items
= {'farming:melon_item 4'}, rarity
= 2 },
12 { items
= {'farming:melon_item 5'}, rarity
= 5 },
13 { items
= {'farming:melon_item 6'}, rarity
= 10 },
14 { items
= {'farming:melon_item 7'}, rarity
= 14 }
17 after_dig_node
= function(pos
, oldnode
, oldmetadata
, user
)
20 local p
= {x
=pos
.x
+x
, y
=pos
.y
, z
=pos
.z
}
21 local n
= minetest
.env
:get_node(p
)
22 if string.find(n
.name
, "melontige_linked_") and have_change
== 0 then
24 minetest
.env
:add_node(p
, {name
="farming:melontige_unconnect"})
27 if have_change
== 0 then
29 p
= {x
=pos
.x
, y
=pos
.y
, z
=pos
.z
+z
}
30 local n
= minetest
.env
:get_node(p
)
31 if string.find(n
.name
, "melontige_linked_") and have_change
== 0 then
33 minetest
.env
:add_node(p
, {name
="farming:melontige_unconnect"})
40 minetest
.register_node("farming:melontige_1", {
43 drawtype
= "plantlike",
44 sunlight_propagates
= true,
46 tiles
= {"farming_tige_1.png"},
50 {-0.5, -0.5, -0.5, 0.5, -0.5+6/16, 0.5}
53 groups
= {snappy
=3, flammable
=2, not_in_creative_inventory
=1 ,dig_by_water
=1},
54 sounds
= default
.node_sound_leaves_defaults(),
57 minetest
.register_node("farming:melontige_2", {
60 drawtype
= "plantlike",
61 sunlight_propagates
= true,
63 tiles
= {"farming_tige_2.png"},
67 {-0.5, -0.5, -0.5, 0.5, -0.5+9/16, 0.5}
70 groups
= {snappy
=3, flammable
=2, not_in_creative_inventory
=1 ,dig_by_water
=1},
71 sounds
= default
.node_sound_leaves_defaults(),
74 minetest
.register_node("farming:melontige_unconnect", {
77 sunlight_propagates
= true,
79 drawtype
= "plantlike",
80 tiles
= {"farming_tige_end.png"},
81 groups
= {snappy
=3, flammable
=2, not_in_creative_inventory
=1 ,dig_by_water
=1},
82 sounds
= default
.node_sound_leaves_defaults(),
85 minetest
.register_node("farming:melontige_linked_r", {
87 sunlight_propagates
= true,
92 paramtype2
= "wallmounted",
93 legacy_wallmounted
= true,
97 {-0.5, -0.5, 0, 0.5, 0.5, 0}, -- NodeBox1
102 fixed
= {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2}
105 "farming_tige_connnect.png", --top
106 "farming_tige_connnect.png", -- bottom
107 "farming_tige_connnect.png", -- right
108 "farming_tige_connnect.png", -- left
109 "farming_tige_connnect.png", -- back
110 "farming_tige_connnect.png^[transformFX90" --front
112 groups
= {snappy
=3, flammable
=2, not_in_creative_inventory
=1 ,dig_by_water
=1},
113 sounds
= default
.node_sound_leaves_defaults(),
116 minetest
.register_node("farming:melontige_linked_l", {
119 sunlight_propagates
= true,
121 drawtype
= "nodebox",
123 paramtype2
= "wallmounted",
124 legacy_wallmounted
= true,
128 {-0.5, -0.5, 0, 0.5, 0.5, 0}, -- NodeBox1
133 fixed
= {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2}
136 "farming_tige_connnect.png", --top
137 "farming_tige_connnect.png", -- bottom
138 "farming_tige_connnect.png", -- right
139 "farming_tige_connnect.png", -- left
140 "farming_tige_connnect.png^[transformFX90", -- back
141 "farming_tige_connnect.png" --front
143 groups
= {snappy
=3, flammable
=2, not_in_creative_inventory
=1 ,dig_by_water
=1},
144 sounds
= default
.node_sound_leaves_defaults(),
147 minetest
.register_node("farming:melontige_linked_t", {
150 sunlight_propagates
= true,
152 drawtype
= "nodebox",
154 paramtype2
= "wallmounted",
155 legacy_wallmounted
= true,
159 {0, -0.5, -0.5, 0, 0.5, 0.5}, -- NodeBox1
164 fixed
= {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2}
167 "farming_tige_connnect.png", --top
168 "farming_tige_connnect.png", -- bottom
169 "farming_tige_connnect.png^[transformFX90", -- right
170 "farming_tige_connnect.png", -- left
171 "farming_tige_connnect.png", -- back
172 "farming_tige_connnect.png" --front
174 groups
= {snappy
=3, flammable
=2, not_in_creative_inventory
=1 ,dig_by_water
=1},
175 sounds
= default
.node_sound_leaves_defaults(),
178 minetest
.register_node("farming:melontige_linked_b", {
181 sunlight_propagates
= true,
183 drawtype
= "nodebox",
185 paramtype2
= "wallmounted",
186 legacy_wallmounted
= true,
190 {0, -0.5, -0.5, 0, 0.5, 0.5}, -- NodeBox1
195 fixed
= {-0.2, -0.5, -0.2, 0.2, 0.2, 0.2}
198 "farming_tige_connnect.png", --top
199 "farming_tige_connnect.png", -- bottom
200 "farming_tige_connnect.png", -- right
201 "farming_tige_connnect.png^[transformFX90", -- left
202 "farming_tige_connnect.png", -- back
203 "farming_tige_connnect.png" --front
205 groups
= {snappy
=3, flammable
=2, not_in_creative_inventory
=1 ,dig_by_water
=1},
206 sounds
= default
.node_sound_leaves_defaults(),
209 minetest
.register_craftitem("farming:melon_seed", {
210 description
= "Melon seed",
212 inventory_image
= "farming_melon_seed.png",
213 on_place
= function(itemstack
, placer
, pointed_thing
)
214 return farming
:place_seed(itemstack
, placer
, pointed_thing
, "farming:melontige_1")
218 minetest
.register_craftitem("farming:melon_item", {
219 description
= "Melon",
221 inventory_image
= "farming_melon.png",
222 on_use
= minetest
.item_eat(2),
225 minetest
.register_craftitem("farming:melon_item_speckled", {
226 description
= "Melon Speckled",
228 inventory_image
= "farming_melon_speckled.png",
231 minetest
.register_abm({
232 nodenames
= {"farming:melontige_unconnect"},
236 action
= function(pos
)
237 local have_change
= 0
238 local newpos
= {x
=pos
.x
, y
=pos
.y
, z
=pos
.z
}
239 local light
= minetest
.get_node_light(pos
)
240 if light
or light
> 10 then
242 local p
= {x
=pos
.x
+x
, y
=pos
.y
-1, z
=pos
.z
}
243 newpos
= {x
=pos
.x
+x
, y
=pos
.y
, z
=pos
.z
}
244 local n
= minetest
.env
:get_node(p
)
245 local nod
= minetest
.env
:get_node(newpos
)
246 if n
.name
=="default:dirt_with_grass" and nod
.name
=="air" and have_change
== 0
247 or n
.name
=="default:dirt" and nod
.name
=="air" and have_change
== 0
248 or string.find(n
.name
, "farming:soil") and nod
.name
=="air" and have_change
== 0 then
250 minetest
.env
:add_node(newpos
, {name
="farming:melon"})
252 minetest
.env
:add_node(pos
, {name
="farming:melontige_linked_r" })
254 minetest
.env
:add_node(pos
, {name
="farming:melontige_linked_l"})
258 if have_change
== 0 then
260 p
= {x
=pos
.x
, y
=pos
.y
-1, z
=pos
.z
+z
}
261 newpos
= {x
=pos
.x
, y
=pos
.y
, z
=pos
.z
+z
}
262 n
= minetest
.env
:get_node(p
)
263 local nod2
= minetest
.env
:get_node(newpos
)
264 if n
.name
=="default:dirt_with_grass" and nod2
.name
=="air" and have_change
== 0
265 or n
.name
=="default:dirt" and nod2
.name
=="air" and have_change
== 0
266 or string.find(n
.name
, "farming:soil") and nod2
.name
=="air" and have_change
== 0 then
268 minetest
.env
:add_node(newpos
, {name
="farming:melon"})
270 minetest
.env
:add_node(pos
, {name
="farming:melontige_linked_t" })
272 minetest
.env
:add_node(pos
, {name
="farming:melontige_linked_b" })
281 farming
:add_plant("farming:melontige_unconnect", {"farming:melontige_1", "farming:melontige_2"}, 50, 20)
283 minetest
.register_craft({
285 output
= "farming:melon_seed",
286 recipe
= {"farming:melon_item"}
289 minetest
.register_craft({
290 output
= 'farming:melon',
292 {'farming:melon_item', 'farming:melon_item', 'farming:melon_item'},
293 {'farming:melon_item', 'farming:melon_item', 'farming:melon_item'},
294 {'farming:melon_item', 'farming:melon_item', 'farming:melon_item'},