From 245d052bc5f3b0845d3feba0fe2f4a8141207fe7 Mon Sep 17 00:00:00 2001 From: NathanSalapat Date: Sat, 24 Dec 2016 09:56:49 -0600 Subject: [PATCH] fixed spreading. --- functions.lua | 11 ++++++++++- prickly_pear.lua | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/functions.lua b/functions.lua index aa6f330..d338cf2 100644 --- a/functions.lua +++ b/functions.lua @@ -32,10 +32,19 @@ function desert_life.spread(nodename, pos, undernode, replacing) local under_location = ({x=location.x, y=location.y-1, z=location.z}) local under_name = minetest.get_node_or_nil(under_location) local location_name = minetest.get_node_or_nil(location) + if under_name == nil then + return -- Should under_name somehow not be a node this will keep the script from crashing. + end if under_name.name == undernode then - if location_name.name == replacing then + if location_name.name == replacing then + local pos1 = {x=location.x+2, y=location.y, z=location.z+2} + local pos0 = {x=location.x-2, y=location.y, z=location.z-2} + local can_replace = minetest.find_nodes_in_area(pos0, pos1, replacing) + local replace_num = #can_replace + if replace_num > 22 then --increase to decrease number of plants. local face_ran = math.random(0,3) minetest.set_node(location, {name = nodename, param2 = face_ran}) + end end end end diff --git a/prickly_pear.lua b/prickly_pear.lua index 4af56de..d2cc8f5 100644 --- a/prickly_pear.lua +++ b/prickly_pear.lua @@ -150,8 +150,8 @@ minetest.register_decoration({ minetest.register_abm{ nodenames = {"group:dl_pp"}, - interval = 30, - chance = 20, + interval = 40, + chance = 30, action = function(pos) local node = minetest.get_node(pos) if node.name == 'desert_life:prickly_pear_1' then @@ -181,8 +181,8 @@ minetest.register_abm{ if desert_life_bloom == true then minetest.register_abm{ nodenames = {"group:dl_pp"}, - interval = 30, - chance = 20, + interval = 1, + chance = 2, action = function(pos) if mymonths.month_counter == 4 or mymonths.month_counter == 5