There is a way to randomize it. You can make use of background simulations because they are garenteed to always be in random order.
So what you can do is overwrite startup simulations instead of the image location, and create on simulation for each image you have. Of course, this will create a simulation, which means a map, and not an image. But, you can use LuaRendering to draw your images on the map. For example, I use LuaRendering to draw the little Hall of Fame Emblems
on the simulations in the Hall of Fame mod.
So basically something like:
-- data.lua
-- Clear vanilla simulations
data.raw["utility-constants"]["default"].main_menu_simulations = { }
-- Convenience Handle
local simulations = data.raw["utility-constants"]["default"].main_menu_simulations
for background_name, background_path in pairs(backgrounds) do
-- Create sprites
data:extend{
{
type = background_name,
filename = background_path,
-- etc,
}
}
-- Create new simulation and draw the image on the background
simulations[background_name] = {
init = [[
rendering.draw_sprite{
name = "]]..background_name..[[",
target = {0, 0},
-- etc
}
]]
}
end
Note, this won't be perfect, because you'll cut of the image at different places depending on your screen size. So it will be a little trade-off, although I guess the images are always stretched or cropped to fit on different screens anyway in your current implemenation. For some information you can read this Forum Post