diff options
author | TenPlus1 <kinsellaja@yahoo.com> | 2016-01-21 14:59:28 +0000 |
---|---|---|
committer | TenPlus1 <kinsellaja@yahoo.com> | 2016-01-21 14:59:28 +0000 |
commit | 87031b60518731f62dbce0ffb1601b0c34d506c9 (patch) | |
tree | 707258c7ca090302fbbc7114966d551c849881da /sapling.lua | |
parent | bd0fae584c0b0c3a04d41608acb4dfaf77554d91 (diff) |
Optimize code, allfaces leaves by default, leaves walkable by default
Diffstat (limited to 'sapling.lua')
-rw-r--r-- | sapling.lua | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/sapling.lua b/sapling.lua index 05ba759..896cb69 100644 --- a/sapling.lua +++ b/sapling.lua @@ -57,8 +57,11 @@ local path = minetest.get_modpath("ethereal").."/schematics/" ethereal.grow_sapling = function (pos, node) - local under = minetest.get_node_or_nil({x = pos.x, y = pos.y - 1, z = pos.z}) - if under then under = under.name else return end + local under = minetest.get_node({ + x = pos.x, + y = pos.y - 1, + z = pos.z + }).name -- Check if Sapling is growing on correct substrate if node.name == "ethereal:yellow_tree_sapling" @@ -139,13 +142,15 @@ minetest.register_craftitem("ethereal:tree_tool", { description = "Tree Tool", inventory_image = "default_stick.png", on_use = function(itemstack, user, pointed_thing) + if not pointed_thing or pointed_thing.type ~= "node" then return end + local pos = pointed_thing.under - local nod = minetest.get_node_or_nil(pos) - if not nod then return end + local nod = minetest.get_node(pos) + ethereal.grow_sapling(pos, nod) end, }) |