I could only skid it and ask chatgpt ad it gave me this:
local shapes = {
{Name = "block", Chance = 1/2},
{Name = "cube", Chance = 1/3},
{Name = "2d square", Chance = 1/6},
}
function rollShape()
local roll = math.random()
local cumulative = 0
for _, shape in ipairs(shapes) do
cumulative = cumulative + shape.Chance
if roll <= cumulative then
return shape.Name
end
end
-- fallback, shouldn't happen unless the chances don't add up to 1
return "???"
end
i sent this into #📜︱scripting and asked for advice and they said 2 things:
make it yourself not ai
and
use weighted system
whats a weight system and how to make