Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   string manipulation (https://forums.graalonline.com/forums/showthread.php?t=64842)

excaliber7388 03-20-2006 04:11 AM

string manipulation
 
#T and #e I've read how the wiki says to use them, but I can't get it right x_X
PHP Code:

//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
NPC Code:

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


Riot 03-20-2006 04:58 AM

Quote:

Originally Posted by Maniaman
Hmm, I am not sure, but you might try
NPC Code:

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
PHP Code:

if (str.starts("coat")) 

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

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

Quote:

Originally Posted by lancelot9
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.

PHP Code:

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



Yen 03-21-2006 10:03 PM

Quote:

Originally Posted by lancelot9
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?
PHP Code:

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

Quote:

Originally Posted by Yen
... Because /skin is 5 characters long.

Haha.
Quote:

Originally Posted by Yen
If you include the space, 6 characters long.

.trim() truncates leading and following spaces.

excaliber7388 03-22-2006 05:55 PM

Quote:

Originally Posted by ApothiX
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.

NPC Code:

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


Skyld 03-22-2006 09:34 PM

Quote:

Originally Posted by Warcaptain
Also in substring() you need to tell it how long as well.

NPC Code:

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.
PHP Code:

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

... is perfectly acceptable.

Warcaptain 03-22-2006 11:02 PM

oh, my bad.

well thats great :)


All times are GMT +2. The time now is 09:25 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.