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

Pages: (2): « First [ 1 ] 2 » Last »
Flip Text Script
Author: Message:
Tawa
New Member
*


Posts: 8
34 / Male / Flag
Joined: Dec 2009
O.P. Flip Text Script
Hello for all,

I've made a simple script called FlipText, you can download it from here. I hope you guys like it.

Since I don't have a better place to receive feedback and suggestions, I thought about opening a thread in this forum for this purpose.

So, I hope you like my script, and please share your feedback and suggestions.

If you check the code, you'll notice that it's too messy :p anyhow, I changed a few things, and added some stuff to it.

For the next version of the script, I added the following:
- Flipon/Flipoff option, so that the script would flip every message you send without the command /flip
- Tweaked the code of course.
- Added the option to flip the text before sending it.

Working On:
- Flipon/Flipoff option for each conversation separately.
- Adding support for letters with accents.

Known Bugs:
- Flipping the PSM for the first time after signing in would clear the PSM, if however the PSM has not been edited at least once since login[Apparently it is a bug from Messenger Plus.]

Again, I'll be glad to hear any suggestions that would make this script more fun.

Thanks in Advance.

Tawa Nicolas
03-02-2010 08:19 AM
Profile PM Find Quote Report
matty
Scripting Guru
*****


Posts: 8336
Reputation: 109
39 / Male / Flag
Joined: Dec 2002
Status: Away
RE: Flip Text Script
One suggestion would to make a single function that has a parameter which is the text you want to flip. Then at the end of the script return the temp variable and then you can assign it as the name or PSM or the text in the conversation.
03-02-2010 01:48 PM
Profile E-Mail PM Find Quote Report
Tawa
New Member
*


Posts: 8
34 / Male / Flag
Joined: Dec 2009
O.P. RE: Flip Text Script
I already did that. And to be honest I was expecting someone to tell me to do it :p

This post was edited on 03-02-2010 at 06:00 PM by Tawa.
03-02-2010 05:59 PM
Profile PM Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Flip Text Script
When I first saw the topic I thought: "Oh no.. , not another entire script to simply swap a string from left to right :p" (as you can do that in one line of code, see below). But I must say, I am pleasantly surprised to see you took it a step further with a twist (almost literally :D).

Anyways...

The whole process to replace a character with another in OnEvent_ChatWndSendMessage() can already be made more efficient if you integrate the second 'For' loop (line 74) into the first (line 62).

At this moment you do:
- iterate thru the original string and replace character x with y
- iterate thru the new string and flip it left to right.

This means 2 times iterating thru the entire string.
Together with that you also look up a part of the string deep inside the loop each time to build your new string (and even two times: the stuff which is in front of the replaced character, and the stuff which comes after it), this is very slow and not needed.

All you need is the actual new character in the loop. Do the concatenation later, after the whole loop. The benefit is also that you can immediatly add the new character at the end of the new string instead of at the beginning (and then later start a new loop to swap from left to right), thus automatically swapping the string from left to right too.

improvement example:
Javascript code:
var temp = Message.substring(6);
var str = "";
var charNew = "";
for(var i = 0; i < temp.length; i++){
    // Assign the new character to the original character in case
    // there is no replacement. Note: this also features a double
    // purpose, see next comment.
    charNew = temp.charAt(i);
    for(var j = 0; j < alpha.length; j++){
        // Also note that I replaced all the temp.charAt(i) with charNew
        // eliminating all the (slow) string lookups.
        if(charNew === alpha[j] || charNew === kappa[j]){
            charNew = omega[j];
            break;
        }
        if(charNew === omega[j]){
            charNew = alpha[j];
            break;
        }
    }
    // instead of doing 'str+=charNew' and then making another loop to
    // swap everything from left to right, we immediatly add the new
    // character to the end of the new string
    str = CharNew + str;
}
return str;

Also note the change from == (equality operator) to === (identity operator) which is faster.
See CookieRevised's reply to Script about lock messenger


----

PS: if you ever want to swap an entire string from left to right, instead of this:
Javascript code:
var OriginalStr = "Hello World";
var NewStr = "";
for(var i = OriginalStr.length-1; i >= 0; i--){
    NewStr+=temp.charAt(i);
}
return New Str

you can also do this:
Javascript code:
var OriginalStr = "Hello World";
return OriginalStr.split('').reverse().join('')



;)

This post was edited on 03-03-2010 at 03:35 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
03-03-2010 03:06 AM
Profile PM Find Quote Report
Tawa
New Member
*


Posts: 8
34 / Male / Flag
Joined: Dec 2009
O.P. RE: Flip Text Script
CookieRevised, thanks a lot for the clarifications.

I had already replaced the Reverse function, but never knew that temp.charAt() slows the process. And the === thing looks good now to me :p

Anyways, I'm new to JavaScript, I got little experience in it. But I'm learning from this :D

Thanks again.
03-03-2010 04:23 PM
Profile PM Find Quote Report
billyy
Full Member
***

Avatar

Posts: 103
Reputation: 1
36 / Male / Flag
Joined: Feb 2010
Status: Away
RE: Flip Text Script
A litle part on what it does would be cool?
Hmm too bad uppercase doesn't work that well and some numbers look ****py but i like it :D

This post was edited on 03-03-2010 at 04:55 PM by billyy.
I'm new at this, so don't expect me to be usefull any
time soon. But if i behaved you could rep me :P
03-03-2010 04:25 PM
Profile E-Mail PM Find Quote Report
Spongshga
Junior Member
**

Avatar
reporter

Posts: 44
33 / – / Flag
Joined: Aug 2008
RE: Flip Text Script
SmilieBUG:

Report:
bug with "^^" smilie!!! make it "vv" | ^=v

quote:
Orginaltext: "this was a funny joke ^^"
FlipText: "^^ &#477;&#670;o&#638; &#654;uun&#607; &#592; s&#592;&#653; s&#305;&#613;&#647;"

BugfreeFixed FlipText: "vv &#477;&#670;o&#638; &#654;uun&#607; &#592; s&#592;&#653; s&#305;&#613;&#647;"

Screen:
[Image: vvBug.png]


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

Textformation
make a option to set "ABC" in "abc"

.png File Attachment: vvBug.png (3.53 KB)
This file has been downloaded 123 time(s).

This post was edited on 03-04-2010 at 08:34 PM by Spongshga.
[Image: 6hxggzng.gif]
[Image: 4lr87q.jpg]
03-04-2010 08:25 PM
Profile E-Mail PM Web Find Quote Report
davidpolitis
Full Member
***


Posts: 371
Reputation: 16
Joined: Aug 2006
RE: RE: Flip Text Script
quote:
Originally posted by Tawa

Anyways, I'm new to JavaScript, I got little experience in it. But I'm learning from this :D
Messenger Plus! Live scripts are written in JScript, not JavaScript.

This post was edited on 03-07-2010 at 11:20 AM by davidpolitis.
03-07-2010 11:18 AM
Profile PM Find Quote Report
Tawa
New Member
*


Posts: 8
34 / Male / Flag
Joined: Dec 2009
O.P. RE: RE: Flip Text Script
quote:
Originally posted by billyy
Hmm too bad uppercase doesn't work that well and some numbers look ****py but i like it :D
I could enable capital letters, but they would look sh**ier than flipped numbers.

Turning this:
AB
C
DEFGHI
J
KLMNOPQRSTUVWXYZ
Will give this:

[Image: capturezn.png]

quote:
Originally posted by Spongshga
SmilieBUG:

Report:
bug with "^^" smilie!!! make it "vv" | ^=v

quote:
Orginaltext: "this was a funny joke ^^"
FlipText: "^^ &#477;&#670;o&#638; &#654;uun&#607; &#592; s&#592;&#653; s&#305;&#613;&#647;"

BugfreeFixed FlipText: "vv &#477;&#670;o&#638; &#654;uun&#607; &#592; s&#592;&#653; s&#305;&#613;&#647;"

Screen:
[Image: vvBug.png]


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

Textformation
make a option to set "ABC" in "abc"

Thank you for your effort in pointing me to this :p
Replacing ^ with the letter v would change the sentence, so I added a character I found in Windows' Character Map which resembles the letter 'v'

quote:
Originally posted by davidpolitis
quote:
Originally posted by Tawa

Anyways, I'm new to JavaScript, I got little experience in it. But I'm learning from this :D
Messenger Plus! Live scripts are written in JScript, not JavaScript.

Thank you for pointing this out. :D

This post was edited on 03-07-2010 at 11:47 PM by Tawa.
03-07-2010 11:44 PM
Profile PM Find Quote Report
Tawa
New Member
*


Posts: 8
34 / Male / Flag
Joined: Dec 2009
O.P. RE: Flip Text Script
Script update is now live :)
03-10-2010 08:20 PM
Profile PM 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