mirror of
https://github.com/mt-mods/plantlife_modpack.git
synced 2024-12-26 10:30:19 +01:00
performance improvement
cache type() check of node/function/model, always check if it's string before trying to execute that string as a function.
This commit is contained in:
parent
942aefd7dd
commit
591a917e21
@ -182,14 +182,16 @@ function plantslib:search_for_surfaces(minp, maxp, biomedef, node_or_function_or
|
|||||||
minetest.remove_node(pos)
|
minetest.remove_node(pos)
|
||||||
end
|
end
|
||||||
|
|
||||||
if type(node_or_function_or_model) == "table" then
|
objtype = type(node_or_function_or_model)
|
||||||
|
|
||||||
|
if objtype == "table" then
|
||||||
plantslib:generate_tree(pos, node_or_function_or_model)
|
plantslib:generate_tree(pos, node_or_function_or_model)
|
||||||
spawned = true
|
spawned = true
|
||||||
elseif type(node_or_function_or_model) == "string" and
|
elseif objtype == "string" and
|
||||||
minetest.registered_nodes[node_or_function_or_model] then
|
minetest.registered_nodes[node_or_function_or_model] then
|
||||||
minetest.add_node(p_top, { name = node_or_function_or_model })
|
minetest.add_node(p_top, { name = node_or_function_or_model })
|
||||||
spawned = true
|
spawned = true
|
||||||
elseif pcall(loadstring(("return %s(%s)"):
|
elseif objtype == "string" and pcall(loadstring(("return %s(%s)"):
|
||||||
format(node_or_function_or_model, dump_pos(pos)))) then
|
format(node_or_function_or_model, dump_pos(pos)))) then
|
||||||
spawned = true
|
spawned = true
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user