Clean up soil checking code in melon/pumpkin

This commit is contained in:
Wuzzy 2017-03-13 20:21:38 +01:00
parent d06df50d96
commit 6456351722
2 changed files with 56 additions and 50 deletions

View File

@ -280,9 +280,11 @@ minetest.register_abm({
newpos = {x=pos.x+x, y=pos.y, z=pos.z}
local n = minetest.get_node(p)
local nod = minetest.get_node(newpos)
local soilgroup = minetest.get_item_group(n.name, "soil")
if n.name=="mcl_core:dirt_with_grass" and nod.name=="air" and have_change == 0
or n.name=="mcl_core:dirt" and nod.name=="air" and have_change == 0
or string.find(n.name, "mcl_farming:soil") and nod.name=="air" and have_change == 0 then
or (soilgroup == 2 or soilgroup == 3) and nod.name=="air" and have_change == 0 then
have_change = 1
minetest.add_node(newpos, {name="mcl_farming:melon"})
if x == 1 then
@ -298,9 +300,11 @@ minetest.register_abm({
newpos = {x=pos.x, y=pos.y, z=pos.z+z}
local n = minetest.get_node(p)
local nod2 = minetest.get_node(newpos)
local soilgroup = minetest.get_item_group(n.name, "soil")
if n.name=="mcl_core:dirt_with_grass" and nod2.name=="air" and have_change == 0
or n.name=="mcl_core:dirt" and nod2.name=="air" and have_change == 0
or string.find(n.name, "mcl_farming:soil") and nod2.name=="air" and have_change == 0 then
or (soilgroup == 2 or soilgroup == 3) and nod2.name=="air" and have_change == 0 then
have_change = 1
minetest.add_node(newpos, {name="mcl_farming:melon"})
if z == 1 then

View File

@ -254,8 +254,8 @@ mcl_farming:add_plant("mcl_farming:pumpkintige_unconnect", {"mcl_farming:pumpkin
minetest.register_abm({
nodenames = {"mcl_farming:pumpkintige_unconnect"},
neighbors = {"air"},
interval = 30,
chance = 15,
interval = 1,
chance = 1,
action = function(pos)
local have_change = 0
local newpos = {x=pos.x, y=pos.y, z=pos.z}
@ -266,9 +266,10 @@ minetest.register_abm({
newpos = {x=pos.x+x, y=pos.y, z=pos.z}
local n = minetest.get_node(p)
local nod = minetest.get_node(newpos)
local soilgroup = minetest.get_item_group(n.name, "soil")
if n.name=="mcl_core:dirt_with_grass" and nod.name=="air" and have_change == 0
or n.name=="mcl_core:dirt" and nod.name=="air" and have_change == 0
or string.find(n.name, "mcl_farming:soil") and nod.name=="air" and have_change == 0 then
or (soilgroup == 2 or soilgroup == 3) and nod.name=="air" and have_change == 0 then
have_change = 1
minetest.add_node(newpos, {name="mcl_farming:pumpkin_face"})
if x == 1 then
@ -284,9 +285,10 @@ minetest.register_abm({
newpos = {x=pos.x, y=pos.y, z=pos.z+z}
local n = minetest.get_node(p)
local nod2 = minetest.get_node(newpos)
local soilgroup = minetest.get_item_group(n.name, "soil")
if n.name=="mcl_core:dirt_with_grass" and nod2.name=="air" and have_change == 0
or n.name=="mcl_core:dirt" and nod2.name=="air" and have_change == 0
or string.find(n.name, "mcl_farming:soil") and nod2.name=="air" and have_change == 0 then
or (soilgroup == 2 or soilgroup == 3) and nod2.name=="air" and have_change == 0 then
have_change = 1
minetest.add_node(newpos, {name="mcl_farming:pumpkin_face"})
if z == 1 then