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:
Gareth_2007
Junior Member
**


Posts: 21
Joined: Mar 2007
O.P. Huh?  scripting help need please
i have some code that makes merlin talk but where you see merlin.Speak("Hello" + Messenger.MyName); it is only one hello but what i want is every time i log in it is a different hello on random from a hardcoded list! but i dont no how to code it! and where you see merlin.Speak("I'm Merlin, Nice To Meet You!" + Messenger.MyStatus); i want him to say the users satus but he says the status number! any ideas? cheers gareth

function OnEvent_Initialize(MessengerStart){
if(MessengerStart==false){
    startcharacter();
    merlin.Show();
    merlin.MoveTo(25,30);
    merlin.Play("Announce");
    merlin.Speak("Hello" + Messenger.MyName);
    merlin.Play("Greet");
    merlin.Play("RestPose");
    merlin.Speak("I'm Merlin, Nice To Meet You!" + Messenger.MyStatus);

    merlin.Speak("Bye");
    merlin.Play("Wave");
    merlin.Hide();
}else{
        function OnEvent_SigninReady(Email){
            startcharacter();
        }
}
}
03-07-2007 12:31 AM
Profile E-Mail PM Find Quote Report
Dennis Mike
Junior Member
**

Avatar

Posts: 59
Reputation: 2
34 / Male / –
Joined: Jan 2007
RE: scripting help need please
switch(Messenger.MyStatus){
case 1:
status = "online"
case 2:
status = "etc"
}

merlin.Speak("I'm Merlin, Nice To Meet You!" + status);
03-07-2007 02:56 AM
Profile PM Web Find Quote Report
Felu
Veteran Member
*****


Posts: 2223
Reputation: 72
30 / Male / Flag
Joined: Apr 2006
Status: Away
RE: scripting help need please
Or you can make an array with Status names and Match it with Status code :).
code:
var Status = new Array("Unknown", "Offline", "Appear Offline", "Online", "Busy", "Be Right Back", "Idle", "Away", "In a Call", "Out to Lunch");
Status[Messenger.MyStatus];

This post was edited on 03-07-2007 at 12:30 PM by Felu.
03-07-2007 03:14 AM
Profile E-Mail PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: scripting help need please
Gareth_2007,

Note that your general code is completely wrong though. It will not function properly and will returns errors in some cases:
code:
function OnEvent_Initialize(MessengerStart){
    if(MessengerStart==false){
        startcharacter();
        merlin.Show();
        merlin.MoveTo(25,30);
        merlin.Play("Announce");
        merlin.Speak("Hello" + Messenger.MyName);
        merlin.Play("Greet");
        merlin.Play("RestPose");
        merlin.Speak("I'm Merlin, Nice To Meet You!" + Messenger.MyStatus);

        merlin.Speak("Bye");
        merlin.Play("Wave");
        merlin.Hide();
    }else{
        function OnEvent_SigninReady(Email){
            startcharacter();
        }
    }
}

Fixed for what you probably want to do:
code:
function OnEvent_Initialize(MessengerStart){
    if(Messenger.MyStatus > 1){
        OnEvent_SigninReady(Messenger.MyEmail);
    }
}

function OnEvent_SigninReady(Email){
        startcharacter();
        merlin.Show();
        merlin.MoveTo(25,30);
        merlin.Play("Announce");
        merlin.Speak("Hello " + Messenger.MyName);
        merlin.Play("Greet");
        merlin.Play("RestPose");
        merlin.Speak("I'm Merlin, Nice To Meet You! Your status is " + Array("Unknown", "Offline", "Appear Offline", "Online", "Busy", "Be Right Back", "Idle", "Away", "In a Call", "Out to Lunch")[Messenger.MyStatus]);

        merlin.Speak("Bye");
        merlin.Play("Wave");
        merlin.Hide();
}

;)




-------------------------------------------------------------------
quote:
Originally posted by Dennis Mike
switch(Messenger.MyStatus){
case 1:
status = "online"
1 = "Offline", not "Online"


This post was edited on 03-07-2007 at 12:29 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
03-07-2007 11:44 AM
Profile PM Find Quote Report
Gareth_2007
Junior Member
**


Posts: 21
Joined: Mar 2007
O.P. RE: scripting help need please
cheer for the help guys! how can i get merlin to choose form a list of different hellos so when you sign in it will be a different hello on random? cheers
03-07-2007 01:55 PM
Profile E-Mail PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
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 »


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