Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   strlen + #e (https://forums.graalonline.com/forums/showthread.php?t=50614)

Blue_Dragn 01-25-2004 09:21 PM

strlen + #e
 
well im having a little scriptproblem

what i want is for it to take each letter of a string one by one, but i dont think im doing it quite right

NPC Code:

...
for (i=0;i<strlen(#s(this.word));i++) {
setstring this.word2,#e(i,1,#s(this.word));
}
...



i guess thats where ive narrowed it to not working, because it wont take it piece by piece.

DarkShadows_Legend 01-25-2004 09:33 PM

lets say this.word2 = hello

Your script will set the string accordingly
this.word2 = h
this.word2 = e
this.word2 = l
this.word2 = l
this.word2 = o

if you want it as a list you will have to use addstring

example
NPC Code:

for(i = 0; i < strlen(#s(this.word2)); i ++)
addstring this.word2,#e(i,1,#s(this.word2));


adam 01-25-2004 09:43 PM

Either PD has your answer, or you need to be more descriptive of your problem. Becouse the rest looks right.

Blue_Dragn 01-25-2004 10:15 PM

ok i missed exactily what my point was, so far it is working right with the way you suggested to fix it, but it broke up all the parts and made a list with commas like

h,e,l,l,o
but i fixed it thanks for your help :)

R0bin 01-25-2004 11:37 PM

setstring tword,Blahblah;
for (i=0;i<strlen(#s(tword));i++) {
setstring tword2,#s(tword2)#e(i,1,#s(tword));
}

gives you

tword=Blahblah
tword2=BlahblahB

I dont know why it puts the B on thend, musta buggered up somewheres.

ZeLpH_MyStiK 01-25-2004 11:52 PM

Quote:

Originally posted by R0bin
setstring tword,Blahblah;
for (i=0;i<strlen(#s(tword));i++) {
setstring tword2,#s(tword2)#e(i,1,#s(tword));
}

gives you

tword=Blahblah
tword2=BlahblahB

I dont know why it puts the B on thend, musta buggered up somewheres.

unset tword2; before the loop?

mhermher 01-26-2004 12:24 AM

Quote:

Originally posted by ZeLpH_MyStiK

unset tword2; before the loop?

There is no flag to unset.

ZeLpH_MyStiK 01-26-2004 12:28 AM

Quote:

Originally posted by mhermher


There is no flag to unset.

unset teh string?

R0bin 01-26-2004 02:56 AM

setstring tword2,;
setstring tword,Blahblah;
for (i=0;i<strlen(#s(tword));i++) {
setstring tword2,#s(tword2)#e(i,1,#s(tword));
}

Still gives BlahblahB, dunno why.

ZeLpH_MyStiK 01-26-2004 03:07 AM

Quote:

Originally posted by R0bin
setstring tword2,;
setstring tword,Blahblah;
for (i=0;i<strlen(#s(tword));i++) {
setstring tword2,#s(tword2)#e(i,1,#s(tword));
}

Still gives BlahblahB, dunno why.

That's weird i tried it and it didnt give me what, it gave me Blahblah x.x.

mhermher 01-26-2004 10:43 AM

Quote:

Originally posted by ZeLpH_MyStiK

That's weird i tried it and it didnt give me what, it gave me Blahblah x.x.

"unset tword2;" That is unsetting a FLAG.
"setstring tword2,;" That is "unsetting" a string..

You cant assume stuff like that, ye know?

ZeLpH_MyStiK 01-26-2004 02:34 PM

Quote:

Originally posted by mhermher


"unset tword2;" That is unsetting a FLAG.
"setstring tword2,;" That is "unsetting" a string..

You cant assume stuff like that, ye know?

They both work -.- Try it out before you tell someone incorrect information please.

osrs 01-26-2004 06:09 PM

Quote:

Originally posted by ZeLpH_MyStiK

They both work -.- Try it out before you tell someone incorrect information please.

You were actually wrong so shhh. :grin:

-Ramirez- 01-26-2004 08:58 PM

Quote:

Originally posted by R0bin
setstring tword2,;
setstring tword,Blahblah;
for (i=0;i<strlen(#s(tword));i++) {
setstring tword2,#s(tword2)#e(i,1,#s(tword));
}

Still gives BlahblahB, dunno why.

Wtf, a script did something similar to me before. After experimenting with it a minute ago... I think I know what does it. The script was being ran through the second you put it in a level and clicked "Close" on the script dialog. It set the first two strings, ignored the loop, and set the string inside of the for loop. Since i hadn't been set to anything yet, it was set as 0, so it set "tword2" as B initially. ...but that wouldn't explain why it stayed there even after you clicked "Play", since it should have unset tword2 before running through the loop. Weird.

Ok... nor does that explain why the B is on the END of your string...
OH, wait, did you use the debugger to view the string, or did you press F4 and look at the flag list? If you used F4, it might have re-parsed through the script and did what I said at the beginning. That would explain the B at the end rather than the beginning.

Yeah, I just tested out that theory. That's exactly what it seems to be doing. Obviously a bug, as it shouldn't be going inside of a loop when it sets initial strings. Well, it's a bit awkward that it would even set strings before entering the level anyway...

DIABLO2099 01-26-2004 09:39 PM

Quote:

Originally posted by -Ramirez-

Wtf, a script did something similar to me before. After experimenting with it a minute ago... I think I know what does it. The script was being ran through the second you put it in a level and clicked "Close" on the script dialog. It set the first two strings, ignored the loop, and set the string inside of the for loop. Since i hadn't been set to anything yet, it was set as 0, so it set "tword2" as B initially. ...but that wouldn't explain why it stayed there even after you clicked "Play", since it should have unset tword2 before running through the loop. Weird.

Ok... nor does that explain why the B is on the END of your string...
OH, wait, did you use the debugger to view the string, or did you press F4 and look at the flag list? If you used F4, it might have re-parsed through the script and did what I said at the beginning. That would explain the B at the end rather than the beginning.

Yeah, I just tested out that theory. That's exactly what it seems to be doing. Obviously a bug, as it shouldn't be going inside of a loop when it sets initial strings. Well, it's a bit awkward that it would even set strings before entering the level anyway...

Hm, maybe if you delay the script for a tenth of a second or more it might be enough delay to make it run correctly, I'm not really sure =x.


All times are GMT +2. The time now is 04:12 PM.

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