1 local S
= minetest
.get_translator("flowers_plus")
3 -- This file supplies seaweed and waterlilies
8 local SPAWN_DELAY
= 1000
9 local SPAWN_CHANCE
= 200
10 local flowers_seed_diff
= 329
11 local lilies_max_count
= 12
12 local lilies_rarity
= 33
13 local seaweed_max_count
= 20
14 local seaweed_rarity
= 33
16 local lilypads_max_count
= {}
17 local lilypads_rarity
= {}
18 -- register the various rotations of waterlilies
23 { "225", "22.5" , 2 },
25 { "675", "67.5" , 4 },
26 { "s1" , "small_1" , 5 },
27 { "s2" , "small_2" , 6 },
28 { "s3" , "small_3" , 7 },
29 { "s4" , "small_4" , 8 },
33 for i
in ipairs(lilies_list
) do
36 local lily_groups
= {snappy
= 3,flammable
=2,waterlily
=1}
39 if lilies_list
[i
][1] ~= nil then
40 deg1
= "_"..lilies_list
[i
][1]
41 deg2
= "_"..lilies_list
[i
][2]
42 lily_groups
= { snappy
= 3,flammable
=2,waterlily
=1, not_in_creative_inventory
=1 }
46 minetest
.register_node(":flowers:waterlily"..deg1
, {
47 description
= S("Waterlily"),
50 "flowers_waterlily"..deg2
..".png",
51 "flowers_waterlily"..deg2
..".png^[transformFY",
54 inventory_image
= "flowers_waterlily.png",
55 wield_image
= "flowers_waterlily.png",
56 sunlight_propagates
= true,
58 paramtype2
= "facedir",
61 sounds
= hades_sounds
.node_sound_leaves_defaults(),
64 fixed
= { -0.5, -0.5, -0.5, 0.5, -7/16, 0.5 },
68 fixed
= { -0.5, -0.495, -0.5, 0.5, -0.49, 0.5 },
73 liquids_pointable
= true,
74 drop
= "flowers:waterlily",
75 on_place
= function(itemstack
, placer
, pointed_thing
)
76 local keys
=placer
:get_player_control()
77 local pt
= pointed_thing
81 local top_pos
= {x
=pt
.under
.x
, y
=pt
.under
.y
+1, z
=pt
.under
.z
}
82 local under_node
= minetest
.get_node(pt
.under
)
83 local above_node
= minetest
.get_node(pt
.above
)
84 local top_node
= minetest
.get_node(top_pos
)
87 if plantslib
:get_nodedef_field(under_node
.name
, "buildable_to") then
88 if under_node
.name
~= "hades_core:water_source" then
90 elseif top_node
.name
~= "hades_core:water_source"
91 and plantslib
:get_nodedef_field(top_node
.name
, "buildable_to") then
96 elseif plantslib
:get_nodedef_field(above_node
.name
, "buildable_to") then
100 if not place_pos
then
104 if not plantslib
:node_is_owned(place_pos
, placer
) then
106 local nodename
= "hades_core:cobble" -- if this block appears, something went....wrong :-)
108 if not keys
["sneak"] then
109 local node
= minetest
.get_node(pt
.under
)
110 local waterlily
= math
.random(1,8)
111 if waterlily
== 1 then
112 nodename
= "flowers:waterlily"
113 elseif waterlily
== 2 then
114 nodename
= "flowers:waterlily_225"
115 elseif waterlily
== 3 then
116 nodename
= "flowers:waterlily_45"
117 elseif waterlily
== 4 then
118 nodename
= "flowers:waterlily_675"
119 elseif waterlily
== 5 then
120 nodename
= "flowers:waterlily_s1"
121 elseif waterlily
== 6 then
122 nodename
= "flowers:waterlily_s2"
123 elseif waterlily
== 7 then
124 nodename
= "flowers:waterlily_s3"
125 elseif waterlily
== 8 then
126 nodename
= "flowers:waterlily_s4"
128 minetest
.add_node(place_pos
, {name
= nodename
, param2
= math
.random(0,3) })
130 local fdir
= minetest
.dir_to_facedir(placer
:get_look_dir())
131 minetest
.add_node(place_pos
, {name
= "flowers:waterlily", param2
= fdir
})
135 if not minetest
.is_creative_enabled(placer
:get_player_name()) then
136 itemstack
:take_item()
141 on_rotate
= "simple",
146 local algae_list
= { {nil}, {2}, {3}, {4} }
149 for i
in ipairs(algae_list
) do
151 local algae_groups
= {snappy
= 3,flammable
=2,seaweed
=1}
154 if algae_list
[i
][1] ~= nil then
155 num
= "_"..algae_list
[i
][1]
156 algae_groups
= { snappy
= 3,flammable
=2,seaweed
=1, not_in_creative_inventory
=1 }
160 minetest
.register_node(":flowers:seaweed"..num
, {
161 description
= S("Seaweed"),
162 drawtype
= "nodebox",
164 "flowers_seaweed"..num
..".png",
165 "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.5, -0.5, -0.5, 0.5, -7/16, 0.5 },
182 fixed
= { -0.5, -0.495, -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 minetest
.is_creative_enabled(placer
:get_player_name()) then
242 itemstack
:take_item()
247 on_rotate
= "simple",
252 -- ongen registrations
255 flowers_plus
.grow_waterlily
= function(pos
)
256 local right_here
= {x
=pos
.x
, y
=pos
.y
+1, z
=pos
.z
}
257 for i
in ipairs(lilies_list
) do
258 local chance
= math
.random(1,8)
260 local num
= lilies_list
[i
][3]
263 if lilies_list
[i
][1] ~= nil then
264 ext
= "_"..lilies_list
[i
][1]
268 if chance
== num
then
269 minetest
.add_node(right_here
, {name
="flowers:waterlily"..ext
, param2
=math
.random(0,3)})
275 plantslib
:register_generate_plant({
276 surface
= {"hades_core:water_source"},
277 max_count
= lilypads_max_count
,
278 rarity
= lilypads_rarity
,
281 near_nodes
= {"hades_core:dirt_with_grass"},
283 near_nodes_vertical
= 1,
284 near_nodes_count
= 1,
285 plantlife_limit
= -0.9,
289 "flowers_plus.grow_waterlily"
293 flowers_plus
.grow_seaweed
= function(pos
)
294 local right_here
= {x
=pos
.x
, y
=pos
.y
+1, z
=pos
.z
}
295 minetest
.add_node(right_here
, {name
="along_shore:seaweed_"..math
.random(1,4), param2
=math
.random(1,3)})
299 plantslib
:register_generate_plant({
300 surface
= {"hades_core:water_source"},
301 max_count
= seaweed_max_count
,
302 rarity
= seaweed_rarity
,
303 -- min_elevation = 1,
305 near_nodes
= {"hades_core:mossystone", "hades_core:dirt_with_grass"},
307 near_nodes_vertical
= 2,
308 near_nodes_count
= 1,
309 plantlife_limit
= -1.0,
311 "flowers_plus.grow_seaweed"
314 plantslib
:spawn_on_surfaces({
315 spawn_delay
= SPAWN_DELAY
/2,
318 "flowers:waterlily_225",
319 "flowers:waterlily_45",
320 "flowers:waterlily_675",
321 "flowers:waterlily_s1",
322 "flowers:waterlily_s2",
323 "flowers:waterlily_s3",
324 "flowers:waterlily_s4"
327 spawn_chance
= SPAWN_CHANCE
*4,
328 spawn_surfaces
= {"hades_core:water_source"},
329 avoid_nodes
= {"group:flower", "group:flora" },
330 seed_diff
= flowers_seed_diff
,
333 random_facedir
= {0,3}
337 plantslib
:spawn_on_surfaces({
338 spawn_delay
= SPAWN_DELAY
*2,
339 spawn_plants
= {"flowers:seaweed"},
340 spawn_chance
= SPAWN_CHANCE
*2,
341 spawn_surfaces
= {"hades_core:water_source"},
342 avoid_nodes
= {"group:flower", "group:flora"},
343 seed_diff
= flowers_seed_diff
,
346 neighbors
= {"hades_core:dirt_with_grass"},
351 plantslib
:spawn_on_surfaces({
352 spawn_delay
= SPAWN_DELAY
*2,
353 spawn_plants
= {"flowers:seaweed"},
354 spawn_chance
= SPAWN_CHANCE
*2,
355 spawn_surfaces
= {"hades_core:dirt_with_grass"},
356 avoid_nodes
= {"group:flower", "group:flora" },
357 seed_diff
= flowers_seed_diff
,
360 neighbors
= {"hades_core:water_source"},
368 minetest
.register_craft({
369 output
= 'flowers:seaweed 3',
370 recipe
= {{'flowers:waterlily'},}
373 minetest
.register_abm({
374 label
= "Turn seaweed to waterlily",
375 nodenames
= {"flowers:seaweed"},
378 action
= function(pos
, node
)
379 minetest
.set_node(pos
, {name
="flowers:waterlily"})
383 minetest
.log("action", "[flowers_plus] loaded.")