Fix rebase missing moving a function to new mcl_util/table.lua

This commit is contained in:
teknomunk 2025-01-07 06:52:58 -06:00 committed by the-real-herowl
parent 9aade4034f
commit b568a5cc49
2 changed files with 13 additions and 14 deletions
mods/CORE/mcl_util

View file

@ -6,20 +6,6 @@ dofile(modpath.."/roman_numerals.lua")
dofile(modpath.."/nodes.lua")
dofile(modpath.."/table.lua")
-- Removes one element randomly selected from the array section of the table and
-- returns it, or nil if there are no elements in the array section of the table
function table.remove_random_element(table)
local count = #table
if count == 0 then return nil end
local idx = math.random(count)
local res = table[idx]
table[idx] = table[count]
table[count] = nil
count = count - 1
return res
end
local LOGGING_ON = minetest.settings:get_bool("mcl_logging_default", false)
local LOG_MODULE = "[MCL2]"
function mcl_util.mcl_log(message, module, bypass_default_logger)

View file

@ -69,3 +69,16 @@ function table.intersect(a, b)
return result
end
-- Removes one element randomly selected from the array section of the table and
-- returns it, or nil if there are no elements in the array section of the table
function table.remove_random_element(table)
local count = #table
if count == 0 then return nil end
local idx = math.random(count)
local res = table[idx]
table[idx] = table[count]
table[count] = nil
count = count - 1
return res
end