summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAuke Kok <sofar@foo-projects.org>2015-11-25 22:25:41 -0800
committerAuke Kok <sofar@foo-projects.org>2015-11-25 22:25:41 -0800
commit5329ff5b369602918fbb70b61351b2d89ae440eb (patch)
treee733b404acb8d415aaacad51275d72dce72d1b7b
parentf5908b08afddf6da3d569c2328fd61784da7a0c3 (diff)
Particle spawner on dead plants: flies.
These buzz around dead plants, right after they die.
-rw-r--r--corn.lua3
-rw-r--r--init.lua95
-rw-r--r--polebean.lua3
-rw-r--r--potato.lua2
-rw-r--r--pumpkin.lua6
-rw-r--r--textures/crops_flies.pngbin0 -> 89 bytes
-rw-r--r--tomato.lua6
7 files changed, 93 insertions, 22 deletions
diff --git a/corn.lua b/corn.lua
index 467eff6..debd661 100644
--- a/corn.lua
+++ b/corn.lua
@@ -290,8 +290,7 @@ minetest.register_node("crops:corn_top_3", {
for i = 1,math.random(2 - (damage / 100), 4 - (3 * (damage / 100))) do
table.insert(drops, ('crops:corn_cob'))
end
- minetest.set_node(pos, { name = "crops:corn_top_4" })
- minetest.set_node(below, { name = "crops:corn_base_3" })
+ crops.die(below)
core.handle_node_drops(pos, drops, digger)
end
})
diff --git a/init.lua b/init.lua
index a4f5f36..a7f0989 100644
--- a/init.lua
+++ b/init.lua
@@ -142,7 +142,7 @@ crops.particles = function(pos, flag)
local p = {}
if flag == 0 then
-- wither (0)
- p = {
+ minetest.add_particlespawner({
amount = 1 * crops.settings.interval,
time = crops.settings.interval,
minpos = { x = pos.x - 0.4, y = pos.y - 0.4, z = pos.z - 0.4 },
@@ -158,10 +158,10 @@ crops.particles = function(pos, flag)
collisiondetection = false,
texture = "crops_wither.png",
vertical = true,
- }
+ })
elseif flag == 1 then
-- soak (1)
- p = {
+ minetest.add_particlespawner({
amount = 8 * crops.settings.interval,
time = crops.settings.interval,
minpos = { x = pos.x - 0.4, y = pos.y - 0.4, z = pos.z - 0.4 },
@@ -177,9 +177,10 @@ crops.particles = function(pos, flag)
collisiondetection = false,
texture = "crops_soak.png",
vertical = false,
- }
- else -- watering (2)
- p = {
+ })
+ elseif flag == 2 then
+ -- watering (2)
+ minetest.add_particlespawner({
amount = 30,
time = 3,
minpos = { x = pos.x - 0.4, y = pos.y - 0.4, z = pos.z - 0.4 },
@@ -195,9 +196,85 @@ crops.particles = function(pos, flag)
collisiondetection = false,
texture = "crops_watering.png",
vertical = true,
- }
+ })
+ else
+ -- withered/rotting (3)
+ minetest.add_particlespawner({
+ amount = 20,
+ time = 30,
+ minpos = { x = pos.x + 0.3, y = pos.y - 0.5, z = pos.z - 0.5 },
+ maxpos = { x = pos.x + 0.5, y = pos.y + 0.5, z = pos.z + 0.5 },
+ minvel = { x = -0.6, y = -0.1, z = -0.2 },
+ maxvel = { x = -0.4, y = 0.1, z = 0.2 },
+ minacc = { x = 0.4, y = 0, z = -0.1 },
+ maxacc = { x = 0.5, y = 0, z = 0.1 },
+ minexptime = 2,
+ maxexptime = 4,
+ minsize = 1,
+ maxsize = 1,
+ collisiondetection = false,
+ texture = "crops_flies.png",
+ vertical = true,
+ })
+ minetest.add_particlespawner({
+ amount = 20,
+ time = 30,
+ minpos = { x = pos.x - 0.3, y = pos.y - 0.5, z = pos.z - 0.5 },
+ maxpos = { x = pos.x - 0.5, y = pos.y + 0.5, z = pos.z + 0.5 },
+ minvel = { x = 0.6, y = -0.1, z = -0.2 },
+ maxvel = { x = 0.4, y = 0.1, z = 0.2 },
+ minacc = { x = -0.4, y = 0, z = -0.1 },
+ maxacc = { x = -0.5, y = 0, z = 0.1 },
+ minexptime = 2,
+ maxexptime = 4,
+ minsize = 1,
+ maxsize = 1,
+ collisiondetection = false,
+ texture = "crops_flies.png",
+ vertical = true,
+ })
+ minetest.add_particlespawner({
+ amount = 20,
+ time = 30,
+ minpos = { x = pos.x - 0.5, y = pos.y - 0.5, z = pos.z + 0.3 },
+ maxpos = { x = pos.x + 0.5, y = pos.y + 0.5, z = pos.z + 0.5 },
+ minvel = { z = -0.6, y = -0.1, x = -0.2 },
+ maxvel = { z = -0.4, y = 0.1, x = 0.2 },
+ minacc = { z = 0.4, y = 0, x = -0.1 },
+ maxacc = { z = 0.5, y = 0, x = 0.1 },
+ minexptime = 2,
+ maxexptime = 4,
+ minsize = 1,
+ maxsize = 1,
+ collisiondetection = false,
+ texture = "crops_flies.png",
+ vertical = true,
+ })
+ minetest.add_particlespawner({
+ amount = 20,
+ time = 30,
+ minpos = { x = pos.x - 0.5, y = pos.y - 0.5, z = pos.z - 0.3 },
+ maxpos = { x = pos.x + 0.5, y = pos.y + 0.5, z = pos.z - 0.5 },
+ minvel = { z = 0.6, y = -0.1, x = -0.2 },
+ maxvel = { z = 0.4, y = 0.1, x = 0.2 },
+ minacc = { z = -0.4, y = 0, x = -0.1 },
+ maxacc = { z = -0.5, y = 0, x = 0.1 },
+ minexptime = 2,
+ maxexptime = 4,
+ minsize = 1,
+ maxsize = 1,
+ collisiondetection = false,
+ texture = "crops_flies.png",
+ vertical = true,
+ })
end
- minetest.add_particlespawner(p)
+end
+
+crops.die = function(pos)
+ crops.particles(pos, 3)
+ local node = minetest.get_node(pos)
+ local plant = find_plant(node)
+ plant.properties.die(pos)
end
minetest.register_tool("crops:watering_can", {
@@ -383,7 +460,7 @@ minetest.register_abm({
-- is it dead?
if damage >= 100 then
- plant.properties.die(pos)
+ crops.die(pos)
end
end
})
diff --git a/polebean.lua b/polebean.lua
index ee1d22d..27eb854 100644
--- a/polebean.lua
+++ b/polebean.lua
@@ -97,8 +97,7 @@ local function crops_beanpole_on_dig(pos, node, digger)
for i = 1,math.random(3 - (2 * (damage / 100)),7 - (6 * (damage / 100))) do
table.insert(drops, "crops:green_bean")
end
- minetest.set_node(bottom, { name = "crops:beanpole_plant_base_6"})
- minetest.set_node(top, { name = "crops:beanpole_plant_top_4"})
+ crops.die(bottom)
elseif bottom_n.name == "crops:beanpole_plant_base_6" and top_n.name == "crops:beanpole_plant_top_4" then
-- harvested beans
for i = 1,math.random(3,4) do
diff --git a/potato.lua b/potato.lua
index 248957b..b1aa889 100644
--- a/potato.lua
+++ b/potato.lua
@@ -125,7 +125,7 @@ minetest.register_abm({
local meta = minetest.get_meta(pos)
local damage = meta:get_int("crops_damage")
if damage == 100 then
- minetest.set_node(pos, { name = "crops:potato_plant_5" })
+ crops.die(pos)
return
end
local n = string.gsub(node.name, "3", "4")
diff --git a/pumpkin.lua b/pumpkin.lua
index 74b4464..a5d2754 100644
--- a/pumpkin.lua
+++ b/pumpkin.lua
@@ -197,8 +197,7 @@ minetest.register_abm({
minetest.swap_node(pos, {name = "crops:pumpkin_plant_5_attached", param2 = faces[r].r})
meta:set_int("crops_pumpkin_ttl", ttl - 1)
else
- -- no luck, plant dead!
- minetest.set_node(pos, { name = "crops:pumpkin_plant_6" })
+ crops.die(pos)
end
local water = meta:get_int("crops_water")
-- growing a pumpkin costs 25 water!
@@ -228,8 +227,7 @@ minetest.register_abm({
minetest.swap_node(pos, { name = "crops:pumpkin_plant_4" })
meta:set_int("crops_pumpkin_ttl", ttl)
else
- minetest.swap_node(pos, { name = "crops:pumpkin_plant_6"})
- meta:set_int("crops_pumpkin_ttl", 0)
+ crops.die(pos)
end
end
})
diff --git a/textures/crops_flies.png b/textures/crops_flies.png
new file mode 100644
index 0000000..b047a61
--- /dev/null
+++ b/textures/crops_flies.png
Binary files differ
diff --git a/tomato.lua b/tomato.lua
index 77ab866..70603f3 100644
--- a/tomato.lua
+++ b/tomato.lua
@@ -85,8 +85,7 @@ minetest.register_node("crops:tomato_plant_5" , {
minetest.swap_node(pos, { name = "crops:tomato_plant_4"})
meta:set_int("crops_tomato_ttl", ttl - 1)
else
- minetest.swap_node(pos, { name = "crops:tomato_plant_6"})
- meta:set_int("crops_tomato_ttl", 0)
+ crops.die(pos)
end
end
})
@@ -162,8 +161,7 @@ minetest.register_abm({
minetest.swap_node(pos, { name = "crops:tomato_plant_5" })
meta:set_int("crops_tomato_ttl", ttl)
else
- -- no luck, plant dead!
- minetest.set_node(pos, { name = "crops:tomato_plant_6" })
+ crops.die(pos)
end
end
})