From d87e2d02316cbc47aeb84e7143ef980dec33ee36 Mon Sep 17 00:00:00 2001 From: Damgam Date: Wed, 4 Sep 2019 14:35:10 +0200 Subject: [PATCH] Fixed randomization of music. no more the same track everytime you launch chobby yey...... unless you set openTrack in config --- LuaMenu/widgets/snd_music_lite.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/LuaMenu/widgets/snd_music_lite.lua b/LuaMenu/widgets/snd_music_lite.lua index ab9c7a921..3fecc09f1 100644 --- a/LuaMenu/widgets/snd_music_lite.lua +++ b/LuaMenu/widgets/snd_music_lite.lua @@ -35,8 +35,8 @@ local function GetRandomTrack(previousTrack) end end - local randomTrack = math.ceil(math.random()*trackCount) - if randomTrack == previousTrackIndex then + local randomTrack = math.random(1, trackCount) + if randomTrack == previousTrackIndex and previousTrackIndex ~= trackCount then randomTrack = trackCount + 1 end return randomTrackList[randomTrack] @@ -154,13 +154,13 @@ function widget:Initialize() return end + math.randomseed(os.clock() * 100) + openTrack = WG.Chobby.Configuration.gameConfig.openTrack if openTrack == nil then - openTrack = randomTrackList[math.random(#randomTrackList)] + openTrack = randomTrackList[math.random(1, #randomTrackList)] end - math.randomseed(os.clock() * 100) - local Configuration = WG.Chobby.Configuration local function onConfigurationChange(listener, key, value)