summaryrefslogtreecommitdiff
path: root/schematics/waterlily.lua
blob: d6bfaa3476381960e4797116343ffa64432a04ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69

-- Waterlily (built column by column, bottom to top)

local a = "default:sand"
local b = "default:water_source"
local c = "flowers:waterlily"

ethereal.waterlily = {
	size = {x = 1, y = 3, z = 1},
	data = {

		{name=a, param1=255},
		{name=b, param1=255},
		{name=c, param1=255},

	},
}

if minetest.registered_nodes["flowers:waterlily"] then

minetest.override_item("flowers:waterlily", {
	walkable = true,
})

else

minetest.register_node(":flowers:waterlily", {
	description = "Waterlily",
	drawtype = "nodebox",
	paramtype = "light",
	paramtype2 = "facedir",
	tiles = {"flowers_waterlily.png"},
	inventory_image = "flowers_waterlily.png",
	wield_image = "flowers_waterlily.png",
	liquids_pointable = true,
	walkable = true,
	buildable_to = true,
	groups = {snappy = 3, flower = 1},
	sounds = default.node_sound_leaves_defaults(),
	node_box = {
		type = "fixed",
		fixed = {-0.5, -0.5, -0.5, 0.5, -0.46875, 0.5}
	},
	selection_box = {
		type = "fixed",
		fixed = {-0.5, -0.5, -0.5, 0.5, -0.4375, 0.5}
	},

	after_place_node = function(pos, placer, itemstack, pointed_thing)
		local find_water = minetest.find_nodes_in_area({x = pos.x - 1, y = pos.y, z = pos.z - 1},
			{x = pos.x + 1, y = pos.y, z = pos.z + 1}, "default:water_source")
		local find_river_water = minetest.find_nodes_in_area({x = pos.x - 1, y = pos.y, z = pos.z - 1},
			{x = pos.x + 1, y = pos.y, z = pos.z + 1}, "default:river_water_source")
		if #find_water ~= 0 then
			minetest.set_node(pos, {name = "default:water_source"})
			pos.y = pos.y + 1
			minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
		elseif #find_river_water ~= 0 then
			minetest.set_node(pos, {name = "default:river_water_source"})
			pos.y = pos.y + 1
			minetest.set_node(pos, {name = "flowers:waterlily", param2 = math.random(0, 3)})
		else
			minetest.remove_node(pos)
			return true
		end
	end
})

end