Longer error message for unknown node/item
This commit is contained in:
parent
5e4c59970a
commit
3dc462d59e
31
init.lua
31
init.lua
@ -13,15 +13,32 @@ end
|
||||
doc_identifier.identify = function(itemstack, user, pointed_thing)
|
||||
local username = user:get_player_name()
|
||||
local show_message = function(username, itype, param)
|
||||
local vsize = 2
|
||||
local message
|
||||
if itype == "error_item" then
|
||||
message = "No help entry for this item could be found."
|
||||
elseif itype == "error_node" then
|
||||
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_unknown" then
|
||||
vsize = vsize + 3
|
||||
local mod
|
||||
local colon = string.find(param, ":")
|
||||
if colon ~= nil and colon > 1 then
|
||||
mod = string.sub(param,1,colon-1)
|
||||
end
|
||||
message = "Error: This is an undefined node or item. That's always an error.\n"
|
||||
message = message .. "This can happen for the following reasons:\n"
|
||||
message = message .. "• The mod which is required for it is not enabled\n"
|
||||
message = message .. "• The author of the subgame or a mod has made a mistake\n\n"
|
||||
|
||||
if mod ~= nil then
|
||||
if minetest.get_modpath(mod) ~= nil then
|
||||
message = message .. "It appears to originate from the mod “"..mod.."”, which is enabled.\n"
|
||||
else
|
||||
message = message .. "It appears to originate from the mod “"..mod.."”, which is not enabled!\n"
|
||||
end
|
||||
end
|
||||
message = message .. "The itemstring is “"..param.."”."
|
||||
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."
|
||||
elseif itype == "error_object" or itype == "error_unknown_thing" then
|
||||
@ -32,7 +49,7 @@ Itemstring: ]]..param
|
||||
minetest.show_formspec(
|
||||
username,
|
||||
"doc_identifier:error_missing_item_info",
|
||||
"size[12,2;]label[0,0.2;"..minetest.formspec_escape(message).."]button_exit[4.5,1.5;3,1;okay;OK]"
|
||||
"size[12,"..vsize..";]label[0,0.2;"..minetest.formspec_escape(message).."]button_exit[4.5,"..(-0.5+vsize)..";3,1;okay;OK]"
|
||||
)
|
||||
end
|
||||
if pointed_thing.type == "node" then
|
||||
@ -48,7 +65,7 @@ Itemstring: ]]..param
|
||||
show_message(username, "error_node")
|
||||
end
|
||||
else
|
||||
show_message(username, "error_unknown_item", node.name)
|
||||
show_message(username, "error_unknown", node.name)
|
||||
end
|
||||
elseif pointed_thing.type == "object" then
|
||||
local object = pointed_thing.ref
|
||||
@ -73,7 +90,7 @@ Itemstring: ]]..param
|
||||
elseif doc.entry_exists("craftitems", itemstring) then
|
||||
doc.show_entry(username, "craftitems", itemstring)
|
||||
elseif minetest.registered_items[itemstring] == nil or itemstring == "unknown" then
|
||||
show_message(username, "error_unknown_item", itemstring)
|
||||
show_message(username, "error_unknown", itemstring)
|
||||
else
|
||||
show_message(username, "error_item")
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user