Jlee
February 28th, 2006, 05:25 AM
Is there a better way to do this in Lua as it seems a bit long winded to have an if statement with so many elseif's. Some sort of select statement maybe?
luckydip = math.random(1,27)
if luckydip == 1 then
path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Pot luck - any album'
elseif luckydip == 2 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\2 tracks from 10 new albums'
elseif luckydip == 3 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Album with unrated tracks'
elseif luckydip == 4 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Favourite album'
elseif luckydip == 5 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Newly added album'
elseif luckydip == 6 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\NOW! album'
elseif luckydip == 7 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Rock album'
elseif luckydip == 8 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Artists\\Tracks from one artist (rated)'
elseif luckydip == 9 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Artists\\Tracks from one artist'
elseif luckydip == 10 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\50 tracks - pot luck'
elseif luckydip == 11 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\2 tracks from each decade'
elseif luckydip == 12 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\10 from the 2000s'
elseif luckydip == 13 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\10 from the 60s'
elseif luckydip == 14 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\10 from the 70s'
elseif luckydip == 15 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\10 from the 80s'
elseif luckydip == 16 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\10 from the 90s'
elseif luckydip == 17 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\50 tracks off iPod - pot luck'
elseif luckydip == 18 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\60s Top 20 Hits'
elseif luckydip == 19 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\70s Top 20 Hits'
elseif luckydip == 20 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\80s Top 20 Hits'
elseif luckydip == 21 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\90s Top 20 Hits'
elseif luckydip == 22 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\2000s Top 20 Hits'
elseif luckydip == 23 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\Club / dance selection'
elseif luckydip == 24 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\Good dance tracks'
elseif luckydip == 25 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Album from 2005+'
elseif luckydip == 26 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\Recent hits - 2005+'
else
path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\Romantic'
end;
I'd like to use something similar to apply channel numbers to channel names on Sky TV i.e. have the channel names in the buttons on my CCF and the associated channel numbers in my lua file. This would make it a whole lot easier to fix when Sky change all the channel numbers.
luckydip = math.random(1,27)
if luckydip == 1 then
path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Pot luck - any album'
elseif luckydip == 2 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\2 tracks from 10 new albums'
elseif luckydip == 3 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Album with unrated tracks'
elseif luckydip == 4 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Favourite album'
elseif luckydip == 5 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Newly added album'
elseif luckydip == 6 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\NOW! album'
elseif luckydip == 7 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Rock album'
elseif luckydip == 8 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Artists\\Tracks from one artist (rated)'
elseif luckydip == 9 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Artists\\Tracks from one artist'
elseif luckydip == 10 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\50 tracks - pot luck'
elseif luckydip == 11 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\2 tracks from each decade'
elseif luckydip == 12 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\10 from the 2000s'
elseif luckydip == 13 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\10 from the 60s'
elseif luckydip == 14 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\10 from the 70s'
elseif luckydip == 15 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\10 from the 80s'
elseif luckydip == 16 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\10 from the 90s'
elseif luckydip == 17 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\50 tracks off iPod - pot luck'
elseif luckydip == 18 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\60s Top 20 Hits'
elseif luckydip == 19 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\70s Top 20 Hits'
elseif luckydip == 20 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\80s Top 20 Hits'
elseif luckydip == 21 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\90s Top 20 Hits'
elseif luckydip == 22 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\2000s Top 20 Hits'
elseif luckydip == 23 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\Club / dance selection'
elseif luckydip == 24 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\Good dance tracks'
elseif luckydip == 25 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Albums\\Album from 2005+'
elseif luckydip == 26 then path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\Recent hits - 2005+'
else
path = 'Media Library\\Audio\\NetRemote\\Lucky Dip\\Tracks\\Romantic'
end;
I'd like to use something similar to apply channel numbers to channel names on Sky TV i.e. have the channel names in the buttons on my CCF and the associated channel numbers in my lua file. This would make it a whole lot easier to fix when Sky change all the channel numbers.