summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortenplus1 <kinsellaja@yahoo.com>2015-05-12 10:11:32 +0100
committertenplus1 <kinsellaja@yahoo.com>2015-05-12 10:11:32 +0100
commit57240fe6f540164860b08d0afa6b8d5621d8ceda (patch)
tree8a14ea3a6f9de38b21f7f936fa12a35a80aa687b
parent2befb9a980f62da3a9c4de2b94a59e8a08afc56a (diff)
Code tweaks
-rw-r--r--dirt.lua11
1 files changed, 4 insertions, 7 deletions
diff --git a/dirt.lua b/dirt.lua
index f31a8f0..11d0570 100644
--- a/dirt.lua
+++ b/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]