mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-19 09:31:07 +01:00
Fix crash when tool_capabilities is nil
This commit is contained in:
parent
0112825a9f
commit
fe770c19a5
1 changed files with 11 additions and 2 deletions
|
@ -243,6 +243,15 @@ local function get_groupcap(group, can_harvest, multiplier, efficiency, uses)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Returns the tool_capabilities from a tool definition or a default set of
|
||||||
|
-- tool_capabilities
|
||||||
|
local function get_tool_capabilities(tdef)
|
||||||
|
if tdef.tool_capabilities then
|
||||||
|
return tdef.tool_capabilities
|
||||||
|
end
|
||||||
|
return {}
|
||||||
|
end
|
||||||
|
|
||||||
-- Get the groupcaps for a tool. This function returns "groupcaps" table of
|
-- Get the groupcaps for a tool. This function returns "groupcaps" table of
|
||||||
-- digging which should be put in the "tool_capabilities" of the tool definition
|
-- digging which should be put in the "tool_capabilities" of the tool definition
|
||||||
-- or in the metadata of an enchanted tool.
|
-- or in the metadata of an enchanted tool.
|
||||||
|
@ -257,7 +266,7 @@ end
|
||||||
-- loading order.
|
-- loading order.
|
||||||
function mcl_autogroup.get_groupcaps(toolname, efficiency)
|
function mcl_autogroup.get_groupcaps(toolname, efficiency)
|
||||||
local tdef = minetest.registered_tools[toolname]
|
local tdef = minetest.registered_tools[toolname]
|
||||||
local groupcaps = table.copy(tdef.tool_capabilities.groupcaps or {})
|
local groupcaps = table.copy(get_tool_capabilities(tdef).groupcaps or {})
|
||||||
add_groupcaps(toolname, groupcaps, tdef._mcl_diggroups, efficiency)
|
add_groupcaps(toolname, groupcaps, tdef._mcl_diggroups, efficiency)
|
||||||
return groupcaps
|
return groupcaps
|
||||||
end
|
end
|
||||||
|
@ -322,7 +331,7 @@ local overwrite = function()
|
||||||
-- Assign groupcaps for digging the registered digging groups
|
-- Assign groupcaps for digging the registered digging groups
|
||||||
-- depending on the _mcl_diggroups in the tool definition
|
-- depending on the _mcl_diggroups in the tool definition
|
||||||
if tdef._mcl_diggroups then
|
if tdef._mcl_diggroups then
|
||||||
local toolcaps = table.copy(tdef.tool_capabilities) or {}
|
local toolcaps = table.copy(get_tool_capabilities(tdef))
|
||||||
toolcaps.groupcaps = mcl_autogroup.get_groupcaps(tname)
|
toolcaps.groupcaps = mcl_autogroup.get_groupcaps(tname)
|
||||||
|
|
||||||
minetest.override_item(tname, {
|
minetest.override_item(tname, {
|
||||||
|
|
Loading…
Reference in a new issue