Blockland Forums > Modification Help

Modify word in sentence?

Pages: << < (3/4) > >>

herb:


--- Quote from: Pew446 on August 04, 2010, 01:03:59 AM ---How would I use this with variables?

Such as:

%var = "123 444 987";

setword(%var, 1, -= 10);

Or something?

--- End quote ---

what are you trying to do?

in words please

MegaScientifical:


--- Code: ---function switchWord(%text, %word, %replace) {
%r = 0;
for(%i = 0; %i < getWordcount(%text); %i++) {
if(getWord(%text, %i) $= %word) {
%text = setWord(%text, %i, %replace);
%r = 1;
}
}
return %r;
}
--- End code ---

That should work. And I added a return if it changes any words.

Pew446:


--- Quote from: herb on August 04, 2010, 01:31:38 AM ---what are you trying to do?

in words please

--- End quote ---

I want to do %var = %var - 10, but inside of the setword.

However this seems like a pain:

setword(%var, 1, (getword(%var, 1) - 10));

Pew446:


--- Quote from: MegaScientifical on August 04, 2010, 02:11:29 AM ---
--- Code: ---function switchWord(%text, %word, %replace) {
%r = 0;
for(%i = 0; %i < getWordcount(%text); %i++) {
if(getWord(%text, %i) $= %word) {
%text = setWord(%text, %i, %replace);
%r = 1;
}
}
return %r;
}
--- End code ---

That should work. And I added a return if it changes any words.

--- End quote ---

Wouldn't that just be the same as setWord?

Kalphiter:


--- Quote from: Pew446 on August 04, 2010, 11:41:23 AM ---Wouldn't that just be the same as setWord?

--- End quote ---
switch, you dumbass.

Pages: << < (3/4) > >>

Go to full version