Blockland Forums > Modification Help

How to filter and replace a chat segment

Pages: (1/5) > >>

frogger3140:

Example, if I said Hello World on chat, world will be changed to Changed.

AppleScript-style psuedocode for whoever needs to know

--- Code: ---get chatMsg
if "World" is present in chatMsg then
modify chatMsg
change "World" to "Changed"
end modify
end if
say chatMsg

--- End code ---


MegaScientifical:

I'm curious as to the most efficient way to do it. I used to use strReplace, but I noticed that's case sensitive. I've made workarounds, but I won't suggest any.

DrenDran:


--- Code: ---%string = "Hello world, testing.";
if(%a = strpos(%string,"hello world") > 0)
{
%string = erase(%string,%a,11);
}

--- End code ---

If erase was a function in torque like it is in C++ that would work to remove an instance of "hello world" from the string.
But I don't know if it is.

Julius The 1st:


--- Quote from: MegaScientifical on November 28, 2010, 02:38:00 AM ---I used to use strReplace, but I noticed that's case sensitive.
--- End quote ---
Just wondering, but won't striReplace be non-case sensitive?

frogger3140:


--- Quote from: DrenDran on November 28, 2010, 08:40:39 AM ---
--- Code: ---%string = "Hello world, testing.";
if(%a = strpos(%string,"hello world") > 0)
{
%string = erase(%string,%a,11);
}

--- End code ---

If erase was a function in torque like it is in C++ that would work to remove an instance of "hello world" from the string.
But I don't know if it is.

--- End quote ---

I don't want it removed, I just want it changed to another word.

Pages: (1/5) > >>

Go to full version