mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-04-22 23:25:15 +02:00
Fix rebase missing moving a function to new mcl_util/table.lua
This commit is contained in:
parent
9aade4034f
commit
b568a5cc49
2 changed files with 13 additions and 14 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue