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)
|
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, param)
|
local show_message = function(username, itype, param)
|
||||||
|
local vsize = 2
|
||||||
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
|
elseif itype == "error_unknown" then
|
||||||
message =
|
vsize = vsize + 3
|
||||||
[[Error: This is an unknown item or node. If you see something like this in Minetest, this is an error.
|
local mod
|
||||||
Itemstring: ]]..param
|
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
|
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
|
||||||
@ -32,7 +49,7 @@ Itemstring: ]]..param
|
|||||||
minetest.show_formspec(
|
minetest.show_formspec(
|
||||||
username,
|
username,
|
||||||
"doc_identifier:error_missing_item_info",
|
"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
|
end
|
||||||
if pointed_thing.type == "node" then
|
if pointed_thing.type == "node" then
|
||||||
@ -48,7 +65,7 @@ Itemstring: ]]..param
|
|||||||
show_message(username, "error_node")
|
show_message(username, "error_node")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
show_message(username, "error_unknown_item", node.name)
|
show_message(username, "error_unknown", 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
|
||||||
@ -73,7 +90,7 @@ Itemstring: ]]..param
|
|||||||
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
|
elseif minetest.registered_items[itemstring] == nil or itemstring == "unknown" then
|
||||||
show_message(username, "error_unknown_item", itemstring)
|
show_message(username, "error_unknown", itemstring)
|
||||||
else
|
else
|
||||||
show_message(username, "error_item")
|
show_message(username, "error_item")
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user