Divergent/mods/Enhanced Graphical User Int.../gamedata/scripts/modxml_menu_music.script

32 lines
800 B
Plaintext
Raw Normal View History

2024-03-17 20:18:03 -04:00
function on_xml_read()
RegisterScriptCallback("on_xml_read", function(xml_file_name, xml_obj)
if xml_file_name == [[ui\ui_mm_main.xml]]
or xml_file_name == [[ui\ui_mm_main_16.xml]]
then
math.randomseed(os.time())
local res = xml_obj:query("menu_sound > menu_music")
local mus_t = {
"music\\mm_music\\track_1",
"music\\mm_music\\track_2",
"music\\mm_music\\track_3",
"music\\mm_music\\track_4",
"music\\mm_music\\track_5",
"music\\mm_music\\track_6",
"music\\mm_music\\track_7",
"music\\mm_music\\track_8",
"music\\mm_music\\track_9",
"music\\mm_music\\track_10",
"music\\mm_music\\track_11",
}
local picked_track = mus_t[math.random(1, #mus_t)]
if res[1] then
el = res[1]
xml_obj:setText (el, picked_track)
end
end
end)
end