PDA

View Full Version : string manipulation


excaliber7388
03-20-2006, 04:11 AM
#T and #e I've read how the wiki says to use them, but I can't get it right x_X
//GS1
if (startswith(coat,#c))
{
setplayerprop #c(1),#T(#e(4,-1,#c));
}
//my gs2 nightmare
if(str.starts("coat"))
{
player.colors[1]=??????????
}

Maniaman
03-20-2006, 04:32 AM
Hmm, I am not sure, but you might try

player.colors[1]=player.chat.trim(player.chat.substring(4,-1));

Riot
03-20-2006, 04:58 AM
Hmm, I am not sure, but you might try

player.colors[1]=player.chat.trim(player.chat.substring(4,-1));


player.chat.substring(4).trim();

Ajira
03-20-2006, 09:30 PM
You are also just doing

if (str.starts("coat"))

To check that the player actually says 'coat' first, do

if (player.chat.starts("coat"))

lancelot9
03-21-2006, 10:01 AM
Welll. Ok here it goes.

First of all the T-3a scriptline and the T-4c SL are interlocked with eachother, this means you have to devide them with a sub script line (such as a simple action command), like you split them apart. Its kinda like shoe strings, you cant walk with both foot's shoes strings tied together, so you tie them seperatly.

PHP Code:
//GS1
if (startswith(coat,#c))
{
if (playerenters) {
playlooped fire-torch2.wav; > (Sub SL)
}
setplayerprop #c(1),#T(#e(4,-1,#c));
if (created) {
y=56.6;
setcoloreffect 0,1,0,0.2;
drawaslight;
}!!(7x(4x+5=3+2x))x a+b=c/Dtall;[Alphatest]
}
//my gs2 nightmare
if(str.starts("coat"))
{
player.colors[1]=??????????
}

Second I have no idea what im talking about

ApothiX
03-21-2006, 03:15 PM
Welll. Ok here it goes.

First of all the T-3a scriptline and the T-4c SL are interlocked with eachother, this means you have to devide them with a sub script line (such as a simple action command), like you split them apart. Its kinda like shoe strings, you cant walk with both foot's shoes strings tied together, so you tie them seperatly.

PHP Code:
//GS1
if (startswith(coat,#c))
{
if (playerenters) {
playlooped fire-torch2.wav; > (Sub SL)
}
setplayerprop #c(1),#T(#e(4,-1,#c));
if (created) {
y=56.6;
setcoloreffect 0,1,0,0.2;
drawaslight;
}!!(7x(4x+5=3+2x))x a+b=c/Dtall;[Alphatest]
}
//my gs2 nightmare
if(str.starts("coat"))
{
player.colors[1]=??????????
}

Second I have no idea what im talking about
Hrm, try to use code blocks for things like that. And also, in your gscript1 version of it, you should not be using code outside event blocks.

if(player.chat.starts("coat")) {
player.colors[1] = player.chat.substring("coat".length(), -1).trim();
}

Yen
03-21-2006, 10:03 PM
Welll. Ok here it goes.

First of all the T-3a scriptline and the T-4c SL are interlocked with eachother, this means you have to devide them with a sub script line (such as a simple action command), like you split them apart. Its kinda like shoe strings, you cant walk with both foot's shoes strings tied together, so you tie them seperatly.

PHP Code:
//GS1
if (startswith(coat,#c))
{
if (playerenters) {
playlooped fire-torch2.wav; > (Sub SL)
}
setplayerprop #c(1),#T(#e(4,-1,#c));
if (created) {
y=56.6;
setcoloreffect 0,1,0,0.2;
drawaslight;
}!!(7x(4x+5=3+2x))x a+b=c/Dtall;[Alphatest]
}
//my gs2 nightmare
if(str.starts("coat"))
{
player.colors[1]=??????????
}

Second I have no idea what im talking about

This makes me miss Excalibur.

excaliber7388
03-21-2006, 11:20 PM
soooo why doesn't this work?

if (player.chat.starts("/skin"))
{
player.colors[0] = player.chat.substring(4).trim();
}

Yen
03-21-2006, 11:55 PM
... Because /skin is 5 characters long.
If you include the space, 6 characters long.

ApothiX
03-22-2006, 03:22 PM
... Because /skin is 5 characters long.Haha.
If you include the space, 6 characters long..trim() truncates leading and following spaces.

excaliber7388
03-22-2006, 05:55 PM
Haha.
ya ha ha x_X tha actual problem was earlier in the script, bu yeah, i missed that too :rolleyes: I was hoping this thread would curl up and die after that, so no one would know about it XD

Warcaptain
03-22-2006, 09:03 PM
Also in substring() you need to tell it how long as well.


player.colors[0] = player.chat.substring(4,-1).trim();

Skyld
03-22-2006, 09:34 PM
Also in substring() you need to tell it how long as well.


player.colors[0] = player.chat.substring(4,-1).trim();

In new gscript, you do not need to specify a second parameter for substring() if you only want to specify an offset and continue to the end of the string.
player.colors[0] = player.chat.substring(4).trim();
... is perfectly acceptable.

Warcaptain
03-22-2006, 11:02 PM
oh, my bad.

well thats great :)