[beta UPDATE] Math Games - Printable Version
-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [beta UPDATE] Math Games (/showthread.php?tid=68916)
[beta UPDATE] Math Games by roflmao456 on 11-27-2006 at 11:24 PM
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
please reply if you found something bad
RE: [beta release] Math Games by matty on 11-27-2006 at 11:47 PM
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.
RE: [beta release] Math Games by roflmao456 on 11-28-2006 at 12:42 AM
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..
RE: [beta release] Math Games by dylan! on 11-28-2006 at 12:44 AM
..∂уℓαη --| 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.
RE: [beta release] Math Games by matty on 11-28-2006 at 02:38 AM
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
RE: RE: [beta release] Math Games by roflmao456 on 11-28-2006 at 04:04 AM
doesnt really work.... but you have a good idea though
when i enter in command it will say COMMAND NOT FOUND
RE: [beta release] Math Games by matty on 11-28-2006 at 04:09 AM
quote: Originally posted by roflmao456
doesnt really work.... but you have a good idea though
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).
RE: [beta release] Math Games by roflmao456 on 11-28-2006 at 04:15 AM
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)
RE: [beta UPDATE] Math Games by elektra on 11-28-2006 at 04:49 PM
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
Good script anyway keep the work up
RE: RE: [beta UPDATE] Math Games by roflmao456 on 11-28-2006 at 08:56 PM
quote: Originally posted by quacky
a suggestion is:
Maybe do a feature to randomly throw a question at the contact
that means i will have to do alot of arrays of words lol
il try
|