Optimize check_if_node_sawed performance, shorten

This commit is contained in:
SmallJoker 2020-05-08 09:55:09 +02:00 committed by GitHub
parent 717ad02350
commit 9786051860
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 12 deletions

View File

@ -196,18 +196,11 @@ technic.register_power_tool("technic:chainsaw", chainsaw_max_charge)
-- This function checks if the specified node should be sawed
local function check_if_node_sawed(pos)
if chainsaw_leaves then
if minetest.get_item_group( minetest.get_node(pos).name, "leaves" ) ~= 0
or minetest.get_item_group( minetest.get_node(pos).name, "tree" ) ~= 0
or timber_nodenames[minetest.get_node(pos).name] then
return true
end
else
if minetest.get_item_group( minetest.get_node(pos).name, "tree" ) ~= 0
or timber_nodenames[minetest.get_node(pos).name] then
return true
end
local node_name = minetest.get_node(pos).name
if timber_nodenames[node_name]
or (chainsaw_leaves and minetest.get_item_group(node_name, "leaves") ~= 0)
or minetest.get_item_group(node_name, "tree") ~= 0 then
return true
end
return false