What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Script Command

Pages: (2): « First « 1 [ 2 ] Last »
Script Command
Author: Message:
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Script Command
quote:
Originally posted by markee
You have to return an empty string with commands, so it will be...
var test1 = 'Hello World!';

code:
function OnGetScriptCommands()
{
var ScriptCommands = "<ScriptCommands>";
ScriptCommands    +=     "<Command>";
ScriptCommands    +=         "<Name>test</Name>";
ScriptCommands    +=         "<Description>testing</Description>";
ScriptCommands    +=     "</Command>";
ScriptCommands    += "</ScriptCommands>";

return ScriptCommands;
}

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
switch (Message) {
case "/test":
foo();
return "";
break;
}
}
function foo() {
ChatWnd.SendMessage(test1);
}


Code after a return doesn't execute does it? That means that the break is not needed :p
<Eljay> "Problems encountered: shit blew up" :zippy:
03-12-2007 03:44 PM
Profile PM Find Quote Report
markee
Veteran Member
*****

Avatar

Posts: 1622
Reputation: 50
36 / Male / Flag
Joined: Jan 2006
RE: Script Command
No but I was lazy and just added the line in.  Realistically I could have at least made Message = "" in the case and return Message at the end or I could have used the likes of Cookie's RegExp for commands or something to make it better, but I thought I would just add to the code to minimise confusion (and it doesn't matter anyway).  If you really want to clean the code up then go ahead but I cba and you'll probably only confuse the new scripter (I do not mean to patronise in any way, I'm sorry if I come across as if I do).
[Image: markee.png]
03-12-2007 03:58 PM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: Script Command
I only mentioned it because they might then think that the break is still nessacerry.
<Eljay> "Problems encountered: shit blew up" :zippy:
03-12-2007 04:09 PM
Profile PM Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: RE: Script Command
The reason why you got that error is because you try to use a child function of an undefined variable "ChatWnd". A fix would be to send the ChatWnd object as a parameter to your foo function, like so:

code:
var test1 = 'Hello World!';

function OnGetScriptCommands()
{
var ScriptCommands = "<ScriptCommands>";
ScriptCommands    +=     "<Command>";
ScriptCommands    +=         "<Name>test</Name>";
ScriptCommands    +=         "<Description>testing</Description>";
ScriptCommands    +=     "</Command>";
ScriptCommands    += "</ScriptCommands>";

return ScriptCommands;
}

function OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
switch (Message) {
case "/test":
foo(ChatWnd);
break;
}
}
function foo(ChatWnd) {
ChatWnd.SendMessage(test1);
}
Or, you could use a return to replace the sent message:
code:
...
switch (Message) {
case "/test":
return foo(ChatWnd);
break; //not really necessary, it simply makes it look more common.
}
...
function foo(ChatWnd) {
return test1;
}
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
03-12-2007 05:18 PM
Profile E-Mail PM Web Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« 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