summaryrefslogtreecommitdiff
path: root/papyrus.lua
diff options
context:
space:
mode:
authortenplus1 <kinsellaja@yahoo.com>2015-04-10 15:38:53 +0100
committertenplus1 <kinsellaja@yahoo.com>2015-04-10 15:38:53 +0100
commit7d5b162ae9c7942bc21725bd310b46ebe8e4e4a2 (patch)
tree897e5de62611c8d8cea46219960744a7c0da7fb3 /papyrus.lua
parentefd4ab247c4fa11921bf0a65b61a432e674600e4 (diff)
tidied & optimized code
Diffstat (limited to 'papyrus.lua')
-rw-r--r--papyrus.lua31
1 files changed, 15 insertions, 16 deletions
diff --git a/papyrus.lua b/papyrus.lua
index e17dee2..5bee2e6 100644
--- a/papyrus.lua
+++ b/papyrus.lua
@@ -1,8 +1,7 @@
--- Override default Papyrus to make it walkable
+-- override default papyrus to make it walkable
minetest.override_item("default:papyrus", {walkable=true, sunlight_propagates=true})
-
--- Have Papyrus grow up to 4 high and Bamboo grow up to 5 in height (shared abm)
+-- have papyrus grow up to 4 high and bamboo grow up to 5 in height (shared abm)
minetest.register_abm({
nodenames = {"default:papyrus", "ethereal:bamboo"},
neighbors = {"group:soil"},
@@ -10,32 +9,32 @@ minetest.register_abm({
chance = 20,
action = function(pos, node)
- local type = minetest.get_node(pos).name
local high = 4
- pos.y = pos.y-1
- local name = minetest.get_node(pos).name
+ pos.y = pos.y - 1
+ local nod = minetest.get_node_or_nil(pos)
- if minetest.get_item_group(name, "soil") < 1 or minetest.find_node_near(pos, 3, {"group:water"}) == nil then
+ if not nod
+ or minetest.get_item_group(nod.name, "soil") < 1
+ or minetest.find_node_near(pos, 3, {"group:water"}) == nil then
return
end
- if type == "ethereal:bamboo" then
+ if node.name == "ethereal:bamboo" then
high = 5
end
- pos.y = pos.y+1
+ pos.y = pos.y + 1
local height = 0
- while minetest.get_node(pos).name == type and height < high do
- height = height+1
- pos.y = pos.y+1
+ while minetest.get_node(pos).name == node.name and height < high do
+ height = height + 1
+ pos.y = pos.y + 1
end
- if height < high then
- if minetest.get_node(pos).name == "air" then
- minetest.set_node(pos, {name=type})
- end
+ nod = minetest.get_node_or_nil(pos)
+ if nod and nod.name == "air" and height < high then
+ minetest.set_node(pos, {name=node.name})
end
end,