Blockland Forums > Modification Help

Client_Punctuation Help

Pages: (1/6) > >>

PurpleMetro:

I got a mod where it would automatically punctuate your sentence when you type, but it's not working. Please help?

The 'client.cs' without any ''s

--- Code: ---//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
//Title: Punctuation
//Author: Secton
//Description: Punctuates for you.
//Summery: Adds some Punctuation for you.
//Licence: Free
//=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


package Punctuation
{
    function GlobleChat(%clanPre, %name, %clanSuf, %Msg)
    {    //run it though the filter
        strreplace(%Msg,nt,"n't");
        //This replaces "nt" with "n't"
        %LwrI = getWord(%Msg, i );
        //find a lowercase I...
        %UprI = strUpr(%Ilwr);
        //Turn it upercase
        strreplace(%Msg,%LwrI,%UprI);
        //Apply it to %msg
        strreplace(%Msg,youre,"you're");
        //make sure you're has "u're" in it   
        strreplace(%Msg,Im,"I'm");
        //its I am, not Im.
        parent::GlobleChat(%Msg);
        //Do all the other stuff you do.
    }
};
ActivatePackage(Punctuation);
--- End code ---

And the description.txt


--- Code: ---Title: Punctuation
Author: Secton
Automatic Punctuation for you

--- End code ---


Treynolds416:

I stopped as soon as I saw "globle"

PurpleMetro:


--- Quote from: Treynolds416 on May 11, 2012, 08:34:32 PM ---I stopped as soon as I saw "globle"

--- End quote ---
I didn't look through this that much T_T.
Is it supposed to be 'GlobalChat', and is that a pre-existing function?

otto-san:

A few problems:

strReplace returns a value, it doesn't do any magic to set it.
You'd have to set a variable to what it returns.

getWord's arguments are %string and %index, it returns the %indexth/st/rd word in the string. If you want to find if there's word, you have to make a function to do it (because there's not a default one in torque for some reason)

Here's one I made which seems to work:

--- Code: ---function findWord(%sourceString, %searchWord)
{
for(%i = 0; %i < getWordCount(%sourceString); %i++)
{
if(getWord(%sourceString, %i) $= firstWord(%searchWord))
return %i;
}
return -1;
}
--- End code ---


Your usage of strUpr sorta makes sense, but you have to have a way to put the uppercase I back into the string.


and when you're calling the parent, it's a good idea to include all the arguments.

Xalos:

"Hey, how do I ren't a boat?"

Hahaha no.

Pages: (1/6) > >>

Go to full version