WoWInterface - View Single Post - Picking a random entry out of a table/list?
View Single Post
12-17-20, 10:13 AM   #2
A Pyroguard Emberseer
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,029
You could do something like this.

local SongList={

This should print a random string grabbed from SongList. The length operator (#) returns the length of the table (number of consecutive numerical indices starting at 1). Giving only one argument to math.random() is the same as calling math.random(1,n) where n is the number you're passing it.

PS: If you're referencing sounds located in your addon folder, you need to make sure the path is formatted relative to WoW's root directory.
It should look something like this:
ESOUI AddOns | WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 12-17-20 at 10:20 AM.
  Reply With Quote