don't register surface types if their nodes aren't defined.

This commit is contained in:
Vanessa Ezekowitz 2014-08-15 16:14:09 -04:00
parent a25fb55c57
commit 8e4c942d9a

View File

@ -119,7 +119,7 @@ function plantslib:register_generate_plant(biomedef, node_or_function_or_model)
if type(node_or_function_or_model) == "string" if type(node_or_function_or_model) == "string"
and string.find(node_or_function_or_model, ":") and string.find(node_or_function_or_model, ":")
and not minetest.registered_nodes[node_or_function_or_model] then and not minetest.registered_nodes[node_or_function_or_model] then
print("[Plants Lib] Warning: Ignored registration for undefined node: "..dump(node_or_function_or_model)) print("[Plants Lib] Warning: Ignored registration for undefined spawn node: "..dump(node_or_function_or_model))
return return
end end
@ -136,15 +136,23 @@ function plantslib:register_generate_plant(biomedef, node_or_function_or_model)
plantslib.actions_list[#plantslib.actions_list + 1] = { biomedef, node_or_function_or_model } plantslib.actions_list[#plantslib.actions_list + 1] = { biomedef, node_or_function_or_model }
local s = biomedef.surface local s = biomedef.surface
if type(s) == "string" then if type(s) == "string" then
if s and minetest.registered_nodes[s] then
if not search_table(plantslib.surfaces_list, s) then if not search_table(plantslib.surfaces_list, s) then
plantslib.surfaces_list[#plantslib.surfaces_list + 1] = s plantslib.surfaces_list[#plantslib.surfaces_list + 1] = s
end end
else
print("[Plants Lib] Warning: Ignored registration for undefined surface node: "..dump(s))
end
else else
for i = 1, #biomedef.surface do for i = 1, #biomedef.surface do
local s = biomedef.surface[i] local s = biomedef.surface[i]
if s and minetest.registered_nodes[s] then
if not search_table(plantslib.surfaces_list, s) then if not search_table(plantslib.surfaces_list, s) then
plantslib.surfaces_list[#plantslib.surfaces_list + 1] = s plantslib.surfaces_list[#plantslib.surfaces_list + 1] = s
end end
else
print("[Plants Lib] Warning: Ignored registration for undefined surface node: "..dump(s))
end
end end
end end
end end
@ -627,6 +635,7 @@ end
print("[Plants Lib] Loaded") print("[Plants Lib] Loaded")
minetest.after(0, function() minetest.after(0, function()
print("[Plants Lib] Registered a total of "..#plantslib.actions_list.." actions and "..plantslib.total_legacy_calls.." legacy mapgen hooks.") print("[Plants Lib] Registered a total of "..#plantslib.surfaces_list.." surface types to be evaluated,")
print("[Plants Lib] a total of "..#plantslib.actions_list.." actions, and "..plantslib.total_legacy_calls.." legacy mapgen hooks.")
end) end)