What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [beta UPDATE] Math Games

[beta UPDATE] Math Games
Author: Message:
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. [beta UPDATE] Math Games
here is another script.. just thought of it today.. in school -_-

CAUTION: this is beta script so it can be recoded..

you can edit this if you want

desc:
Make your contacts play some math questions


known Bugs:
- sometimes returns undefined in the message.
example : when doing 1+1 it sometimes (rarely) returns 1undefined1..
hope someone can fix..?    (FIXED) thanks Matty.....

Commands:

/mgamestart
Start the math game.

/mgamestop
Stop the math game.


--- i hope some math ppl will like this :D
please reply if you found something bad :(

.plsc File Attachment: Math Games beta.plsc (1.29 KB)
This file has been downloaded 210 time(s).

This post was edited on 11-28-2006 at 04:36 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
11-27-2006 11:24 PM
Profile PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [beta release] Math Games
quote:
Originally posted by roflmao456
sometimes returns undefined in the message.
example : when doing 1+1 it sometimes (rarely) returns 1undefined1..
hope someone can fix..?
BEDMAS
Brackets Exponents Division Muliplication Addition Subtraction.

code:
randomop=Math.round(Math.random()*(op.length)-1);

The order of the code that would be processed first is as follows
code:
randomop=Math.round(Math.random()*(op.length)-1);
                    |              |________| |
                    |                   |   | |
                    |                   |_ processed first
                    |_______________________| |
                    |            |            |
                    |            |_ processed second
                    |                         |
                    |                         |
                    |_________________________|
                                 |
                                 |_ processed third

So with your code if the random number generated is 0 then once you subtract 1 you end up with -1 as a value and there is no operator at array position -1.

code:
randomop=Math.round(Math.random()*(op.length-1));

Is the right code.

This post was edited on 11-27-2006 at 11:57 PM by matty.
11-27-2006 11:47 PM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: [beta release] Math Games
quote:
Originally posted by Matty

So with your code if the random number generated is 0 then once you subtract 1 you end up with -1 as a value and there is no operator at array position -1.

code:
randomop=Math.round(Math.random()*(op.length-1));

Is the right code.

it still does that..
[quote]
Ultimatess6
: What a noob mod
11-28-2006 12:42 AM
Profile PM Web Find Quote Report
dylan!
Senior Member
****

Avatar
l33t p4int3r

Posts: 665
Reputation: 30
– / Male / Flag
Joined: Jan 2005
RE: [beta release] Math Games
..∂уℓαη --|            says:
Welcome to Math Game, I am going to ask you math questions.
   ..∂уℓαη --|            says:
What is..

18 - 96?
   ..∂уℓαη --|            says:
-82
   ..∂уℓαη --|            says:
95
   ..∂уℓαη --|            says:
That is wrong. The correct answer was: -78.
   ..∂уℓαη --|            says:
New Question!
   ..∂уℓαη --|            says:
What is..

7undefined92?
   ..∂уℓαη --|            says:
That is wrong. The correct answer was: NaN.
11-28-2006 12:44 AM
Profile E-Mail PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [beta release] Math Games
code:
/*

made by me, roflmao456 aka john
beta

edited by Matty

*/


var _answer;
var _randomop;
var _random1;
var _random2;
var _on = new Boolean(false);
var _played = new Boolean(false);
var _op = new Array('+', '-', '*', '/');

function OnGetScriptCommands(){
    var ScriptCommands = '<ScriptCommands>';
    ScriptCommands += '<Command>';
    if (_on == false) {
        ScriptCommands += '<Name>mgamestart</Name>';
        ScriptCommands += '<Description>Starts the Math Game</Description>';
    } else {
        ScriptCommands += '<Name>mgamestop</Name>';
        ScriptCommands += '<Description>Stops the Math Game</Description>';
    }
    ScriptCommands += '</Command>';
    ScriptCommands += '</ScriptCommands>';
    return ScriptCommands;
}

function OnEvent_ChatWndSendMessage(pChatWnd, sMessage){
    if (_on == false){
        if (sMessage.toLowerCase() == '/mgamestart'){
            _on = true;
            MsgPlus.DisplayToast('Math Game', 'Math Game is now started.');
            _currentchat = pChatWnd;
            _playGame();
            return '';
        }
    } else {
        if (sMessage.toLowerCase() == '/mgamestop'){
            _on = false;
            MsgPlus.DisplayToast('Math Game','Math Game is now stopped.');
            _played = false;
            return '';
        }
    }
}

function _playGame(pChatWnd){
    Debug.Trace('_playGame function called.'); //start setting random question
    _random1 = Math.round(Math.random()*(99)+1);
    _random2 = Math.round(Math.random()*(99)+1);
    _randomop = Math.round(Math.random()*(_op.length-1));
    _answer = eval(_random1+_op[_randomop]+_random2); // set up the answer
    if (_played != true){
        _on = false;
        pChatWnd.SendMessage('Welcome to Math Game, I am going to ask you math questions.');
        pChatWnd.SendMessage('What is.. \n\n'+_random1+' '+_op[_randomop]+' '+_random2+'?');
        _on = true;
    } else {
        _on = false;
        pChatWnd.SendMessage('new Question!');
        pChatWnd.SendMessage('What is.. \n\n'+_random1+' '+_op[_randomop]+' '+_random2+'?');
        _on = true;
    }
}

function OnEvent_ChatWndReceiveMessage(pChatWnd, sOrigin, sMessage){
    if (_on == true){
        if (sOrigin != Messenger.MyName){
            if (sMessage == _answer){
                pChatWnd.SendMessage('That is correct!');
                _played = true;
                _playGame(pChatWnd);
            } else {
                pChatWnd.SendMessage('That is wrong. The correct answer was: '+_answer+'.');
                _played = true;
                _playGame(pChatWnd);
            }
        }
    }
}


feel free to try this code

This post was edited on 11-28-2006 at 02:39 AM by matty.
11-28-2006 02:38 AM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: RE: [beta release] Math Games
doesnt really work.... but you have a good idea though :D

when i enter in command it will say COMMAND NOT FOUND
[quote]
Ultimatess6
: What a noob mod
11-28-2006 04:04 AM
Profile PM Web Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: [beta release] Math Games
quote:
Originally posted by roflmao456
doesnt really work.... but you have a good idea though :D

when i enter in command it will say COMMAND NOT FOUND
Oops wasn't able to test it I am at work.
code:
/*

made by me, roflmao456 aka john
beta

edited by Matty

*/


var _answer;
var _randomop;
var _random1;
var _random2;
var _on = new Boolean(false);
var _played = new Boolean(false);
var _op = new Array('+', '-', '*', '/');

function OnGetScriptCommands(){
    var ScriptCommands = '<ScriptCommands>';
    ScriptCommands += '<Command>';
    if (_on == false) {
        ScriptCommands += '<Name>mgamestart</Name>';
        ScriptCommands += '<Description>Starts the Math Game</Description>';
    } else {
        ScriptCommands += '<Name>mgamestop</Name>';
        ScriptCommands += '<Description>Stops the Math Game</Description>';
    }
    ScriptCommands += '</Command>';
    ScriptCommands += '</ScriptCommands>';
    return ScriptCommands;
}

function OnEvent_ChatWndSendMessage(pChatWnd, sMessage){
    if (_on == false){
        if (sMessage.toLowerCase() == '/mgamestart'){
            _on = true;
            MsgPlus.DisplayToast('Math Game', 'Math Game is now started.');
            _playGame(pChatWnd);
            return '';
        }
    } else {
        if (sMessage.toLowerCase() == '/mgamestop'){
            _on = false;
            MsgPlus.DisplayToast('Math Game','Math Game is now stopped.');
            _played = false;
            return '';
        }
    }
}

function _playGame(pChatWnd){
    Debug.Trace('_playGame function called.'); //start setting random question
    _random1 = Math.round(Math.random()*(99)+1);
    _random2 = Math.round(Math.random()*(99)+1);
    _randomop = Math.round(Math.random()*(_op.length-1));
    _answer = eval(_random1+_op[_randomop]+_random2); // set up the answer
    if (_played != true){
        _on = false;
        pChatWnd.SendMessage('Welcome to Math Game, I am going to ask you math questions.');
        pChatWnd.SendMessage('What is.. \n\n'+_random1+' '+_op[_randomop]+' '+_random2+'?');
        _on = true;
    } else {
        _on = false;
        pChatWnd.SendMessage('new Question!');
        pChatWnd.SendMessage('What is.. \n\n'+_random1+' '+_op[_randomop]+' '+_random2+'?');
        _on = true;
    }
}

function OnEvent_ChatWndReceiveMessage(pChatWnd, sOrigin, sMessage){
    if (_on == true){
        if (sOrigin != Messenger.MyName){
            if (sMessage == _answer){
                pChatWnd.SendMessage('That is correct!');
                _played = true;
                _playGame(pChatWnd);
            } else {
                pChatWnd.SendMessage('That is wrong. The correct answer was: '+_answer+'.');
                _played = true;
                _playGame(pChatWnd);
            }
        }
    }
}


that should work, I had _playGame() when it should be _playGame(pChatWnd).
11-28-2006 04:09 AM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: [beta release] Math Games
yay it works, thanks!

* Adds to reputation

lol nvm

PS: i only made this today LOL.... took only 20 minutes (wasn't thinking all of it)

This post was edited on 11-28-2006 at 04:18 AM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
11-28-2006 04:15 AM
Profile PM Web Find Quote Report
elektra
Full Member
***

Avatar
aka quacky

Posts: 210
Reputation: -3
– / Male / –
Joined: Jul 2006
RE: [beta UPDATE] Math Games
I hate maths, yet we all hate maths, but this script underlines the good points about maths...and its is funny when the contact gets the question wrong...
a suggestion is:
Maybe do a feature to randomly throw a question at the contact


:cheesy:
Good script anyway keep the work up
[Image: ps3_forum2.jpg][Image: x360_forum2.jpg]
11-28-2006 04:49 PM
Profile E-Mail PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: RE: [beta UPDATE] Math Games
quote:
Originally posted by quacky
a suggestion is:
Maybe do a feature to randomly throw a question at the contact


:D that means i will have to do alot of arrays of words :p lol

il try
[quote]
Ultimatess6
: What a noob mod
11-28-2006 08:56 PM
Profile PM Web 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