#get the amount of essences in total (3)
execute store result score .random_array_size essence run data get storage minecraft:mechanics essence.list

#get the amount of essences in total to storage minus 1 since we start our count from 0
scoreboard players operation .random_array_size essence -= .1 number
execute store result storage minecraft:mechanics essence.array int 1 run scoreboard players get .random_array_size essence

#artifacts random essence. we choose 1 random number from this array
function main:mechanics/artifacts/set/essence/random/choose_random with storage minecraft:mechanics essence

#store the randomized essence into storage as id (so third position will be 4th in our array)
execute store result storage minecraft:mechanics essence.id int 1 run scoreboard players get .random_essence essence

#get the information on a chosen array id (if id is 3 then the essence id is 2) and we remove it from the array
function main:mechanics/artifacts/set/essence/random/remove with storage minecraft:mechanics essence