Display error for unknown nodes/items

This commit is contained in:
Wuzzy 2016-08-16 16:12:32 +02:00
parent 51733ec835
commit 5e4c59970a

View File

@ -12,12 +12,16 @@ end
doc_identifier.identify = function(itemstack, user, pointed_thing) doc_identifier.identify = function(itemstack, user, pointed_thing)
local username = user:get_player_name() local username = user:get_player_name()
local show_message = function(username, itype) local show_message = function(username, itype, param)
local message local message
if itype == "error_item" then if itype == "error_item" then
message = "No help entry for this item could be found." message = "No help entry for this item could be found."
elseif itype == "error_node" then elseif itype == "error_node" then
message = "No help entry for this block could be found." message = "No help entry for this block could be found."
elseif itype == "error_unknown_item" then
message =
[[Error: This is an unknown item or node. If you see something like this in Minetest, this is an error.
Itemstring: ]]..param
elseif itype == "error_ignore" then elseif itype == "error_ignore" then
message = "This block cannot be identified because the world has not materialized at this point yet. Try again in a few seconds." message = "This block cannot be identified because the world has not materialized at this point yet. Try again in a few seconds."
elseif itype == "error_object" or itype == "error_unknown_thing" then elseif itype == "error_object" or itype == "error_unknown_thing" then
@ -43,6 +47,8 @@ doc_identifier.identify = function(itemstack, user, pointed_thing)
else else
show_message(username, "error_node") show_message(username, "error_node")
end end
else
show_message(username, "error_unknown_item", node.name)
end end
elseif pointed_thing.type == "object" then elseif pointed_thing.type == "object" then
local object = pointed_thing.ref local object = pointed_thing.ref
@ -66,6 +72,8 @@ doc_identifier.identify = function(itemstack, user, pointed_thing)
doc.show_entry(username, "tools", itemstring) doc.show_entry(username, "tools", itemstring)
elseif doc.entry_exists("craftitems", itemstring) then elseif doc.entry_exists("craftitems", itemstring) then
doc.show_entry(username, "craftitems", itemstring) doc.show_entry(username, "craftitems", itemstring)
elseif minetest.registered_items[itemstring] == nil or itemstring == "unknown" then
show_message(username, "error_unknown_item", itemstring)
else else
show_message(username, "error_item") show_message(username, "error_item")
end end