From 2c23ab6174ae903e8a2db1a8f08cdad009eb95d8 Mon Sep 17 00:00:00 2001 From: Daniel Cassidy Date: Thu, 6 Jan 2022 13:52:14 +0000 Subject: [PATCH] _mcl_autogroup: Use register_on_mods_loaded minetest.register_on_mods_loaded calls its callback after all mods have loaded, removing the need for the naming hack used to ensure _mcl_autogroup loads last. --- mods/CORE/_mcl_autogroup/init.lua | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/mods/CORE/_mcl_autogroup/init.lua b/mods/CORE/_mcl_autogroup/init.lua index e04fb2eac5..20549c7251 100644 --- a/mods/CORE/_mcl_autogroup/init.lua +++ b/mods/CORE/_mcl_autogroup/init.lua @@ -115,11 +115,16 @@ local function get_hardness_lookup_for_groups(hardness_values) end -- Array of unique hardness values for each group which affects dig time. -local hardness_values = get_hardness_values_for_groups() +local hardness_values -- Map indexed by hardness values which return the index of that value in -- hardness_value. Used for quick lookup. -local hardness_lookup = get_hardness_lookup_for_groups(hardness_values) +local hardness_lookup + +minetest.register_on_mods_loaded(function() + hardness_values = get_hardness_values_for_groups() + hardness_lookup = get_hardness_lookup_for_groups(hardness_values) +end) --[[local function compute_creativetimes(group) local creativetimes = {} @@ -364,4 +369,4 @@ local function overwrite() end end -overwrite() +minetest.register_on_mods_loaded(overwrite)