Blockland Forums > Modification Help

Modify word in sentence?

Pages: (1/4) > >>

Pew446:

Lets say I have a sentence:

%words = "Happy flappy crappy"

And I wanna modify flappy to be trappy.

How would I go about doing this without doing this:

--- Code: ---%words = getword(%words, 0) SPC "trappy" SPC getword(%words, 2);

--- End code ---

Same goes for if the words were completely random and I wanted to change the center to trappy.


Headcrab Zombie:

%words = setWord(%words,1,"trappy");

herb:

or for a random

%words= "Happy flappy crappy";

%random=getRandom(1,3) or instead of 3, you can use getwordcount(%words);

%replace=getWord(%words,%random);

%words=strReplace(%words,%replace,"Trappy");

this will change a random word, to trappy

Headcrab Zombie:

Using strReplace would replace every occurance of %replace , if you just want to change that one you would do %words = setWord(%words,%random,"trappy");

herb:

but i dont see any other 'occurances' in the string

but yeah, setword would work better

Pages: (1/4) > >>

Go to full version