What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » scripting help need please

scripting help need please
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: scripting help need please
The principle is the same as what you do with the status text.

You create an array of different texts. Then you need to get a random number which would be the number of the element to take from that array.

Random numbers can be generated like this:
code:
var myRandomNumber = Math.floor((upperbound - lowerbound + 1) * Math.random() + lowerbound);
where upperbound is the biggest number and lowerbound the lowest number in the range you which to choose from.

Thus if you whish to choose a random number from 5 to 10, you do:
code:
var myRandomNumber = Math.floor((10 - 5 + 1) * Math.random() + 5);
which equals:
code:
var myRandomNumber = Math.floor(6 * Math.random() + 5);

For the array of random texts, it is important to know that arrays start with index 0 (thus this would be our lowerbound). The length of the array determines our upperbound:
code:
var myTextArray = new Array("Hello", "Bonjour", "Yo", "Hi");

var lowerbound = 0;
var upperbound = myTextArray.length-1;

var myRandomNumber = Math.floor((upperbound - lowerbound + 1) * Math.random() + lowerbound);

var myRandomText = myTextArray[myRandomNumber];
optimized, this would be:
code:
var myTextArray = new Array("Hello", "Bonjour", "Yo", "Hi");
var myRandomText = myTextArray[Math.floor(myTextArray.length * Math.random())];
.-= A 'frrrrrrrituurrr' for Wacky =-.
03-07-2007 02:52 PM
Profile PM Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
scripting help need please - by Gareth_2007 on 03-07-2007 at 12:31 AM
RE: scripting help need please - by Dennis Mike on 03-07-2007 at 02:56 AM
RE: scripting help need please - by Felu on 03-07-2007 at 03:14 AM
RE: scripting help need please - by CookieRevised on 03-07-2007 at 11:44 AM
RE: scripting help need please - by Gareth_2007 on 03-07-2007 at 01:55 PM
RE: scripting help need please - by CookieRevised on 03-07-2007 at 02:52 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On