Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-25-2004, 09:21 PM
Blue_Dragn Blue_Dragn is offline
Registered User
Join Date: Jul 2003
Posts: 302
Blue_Dragn is on a distinguished road
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.
__________________
No longer a Advertisement Goat
Reply With Quote
  #2  
Old 01-25-2004, 09:33 PM
DarkShadows_Legend DarkShadows_Legend is offline
Cult of the Winky
DarkShadows_Legend's Avatar
Join Date: Apr 2003
Location: Florida
Posts: 614
DarkShadows_Legend is on a distinguished road
Send a message via AIM to DarkShadows_Legend
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));

__________________
- Criminal X

"I rather be hated for being myself, than be liked for being what you like best. I go above the influence, not under." - Me
Reply With Quote
  #3  
Old 01-25-2004, 09:43 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Either PD has your answer, or you need to be more descriptive of your problem. Becouse the rest looks right.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #4  
Old 01-25-2004, 10:15 PM
Blue_Dragn Blue_Dragn is offline
Registered User
Join Date: Jul 2003
Posts: 302
Blue_Dragn is on a distinguished road
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
__________________
No longer a Advertisement Goat
Reply With Quote
  #5  
Old 01-25-2004, 11:37 PM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to 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.
Reply With Quote
  #6  
Old 01-25-2004, 11:52 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
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?
__________________
Reply With Quote
  #7  
Old 01-26-2004, 12:24 AM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
Quote:
Originally posted by ZeLpH_MyStiK

unset tword2; before the loop?
There is no flag to unset.
__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
  #8  
Old 01-26-2004, 12:28 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
Quote:
Originally posted by mhermher


There is no flag to unset.
unset teh string?
__________________
Reply With Quote
  #9  
Old 01-26-2004, 02:56 AM
R0bin R0bin is offline
Banned
R0bin's Avatar
Join Date: Oct 2002
Location: Wales, UK
Posts: 828
R0bin is on a distinguished road
Send a message via AIM to 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.
Reply With Quote
  #10  
Old 01-26-2004, 03:07 AM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
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.
__________________
Reply With Quote
  #11  
Old 01-26-2004, 10:43 AM
mhermher mhermher is offline
galase galase!
mhermher's Avatar
Join Date: Jun 2001
Location: Sweden, Stockholm.
Posts: 2,012
mhermher is on a distinguished road
Send a message via ICQ to mhermher Send a message via AIM to mhermher Send a message via Yahoo to mhermher
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?
__________________
Donate money for my trip to Germany

Adiarde Manager
Reply With Quote
  #12  
Old 01-26-2004, 02:34 PM
ZeLpH_MyStiK ZeLpH_MyStiK is offline
Scripter
ZeLpH_MyStiK's Avatar
Join Date: May 2003
Location: NYC
Posts: 553
ZeLpH_MyStiK is on a distinguished road
Send a message via MSN to ZeLpH_MyStiK Send a message via Yahoo to ZeLpH_MyStiK
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.
__________________
Reply With Quote
  #13  
Old 01-26-2004, 06:09 PM
osrs osrs is offline
Graalian since 1998
osrs's Avatar
Join Date: Mar 2002
Location: Brazil
Posts: 2,724
osrs is on a distinguished road
Send a message via ICQ to osrs Send a message via AIM to osrs Send a message via MSN to osrs Send a message via Yahoo to osrs
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:
__________________
"Ability is what you are capable of doing. Motivation determines what you do. Attitude determines how well you do it."
Facebook: facebook.com/raysilvadotnet /
Reply With Quote
  #14  
Old 01-26-2004, 08:58 PM
-Ramirez- -Ramirez- is offline
Registered User
Join Date: Jun 2002
Location: USA, Ohio
Posts: 729
-Ramirez- has a spectacular aura about-Ramirez- has a spectacular aura about
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...
__________________
Kat

Last edited by -Ramirez-; 01-26-2004 at 09:09 PM..
Reply With Quote
  #15  
Old 01-26-2004, 09:39 PM
DIABLO2099 DIABLO2099 is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 290
DIABLO2099 is on a distinguished road
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.
__________________
-Former UnholyNation Server Manager.

Call me Xecutor.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:29 PM.


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