Code tweaks
This commit is contained in:
parent
2befb9a980
commit
57240fe6f5
11
dirt.lua
11
dirt.lua
@ -63,20 +63,17 @@ minetest.register_abm({
|
||||
action = function(pos, node)
|
||||
local count_grasses = {}
|
||||
local curr_max = 0
|
||||
local curr_type = "ethereal:green_dirt_top" -- fallback Colour
|
||||
local curr_type = "ethereal:green_dirt" -- fallback
|
||||
local positions = minetest.find_nodes_in_area(
|
||||
{x=(pos.x-2), y=(pos.y-2), z=(pos.z-2)},
|
||||
{x=(pos.x+2), y=(pos.y+2), z=(pos.z+2)},
|
||||
"group:ethereal_grass")
|
||||
local n
|
||||
-- count new grass nodes
|
||||
for _,p in ipairs(positions) do
|
||||
local n = minetest.get_node(p)
|
||||
n = minetest.get_node_or_nil(p)
|
||||
if n and n.name then
|
||||
if not count_grasses[n.name] then
|
||||
count_grasses[n.name] = 1
|
||||
else
|
||||
count_grasses[n.name] = count_grasses[n.name] + 1
|
||||
end
|
||||
count_grasses[n.name] = (count_grasses[n.name] or 0) + 1
|
||||
-- we found a grass type with more than current max
|
||||
if count_grasses[n.name] > curr_max then
|
||||
curr_max = count_grasses[n.name]
|
||||
|
Loading…
Reference in New Issue
Block a user