mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Improve some warning messages (#15990)
This commit is contained in:
parent
a3648b0b16
commit
7689f1f0fd
3 changed files with 19 additions and 7 deletions
|
@ -156,7 +156,8 @@ local function preprocess_craft(itemdef)
|
||||||
-- BEGIN Legacy stuff
|
-- BEGIN Legacy stuff
|
||||||
if itemdef.inventory_image == nil and itemdef.image ~= nil then
|
if itemdef.inventory_image == nil and itemdef.image ~= nil then
|
||||||
core.log("deprecated", "The `image` field in craftitem definitions " ..
|
core.log("deprecated", "The `image` field in craftitem definitions " ..
|
||||||
"is deprecated. Use `inventory_image` instead.")
|
"is deprecated. Use `inventory_image` instead. " ..
|
||||||
|
"Craftitem name: " .. itemdef.name, 3)
|
||||||
itemdef.inventory_image = itemdef.image
|
itemdef.inventory_image = itemdef.image
|
||||||
end
|
end
|
||||||
-- END Legacy stuff
|
-- END Legacy stuff
|
||||||
|
@ -168,7 +169,8 @@ local function preprocess_tool(tooldef)
|
||||||
-- BEGIN Legacy stuff
|
-- BEGIN Legacy stuff
|
||||||
if tooldef.inventory_image == nil and tooldef.image ~= nil then
|
if tooldef.inventory_image == nil and tooldef.image ~= nil then
|
||||||
core.log("deprecated", "The `image` field in tool definitions " ..
|
core.log("deprecated", "The `image` field in tool definitions " ..
|
||||||
"is deprecated. Use `inventory_image` instead.")
|
"is deprecated. Use `inventory_image` instead. " ..
|
||||||
|
"Tool name: " .. tooldef.name, 3)
|
||||||
tooldef.inventory_image = tooldef.image
|
tooldef.inventory_image = tooldef.image
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -185,7 +187,8 @@ local function preprocess_tool(tooldef)
|
||||||
tooldef.dd_crumbliness ~= nil or
|
tooldef.dd_crumbliness ~= nil or
|
||||||
tooldef.dd_cuttability ~= nil) then
|
tooldef.dd_cuttability ~= nil) then
|
||||||
core.log("deprecated", "Specifying tool capabilities directly in the tool " ..
|
core.log("deprecated", "Specifying tool capabilities directly in the tool " ..
|
||||||
"definition is deprecated. Use the `tool_capabilities` field instead.")
|
"definition is deprecated. Use the `tool_capabilities` field instead. " ..
|
||||||
|
"Tool name: " .. tooldef.name, 3)
|
||||||
tooldef.tool_capabilities = {
|
tooldef.tool_capabilities = {
|
||||||
full_punch_interval = tooldef.full_punch_interval,
|
full_punch_interval = tooldef.full_punch_interval,
|
||||||
basetime = tooldef.basetime,
|
basetime = tooldef.basetime,
|
||||||
|
@ -269,7 +272,8 @@ function core.register_item(name, itemdef)
|
||||||
-- BEGIN Legacy stuff
|
-- BEGIN Legacy stuff
|
||||||
if itemdef.cookresult_itemstring ~= nil and itemdef.cookresult_itemstring ~= "" then
|
if itemdef.cookresult_itemstring ~= nil and itemdef.cookresult_itemstring ~= "" then
|
||||||
core.log("deprecated", "The `cookresult_itemstring` item definition " ..
|
core.log("deprecated", "The `cookresult_itemstring` item definition " ..
|
||||||
"field is deprecated. Use `core.register_craft` instead.")
|
"field is deprecated. Use `core.register_craft` instead. " ..
|
||||||
|
"Item name: " .. itemdef.name, 2)
|
||||||
core.register_craft({
|
core.register_craft({
|
||||||
type="cooking",
|
type="cooking",
|
||||||
output=itemdef.cookresult_itemstring,
|
output=itemdef.cookresult_itemstring,
|
||||||
|
@ -279,7 +283,8 @@ function core.register_item(name, itemdef)
|
||||||
end
|
end
|
||||||
if itemdef.furnace_burntime ~= nil and itemdef.furnace_burntime >= 0 then
|
if itemdef.furnace_burntime ~= nil and itemdef.furnace_burntime >= 0 then
|
||||||
core.log("deprecated", "The `furnace_burntime` item definition " ..
|
core.log("deprecated", "The `furnace_burntime` item definition " ..
|
||||||
"field is deprecated. Use `core.register_craft` instead.")
|
"field is deprecated. Use `core.register_craft` instead. " ..
|
||||||
|
"Item name: " .. itemdef.name, 2)
|
||||||
core.register_craft({
|
core.register_craft({
|
||||||
type="fuel",
|
type="fuel",
|
||||||
recipe=itemdef.name,
|
recipe=itemdef.name,
|
||||||
|
|
|
@ -364,7 +364,8 @@ int ModApiMainMenu::l_get_content_info(lua_State *L)
|
||||||
// being able to return type "unknown".
|
// being able to return type "unknown".
|
||||||
// TODO inspect call sites and make sure this is handled, then we can
|
// TODO inspect call sites and make sure this is handled, then we can
|
||||||
// likely remove the warning.
|
// likely remove the warning.
|
||||||
warningstream << "Requested content info has type \"unknown\"" << std::endl;
|
warningstream << "Requested content info has type \"unknown\" "
|
||||||
|
<< "(at " << path << ")" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
lua_newtable(L);
|
lua_newtable(L);
|
||||||
|
|
|
@ -54,7 +54,13 @@ int ModApiUtil::l_log(lua_State *L)
|
||||||
auto name = readParam<std::string_view>(L, 1);
|
auto name = readParam<std::string_view>(L, 1);
|
||||||
text = readParam<std::string_view>(L, 2);
|
text = readParam<std::string_view>(L, 2);
|
||||||
if (name == "deprecated") {
|
if (name == "deprecated") {
|
||||||
log_deprecated(L, text, 2);
|
// core.log("deprecated", message [, stack_level])
|
||||||
|
// Level 1 - immediate caller of core.log (probably engine code);
|
||||||
|
// Level 2 - caller of the function that called core.log, and so on
|
||||||
|
int stack_level = readParam<int>(L, 3, 2);
|
||||||
|
if (stack_level < 1)
|
||||||
|
throw LuaError("invalid stack level");
|
||||||
|
log_deprecated(L, text, stack_level);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
level = Logger::stringToLevel(name);
|
level = Logger::stringToLevel(name);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue