Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Strings (https://forums.graalonline.com/forums/showthread.php?t=48095)

SaijinGohan 09-19-2003 11:19 PM

Strings
 
Ok I have been working diligently to create a Mailbox system for the Bravo Online playerhouses. I have EVERYTHING working great. But there is one thing I have come across which I knew would be a problem. So heres what I have come up with:
Suppose I have a message 30 characters long. Now lets say graal can only hold 10 per line in a say2. I can get how many lines I need by dividing 30 by 10. I get 3. Right? Right. Now this paragraph is in a string. How am I going to get a #b after every 10 characters for every line until maxlines (3) - 1. The last part is to keep an extra #b after the last line in a message.

If this were a variable I could do it, but I do not operate well with strings. Anyone have an idea?

Kaimetsu 09-20-2003 04:35 AM

Just loop through and insert them in before say2-ing it. I'm pretty sure that works now.

Goboom 09-20-2003 05:08 AM

Quote:

Originally posted by Kaimetsu
Just loop through and insert them in before say2-ing it. I'm pretty sure that works now.
If he listens to you and does it this way I am going to beat him like the red-headed step child he is. I already told him to do it this way.

SaijinGohan 09-20-2003 05:37 AM

so I gotta work with the strings before hand.


so

NPC Code:

setstring thiso.umessage,blahblahblahblah;
this.chars = strlen(thiso.umessage);
this.loops = int(this.chars/10);
for (a=0;a<this.loops;a++) {
//insert #b stuff here?
}



I think this is how it should go but the problem is getting the #b into the string. I've been looking around and trying several different things but I can only think of setting a new string for every 10 chars. Inefficient I think.

Dach 09-20-2003 07:54 AM

all in one string? use #e(startindex,length,string) for the previous part of the string being examined, and another for the end, then setstring string,#s(partstr1) #b #s(partstr2)

Ah, the power of strings...


[Edit] Note: my syntax is probably wrong :\

Kaimetsu 09-20-2003 08:00 AM

v3 provides a few new options for this kind of thing, but currently #e is probably your best bet.

adam 09-20-2003 08:24 AM

couldn't he use wraptext?

or am I missing something.

Kaimetsu 09-20-2003 08:57 AM

Quote:

Originally posted by adam
am I missing something.
Yes.

SaijinGohan 09-20-2003 05:08 PM

Ok so I'll just #e the token and add #b where needed. Thx!

adam 09-20-2003 06:54 PM

Quote:

Originally posted by Kaimetsu


Yes.

Why isn't

NPC Code:

// NPC made by Rogue Shadow

if (playertouchsme) {
wraptext 25,,#c;
setstring temp,;
for (i=0;i<tokenscount;i++)setstring temp,#s(temp)#t(i)#b;
say2 #s(temp)#b;
}



What he is looking for? This way it won't break up words?

SaijinGohan 09-20-2003 08:47 PM

Wow thats working but its not breaking it up. That #b causes every word to be on a new line. I dunno if its something faulty withe code or what but perhaps because I am running the script serverside? Its a class.

adam 09-20-2003 09:38 PM

Quote:

Originally posted by SaijinGohan
Wow thats working but its not breaking it up. That #b causes every word to be on a new line. I dunno if its something faulty withe code or what but perhaps because I am running the script serverside? Its a class.
what is causing every word to be on a new lline? Show some code?

Dach 09-20-2003 10:18 PM

he copy and pasted, that's bad

SaijinGohan 09-21-2003 08:25 PM

Well since my other post disappeared. -.-

NPC Code:
for (i=0;i<tokenscount;i++)setstring temp,#s(temp)#t(i)#b;



That #b is causing each word to be on a new line. :/ I don't think the wraptext is working. Maybe because it's serverside or does that not matter with wraptext?

GoZelda 09-21-2003 08:31 PM

Maybe there would be an easier way if we knew how this script was made. Maybe you should try to use string lists in some sort of way...

SaijinGohan 09-21-2003 10:41 PM

Ok well I've figured it out. wraptext wont work the way I need it to be used. I'll use #e.

DustyPorViva 09-21-2003 11:00 PM

Quote:

Originally posted by SaijinGohan
Ok well I've figured it out. wraptext wont work the way I need it to be used. I'll use #e.
wraptext works with pixels I believe?

adam 09-21-2003 11:22 PM

Quote:

Originally posted by SaijinGohan
Well since my other post disappeared. -.-

NPC Code:
for (i=0;i<tokenscount;i++)setstring temp,#s(temp)#t(i)#b;



That #b is causing each word to be on a new line. :/ I don't think the wraptext is working. Maybe because it's serverside or does that not matter with wraptext?

no... that can't be the problem works fine for me.. would for you to if you just put it in an npc in an emtpy level and said something and touched it.

Python523 09-21-2003 11:41 PM

Quote:

Originally posted by DustyPorViva


wraptext works with pixels I believe?

wraptext2 does, wraptext doesn't

Mal1core 09-22-2003 12:17 AM

Quote:

Originally posted by SaijinGohan
Well since my other post disappeared. -.-

NPC Code:
for (i=0;i<tokenscount;i++)setstring temp,#s(temp)#t(i)#b;



That #b is causing each word to be on a new line. :/ I don't think the wraptext is working. Maybe because it's serverside or does that not matter with wraptext?

uhh, thats saying that for each token i gets + 1.., so the problem woudl be that for every word since the begining they are both equal, causing a #b for each word :) im so smart i figured that out by myself. ;P

try:
NPC Code:
for (i=5;i<tokenscount;i+=5;)setstring temp,#s(temp)#t(i)#b;



thats for 5 words a line.

SaijinGohan 09-22-2003 01:23 AM

The problem is wraptext doesnt work serverside and therefor was shortchanging the rest of the script.


All times are GMT +2. The time now is 07:07 AM.

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