What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [release] Tic Tac Toe 2

Pages: (2): « First [ 1 ] 2 » Last »
[release] Tic Tac Toe 2
Author: Message:
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. Dodgy  [release] Tic Tac Toe 2
Tic Tac Toe 2


Play with your contact a game of Tic Tac Toe!

here it is.................

Command: type

/tic

/tac

or

/toe

to start a game

works if they have the script too..

.plsc File Attachment: Tic Tac Toe 2.plsc (336.85 KB)
This file has been downloaded 175 time(s).

This post was edited on 12-12-2006 at 11:19 PM by roflmao456.
[quote]
Ultimatess6
: What a noob mod
12-12-2006 11:18 PM
Profile PM Web Find Quote Report
DarkMe
Full Member
***

Avatar
Thx ins4ne for my av :p

Posts: 471
Reputation: 20
32 / Male / –
Joined: Jun 2006
RE: [release] Tic Tac Toe 2
* DarkMe downloads
Good Script (y)

no i dont have to wait til wlm starts the app :p
[Image: darkme.png]
12-12-2006 11:40 PM
Profile E-Mail PM Web Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: [release] Tic Tac Toe 2
Nice to see me in the about box ^o)

I thought I replaced that ugly white box with a transparent one to blend in?

As for opening a "Chat Window"... what do you think people talk in anyway? It doesn't NEED one.

Hope you fixed the logic errors in this one after you so kindly wrecked mine :refuck:

EDIT:
code:
var SW_MINIMIZE = 0x6;
Interop.Call('user32', 'ShowWindow', game.Handle, SW_MINIMIZE);


Why not:
code:
Interop.Call('user32', 'ShowWindow', game.Handle, 0x6);


This post was edited on 12-13-2006 at 12:00 AM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
12-12-2006 11:57 PM
Profile PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: RE: [release] Tic Tac Toe 2
quote:
Originally posted by SpunkyLoveMuff
code:
var SW_MINIMIZE = 0x6;
Interop.Call('user32', 'ShowWindow', game.Handle, SW_MINIMIZE);


Why not:
code:
Interop.Call('user32', 'ShowWindow', game.Handle, 0x6);


in my opinion its better/more convenient to use constants like that, however I'd declare them globally instead of locally in the function :/
12-13-2006 12:44 AM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [release] Tic Tac Toe 2
quote:
Originally posted by deAd
quote:
Originally posted by SpunkyLoveMuff
code:
var SW_MINIMIZE = 0x6;
Interop.Call('user32', 'ShowWindow', game.Handle, SW_MINIMIZE);


Why not:
code:
Interop.Call('user32', 'ShowWindow', game.Handle, 0x6);


in my opinion its better/more convenient to use constants like that, however I'd declare them globally instead of locally in the function :/

If it is just for 1 line of code, like in this script, you can do something like:

Interop.Call('user32', 'ShowWindow', game.Handle, /* SW_MINIMIZE */ 0x6);

-------------------------------------------------------------

anyways, roflmao456

some tips:

- Start by indenting lines of code properly with tabs. This will make possible errors and optimizations visible in an instant.

- Remove the need for all those global variables. You will need some global variables, but not all of those.

- Declaring an activex object in global space isn't needed at all. Declare it where you need it.

- Use an array as your play grid instead of all those sequencial variables a1, a2, a3, b1, b2, etc...

- Determining who won can be made shorter. And it also contains a duplicated check for both sides btw.

Don't check each side individually, but simply check if squares are equal (using the method above). And if they are, only then determine to which side the squares are belonging. In other words, use the opposite of the logic you use now. This will make the whole checking faster and shorter and will reduce the needed checks from the currently 18 to 8 checks.

And if you take in account the last move (which is the only one which might trigger a win situation of course) and you use an array as your playing grid you could reduce this even further to only 3 or 4 checks (for a horizontal, a vertical and a diagonal solution).

So you don't need all those checks since the only way that someone can have 3 in a row is when the middle square of the sequence is equal to the left and right side square of it, or upper and lower side of it, or up-left and down-right, or down-left and up-right. And if so, any of the three squares making a solution will always hold the sign of the winning party. Or even shorter: if a winning solution is made, the winning party will always be the one who last made a move, thus you actually don't even need to check the signs in the squares.

- Some code in checkWin() is also duplicated, so remove that and put it above the structure where it is nested in (the alertmsg and canMove variables).

In addition to this, since the only thing you change in the         if(won == "O"){} check is the name of the side that won, you can easly remove that check and simply place won as a variable in that sentence since it already identifies who won.

- In the OnEvent_Timer(timerId) function replaces those if_then_else's with a switch statement.

- Change the "!tic-tac-toe" command to "/tic-tac-toe". Commands in Plus! start with "/", so that is what the user is used to.
(and personally I would remove the "-" in the command, but that's just pure personal preference)

- Take in account that the user can type commands in uppercase to. So add a .tolowercase() to the command catching routines.

- The rest is just a big mess in code atm and I cba to fix all the indenting first to check the code further, see point 1 ;)

- Change things like:
code:
if (Origin != Messenger.MyName) {
    if (Message.substr(0,12) == "!tic-tac-toe"){
    }
}
if (Origin == Messenger.MyName){
    if (Message.substr(0,12) == "!tic-tac-toe"){
    }
}
to:
code:
if (Message.substr(0,12) === "!tic-tac-toe"){
    if (Origin === Messenger.MyName) {
    } else {
    }
}
which is shorter and easier to maintain.

- Chage stuff like
code:
if(Message.substr(0,3)!="!a1"){
if(Message.substr(0,3)!="!a2"){
if(Message.substr(0,3)!="!a3"){
if(Message.substr(0,3)!="!a1"){
if(Message.substr(0,3)!="!a2"){
if(Message.substr(0,3)!="!a3"){
if(Message.substr(0,3)!="!b1"){
if(Message.substr(0,3)!="!b2"){
if(Message.substr(0,3)!="!b3"){
if(Message.substr(0,3)!="!c1"){
if(Message.substr(0,3)!="!c2"){
if(Message.substr(0,3)!="!c3"){
//dosomething
}}}}}}}}}
to at least 1 check using an AND operator.
Or better yet, use a single regular expression.

Also you use such a bunch of checks twice inside an if_then_else, once for the true part and once for the false part. So switch this logic around and use those bunch of checks as the first main checks and only then do the check you otherwise did first (if(chat.GetControlText("chatAll")){).


- the design of the game window is nice (y)

This post was edited on 12-13-2006 at 02:49 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-13-2006 01:52 AM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: [release] Tic Tac Toe 2
quote:
Originally posted by CookieRevised
Take in account that the user can type commands in uppercase to. So add a .tolowercase() to the command catching routines

I think thats just a command that gets sent by the script to initiate the other players window so it will always be the same case.

Some problems with this script are partially my fault as the code its loosly based on a script I attempted when I first started scripting. However, functions such as canMove were added by ROFLMAO and are nothing to do with me.

@ROFLMAO: I know I said just release it under your name, but I didn't mean I wouldn't like any credit for the things that I did do

EDIT:
quote:
Originally posted by CookieRevised
If it is just for 1 line of code, like in this script, you can do something like:

Interop.Call('user32', 'ShowWindow', game.Handle, /* SW_MINIMIZE */ 0x6);

Just to make it clear that was the point I was making, about it not needing a constant for a single use

This post was edited on 12-13-2006 at 02:09 AM by Spunky.
<Eljay> "Problems encountered: shit blew up" :zippy:
12-13-2006 02:07 AM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: [release] Tic Tac Toe 2
quote:
Originally posted by SpunkyLoveMuff
I think thats just a command that gets sent by the script to initiate the other players window so it will always be the same case.
indeed, !tictactoe might not have been the best example, but my comment about taking in account letter case still stands.

This post was edited on 12-13-2006 at 02:26 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
12-13-2006 02:11 AM
Profile PM Find Quote Report
deAd
Scripting Contest Winner
*****

Avatar

Posts: 1060
Reputation: 28
– / Male / Flag
Joined: Jan 2006
RE: RE: [release] Tic Tac Toe 2
quote:
Originally posted by SpunkyLoveMuff
quote:
Originally posted by CookieRevised
If it is just for 1 line of code, like in this script, you can do something like:

Interop.Call('user32', 'ShowWindow', game.Handle, /* SW_MINIMIZE */ 0x6);

Just to make it clear that was the point I was making, about it not needing a constant for a single use

Oh, right. I'm used to having tons and tons of constants in my code, so what I said makes more sense to me :P
12-13-2006 02:58 AM
Profile PM Find Quote Report
Spunky
Former Super Mod
*****

Avatar

Posts: 3658
Reputation: 61
36 / Male / Flag
Joined: Aug 2006
RE: [release] Tic Tac Toe 2
quote:
Originally posted by CookieRevised
the design of the game window is nice

* Spunky does a little dance (and looks a mess doing it)

I wanted to be different so I started working on the interfaces a bit more to try and make something... different

@ROFLMAO: You should probably also display a warning somewhere that clsoing the conversation window will end the current game (as it will destroy the ChatWnd that you send the messages to
<Eljay> "Problems encountered: shit blew up" :zippy:
12-13-2006 04:01 AM
Profile PM Find Quote Report
roflmao456
Skinning Contest Winner
****

Avatar

Posts: 955
Reputation: 24
30 / Male / Flag
Joined: Nov 2006
Status: Away
O.P. RE: [release] Tic Tac Toe 2
quote:
Originally posted by CookieRevised

code:
if(Message.substr(0,3)!="!a1"){
if(Message.substr(0,3)!="!a2"){
if(Message.substr(0,3)!="!a3"){
if(Message.substr(0,3)!="!a1"){
if(Message.substr(0,3)!="!a2"){
if(Message.substr(0,3)!="!a3"){
if(Message.substr(0,3)!="!b1"){
if(Message.substr(0,3)!="!b2"){
if(Message.substr(0,3)!="!b3"){
if(Message.substr(0,3)!="!c1"){
if(Message.substr(0,3)!="!c2"){
if(Message.substr(0,3)!="!c3"){
//dosomething
}}}}}}}}}


that is saying "if the message at 0,3 doesn't equal *this*, do this." ... should it be "if the message at 0,3 equals *this*, do this" ?

quote:
Originally posted by CookieRevised

- the design of the game window is nice (Y)


dont say that 2 me :O say that to SpunkyLM
[quote]
Ultimatess6
: What a noob mod
12-13-2006 11:44 PM
Profile 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