1 local S
= minetest
.get_translator("flowers_plus")
3 -- This file supplies a few additional plants and some related crafts
4 -- for the plantlife modpack. Last revision: 2013-04-24
10 local SPAWN_DELAY
= 1000
11 local SPAWN_CHANCE
= 200
12 local flowers_seed_diff
= 329
13 local lilies_max_count
= 12
14 local lilies_rarity
= 33
15 local seaweed_max_count
= 20
16 local seaweed_rarity
= 33
18 local lilypads_max_count
= {}
19 local lilypads_rarity
= {}
20 -- register the various rotations of waterlilies
25 { "225", "22.5" , 2 },
27 { "675", "67.5" , 4 },
28 { "s1" , "small_1" , 5 },
29 { "s2" , "small_2" , 6 },
30 { "s3" , "small_3" , 7 },
31 { "s4" , "small_4" , 8 },
35 for i
in ipairs(lilies_list
) do
38 local lily_groups
= {snappy
= 3,flammable
=2,waterlily
=1}
41 if lilies_list
[i
][1] ~= nil then
42 deg1
= "_"..lilies_list
[i
][1]
43 deg2
= "_"..lilies_list
[i
][2]
44 lily_groups
= { snappy
= 3,flammable
=2,waterlily
=1, not_in_creative_inventory
=1 }
48 minetest
.register_node(":flowers:waterlily"..deg1
, {
49 description
= S("Waterlily"),
52 "flowers_waterlily"..deg2
..".png",
53 "flowers_waterlily"..deg2
..".png^[transformFY"
55 inventory_image
= "flowers_waterlily.png",
56 wield_image
= "flowers_waterlily.png",
57 sunlight_propagates
= true,
59 paramtype2
= "facedir",
62 sounds
= hades_sounds
.node_sound_leaves_defaults(),
65 fixed
= { -0.4, -0.5, -0.4, 0.4, -0.45, 0.4 },
69 fixed
= { -0.5, -0.49, -0.5, 0.5, -0.49, 0.5 },
74 liquids_pointable
= true,
75 drop
= "flowers:waterlily",
76 on_place
= function(itemstack
, placer
, pointed_thing
)
77 local keys
=placer
:get_player_control()
78 local pt
= pointed_thing
82 local top_pos
= {x
=pt
.under
.x
, y
=pt
.under
.y
+1, z
=pt
.under
.z
}
83 local under_node
= minetest
.get_node(pt
.under
)
84 local above_node
= minetest
.get_node(pt
.above
)
85 local top_node
= minetest
.get_node(top_pos
)
88 if plantslib
:get_nodedef_field(under_node
.name
, "buildable_to") then
89 if under_node
.name
~= "hades_core:water_source" then
91 elseif top_node
.name
~= "hades_core:water_source"
92 and plantslib
:get_nodedef_field(top_node
.name
, "buildable_to") then
97 elseif plantslib
:get_nodedef_field(above_node
.name
, "buildable_to") then
101 if not place_pos
then
105 if not plantslib
:node_is_owned(place_pos
, placer
) then
107 local nodename
= "hades_core:cobble" -- if this block appears, something went....wrong :-)
109 if not keys
["sneak"] then
110 local node
= minetest
.get_node(pt
.under
)
111 local waterlily
= math
.random(1,8)
112 if waterlily
== 1 then
113 nodename
= "flowers:waterlily"
114 elseif waterlily
== 2 then
115 nodename
= "flowers:waterlily_225"
116 elseif waterlily
== 3 then
117 nodename
= "flowers:waterlily_45"
118 elseif waterlily
== 4 then
119 nodename
= "flowers:waterlily_675"
120 elseif waterlily
== 5 then
121 nodename
= "flowers:waterlily_s1"
122 elseif waterlily
== 6 then
123 nodename
= "flowers:waterlily_s2"
124 elseif waterlily
== 7 then
125 nodename
= "flowers:waterlily_s3"
126 elseif waterlily
== 8 then
127 nodename
= "flowers:waterlily_s4"
129 minetest
.add_node(place_pos
, {name
= nodename
, param2
= math
.random(0,3) })
131 local fdir
= minetest
.dir_to_facedir(placer
:get_look_dir())
132 minetest
.add_node(place_pos
, {name
= "flowers:waterlily", param2
= fdir
})
136 if not plantslib
.expect_infinite_stacks
then
137 itemstack
:take_item()
142 on_rotate
= "simple",
147 local algae_list
= { {nil}, {2}, {3}, {4} }
150 for i
in ipairs(algae_list
) do
152 local algae_groups
= {snappy
= 3,flammable
=2,seaweed
=1}
155 if algae_list
[i
][1] ~= nil then
156 num
= "_"..algae_list
[i
][1]
157 algae_groups
= { snappy
= 3,flammable
=2,seaweed
=1, not_in_creative_inventory
=1 }
161 minetest
.register_node(":flowers:seaweed"..num
, {
162 description
= S("Seaweed"),
163 drawtype
= "nodebox",
165 "flowers_seaweed"..num
..".png",
166 "flowers_seaweed"..num
..".png^[transformFY"
168 inventory_image
= "flowers_seaweed_2.png",
169 wield_image
= "flowers_seaweed_2.png",
170 sunlight_propagates
= true,
172 paramtype2
= "facedir",
174 groups
= algae_groups
,
175 sounds
= hades_sounds
.node_sound_leaves_defaults(),
178 fixed
= { -0.4, -0.5, -0.4, 0.4, -0.45, 0.4 },
182 fixed
= { -0.5, -0.49, -0.5, 0.5, -0.49, 0.5 },
187 liquids_pointable
= true,
188 drop
= "flowers:seaweed",
189 on_place
= function(itemstack
, placer
, pointed_thing
)
190 local keys
=placer
:get_player_control()
191 local pt
= pointed_thing
194 local place_pos
= nil
195 local top_pos
= {x
=pt
.under
.x
, y
=pt
.under
.y
+1, z
=pt
.under
.z
}
196 local under_node
= minetest
.get_node(pt
.under
)
197 local above_node
= minetest
.get_node(pt
.above
)
198 local top_node
= minetest
.get_node(top_pos
)
201 if plantslib
:get_nodedef_field(under_node
.name
, "buildable_to") then
202 if under_node
.name
~= "hades_core:water_source" then
204 elseif top_node
.name
~= "hades_core:water_source"
205 and plantslib
:get_nodedef_field(top_node
.name
, "buildable_to") then
210 elseif plantslib
:get_nodedef_field(above_node
.name
, "buildable_to") then
213 if not place_pos
then
217 if not plantslib
:node_is_owned(place_pos
, placer
) then
220 local nodename
= "hades_core:cobble" -- :D
222 if not keys
["sneak"] then
223 local node
= minetest
.get_node(pt
.under
)
224 local seaweed
= math
.random(1,4)
226 nodename
= "flowers:seaweed"
227 elseif seaweed
== 2 then
228 nodename
= "flowers:seaweed_2"
229 elseif seaweed
== 3 then
230 nodename
= "flowers:seaweed_3"
231 elseif seaweed
== 4 then
232 nodename
= "flowers:seaweed_4"
234 minetest
.add_node(place_pos
, {name
= nodename
, param2
= math
.random(0,3) })
236 local fdir
= minetest
.dir_to_facedir(placer
:get_look_dir())
237 minetest
.add_node(place_pos
, {name
= "flowers:seaweed", param2
= fdir
})
241 if not plantslib
.expect_infinite_stacks
then
242 itemstack
:take_item()
247 on_rotate
= "simple",
252 -- register all potted plant nodes, crafts, and most backward-compat aliases
255 local extra_aliases
= {
264 for i
in ipairs(extra_aliases
) do
265 local flower
= extra_aliases
[i
]
266 minetest
.register_alias("flowers:flower_"..flower
, "flowers:"..flower
)
270 minetest
.register_alias( "trunks:lilypad" , "flowers:waterlily_s1" )
271 minetest
.register_alias( "along_shore:lilypads_1" , "flowers:waterlily_s1" )
272 minetest
.register_alias( "along_shore:lilypads_2" , "flowers:waterlily_s2" )
273 minetest
.register_alias( "along_shore:lilypads_3" , "flowers:waterlily_s3" )
274 minetest
.register_alias( "along_shore:lilypads_4" , "flowers:waterlily_s4" )
275 minetest
.register_alias( "along_shore:pondscum_1" , "flowers:seaweed" )
276 minetest
.register_alias( "along_shore:seaweed_1" , "flowers:seaweed" )
277 minetest
.register_alias( "along_shore:seaweed_2" , "flowers:seaweed_2" )
278 minetest
.register_alias( "along_shore:seaweed_3" , "flowers:seaweed_3" )
279 minetest
.register_alias( "along_shore:seaweed_4" , "flowers:seaweed_4" )
282 -- ongen registrations
285 flowers_plus
.grow_waterlily
= function(pos
)
286 local right_here
= {x
=pos
.x
, y
=pos
.y
+1, z
=pos
.z
}
287 for i
in ipairs(lilies_list
) do
288 local chance
= math
.random(1,8)
290 local num
= lilies_list
[i
][3]
293 if lilies_list
[i
][1] ~= nil then
294 ext
= "_"..lilies_list
[i
][1]
298 if chance
== num
then
299 minetest
.add_node(right_here
, {name
="flowers:waterlily"..ext
, param2
=math
.random(0,3)})
305 plantslib
:register_generate_plant({
306 surface
= {"hades_core:water_source"},
307 max_count
= lilypads_max_count
,
308 rarity
= lilypads_rarity
,
311 near_nodes
= {"hades_core:dirt_with_grass"},
313 near_nodes_vertical
= 1,
314 near_nodes_count
= 1,
315 plantlife_limit
= -0.9,
319 "flowers_plus.grow_waterlily"
323 flowers_plus
.grow_seaweed
= function(pos
)
324 local right_here
= {x
=pos
.x
, y
=pos
.y
+1, z
=pos
.z
}
325 minetest
.add_node(right_here
, {name
="along_shore:seaweed_"..math
.random(1,4), param2
=math
.random(1,3)})
329 plantslib
:register_generate_plant({
330 surface
= {"hades_core:water_source"},
331 max_count
= seaweed_max_count
,
332 rarity
= seaweed_rarity
,
333 -- min_elevation = 1,
335 near_nodes
= {"hades_core:mossystone", "hades_core:dirt_with_grass"},
337 near_nodes_vertical
= 2,
338 near_nodes_count
= 1,
339 plantlife_limit
= -1.0,
341 "flowers_plus.grow_seaweed"
345 -- seaweed at beaches
346 -- MM: not satisfied with it, but IMHO some beaches should have some algae
347 --plantslib:register_generate_plant({
348 --surface = {"hades_core:water_source"},
349 -- max_count = seaweed_max_count,
350 --rarity = seaweed_rarity,
351 -- min_elevation = 1,
352 --max_elevation = 100,
353 --near_nodes = {"hades_core:ash"},
354 --near_nodes_size = 1,
355 --near_nodes_vertical = 0,
356 --near_nodes_count = 3,
357 --plantlife_limit = -0.9,
358 --temp_max = -0.64, -- MM: more or less random values, just to make sure it's not everywhere
359 --temp_min = -0.22, -- MM: more or less random values, just to make sure it's not everywhere
361 --"flowers_plus.grow_seaweed"
363 --plantslib:register_generate_plant({
364 --surface = {"hades_core:ash"},
365 --max_count = seaweed_max_count*2,
366 --rarity = seaweed_rarity/2,
367 -- min_elevation = 1,
368 --max_elevation = 40,
369 --near_nodes = {"hades_core:water_source"},
370 --near_nodes_size = 1,
371 --near_nodes_vertical = 0,
372 --near_nodes_count = 3,
373 --plantlife_limit = -0.9,
374 --temp_max = -0.64, -- MM: more or less random values, just to make sure it's not everywhere
375 --temp_min = -0.22, -- MM: more or less random values, just to make sure it's not everywhere
377 --"flowers_plus.grow_seaweed"
379 -- spawn ABM registrations
382 plantslib
:spawn_on_surfaces({
383 spawn_delay
= SPAWN_DELAY
/2,
386 "flowers:waterlily_225",
387 "flowers:waterlily_45",
388 "flowers:waterlily_675",
389 "flowers:waterlily_s1",
390 "flowers:waterlily_s2",
391 "flowers:waterlily_s3",
392 "flowers:waterlily_s4"
395 spawn_chance
= SPAWN_CHANCE
*4,
396 spawn_surfaces
= {"hades_core:water_source"},
397 avoid_nodes
= {"group:flower", "group:flora" },
398 seed_diff
= flowers_seed_diff
,
401 random_facedir
= {0,3}
405 plantslib
:spawn_on_surfaces({
406 spawn_delay
= SPAWN_DELAY
*2,
407 spawn_plants
= {"flowers:seaweed"},
408 spawn_chance
= SPAWN_CHANCE
*2,
409 spawn_surfaces
= {"hades_core:water_source"},
410 avoid_nodes
= {"group:flower", "group:flora"},
411 seed_diff
= flowers_seed_diff
,
414 neighbors
= {"hades_core:dirt_with_grass"},
419 plantslib
:spawn_on_surfaces({
420 spawn_delay
= SPAWN_DELAY
*2,
421 spawn_plants
= {"flowers:seaweed"},
422 spawn_chance
= SPAWN_CHANCE
*2,
423 spawn_surfaces
= {"hades_core:dirt_with_grass"},
424 avoid_nodes
= {"group:flower", "group:flora" },
425 seed_diff
= flowers_seed_diff
,
428 neighbors
= {"hades_core:water_source"},
434 --plantslib:spawn_on_surfaces({
435 --spawn_delay = SPAWN_DELAY*2,
436 --spawn_plants = {"flowers:seaweed"},
437 --spawn_chance = SPAWN_CHANCE*2,
438 --spawn_surfaces = {"hades_core:stone"},
439 --avoid_nodes = {"group:flower", "group:flora" },
440 --seed_diff = flowers_seed_diff,
443 --neighbors = {"hades_core:water_source"},
452 minetest
.register_craft({
453 output
= 'flowers:seaweed 3',
454 recipe
= {{'flowers:waterlily'},}
457 minetest
.register_abm({
458 nodenames
= {"flowers:seaweed"},
461 action
= function(pos
, node
)
462 minetest
.set_node(pos
, {name
="flowers:waterlily"})
466 -- Cotton plants are now provided by the default "farming" mod.
467 -- old cotton plants -> farming cotton stage 8
468 -- cotton wads -> string (can be crafted into wool blocks)
469 -- potted cotton plants -> potted white dandelions
472 minetest
.register_alias("flowers:cotton_plant", "farming:cotton_8")
473 minetest
.register_alias("flowers:flower_cotton", "farming:cotton_8")
474 minetest
.register_alias("flowers:flower_cotton_pot", "flowers:potted_dandelion_white")
475 minetest
.register_alias("flowers:potted_cotton_plant", "flowers:potted_dandelion_white")
476 minetest
.register_alias("flowers:cotton", "farming:string")
477 minetest
.register_alias("flowers:cotton_wad", "farming:string")
480 minetest
.log("action", "[Flowers] Loaded.")