Thanks Volv for the (foaly's) code, I'll try that out as well once I get Cookie's code working
___________________________________
quote:
You've not copied the code exactly as I put it (or you changed stuff too much or in the wrong way)...
Perhaps so, take a look.
This is the code as I have it.. well, the main functions...
code:
var Text=new Array();
var num=0;
Text[num++] = "Test 1";
Text[num++] = "Test 2";
Text[num++] = "Test 3";
Text[num++] = "Test 4";
Text[num++] = "Test 5";
Text[num++] = "Test 6";
Text[num++] = "Test 7";
Text[num++] = "Test 8";
Text[num++] = "Test 9";
Text[num++] = "Test 10";
Text[num++] = "Test 11";
Text[num++] = "Test 12";
///////////////////////////////////////////////////////////
// Script Starts here
//////////////////////////////////////////////////////////
var arrLyrics = new Array();
var arrPrevious = new Array();
var nUniqueness = 10;
function GetAllLyrics() {
arrPrevious = new Array();
return Text
}
function GetRandomLyric() {
// get a random lyric line from the 'possible lyrics' array
var rndLyric = Math.floor(Math.random() * arrLyrics.length);
// step 1: add new line to 'used lyrics' array and remove it from the 'possible lyrics' array
arrPrevious[nUniqueness-1] = arrLyrics.splice(rndLyric, 1);
// step 2: add last lyric line from the 'used lyrics' array back to the 'possible lyrics' array
if (arrPrevious[0] !== undefined) arrLyrics.push(arrPrevious[0]);
// step 3: remove last lyric line from the 'used lyrics' array
arrPrevious.shift();
// you're done: return the new lyric line
return arrPrevious[nUniqueness-2]
Debug.Trace(arrPrevious);
}
function personalMessage()
{
Debug.Trace ("Started Personal Message");
//reading the timer value from the registry
try{
timer = WShell.RegRead(MsgPlus.ScriptRegPath+Messenger.MyUserId+"\\JeremysRandomSongLyricTimer");
}
catch{}
try{
randomlyric = WshShell.RegRead(MsgPlus.ScriptRegPath+Messenger.MyUserId+"\\JeremysRandomSongLyric");
}
catch{}
if (randomlyric==1)
{
arrLyrics = GetAllLyrics();
var rndLyric = GetRandomLyric();
//Messenger.MyPersonalMessage = "( 8)" + rndLyric;
MsgPlus.DisplayToast("New Random Lyric", "( 8)" + rndLyric, null, 'OnToastClick', null);
MsgPlus.AddTimer('randomtext', timer);
Debug.Trace ("Printed personal message - " + rndLyric);
Debug.Trace ("ArrPrevious - " + arrPrevious);
Debug.Trace ("ArrLyrics - " + arrLyrics);
}