Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   gs2 line breaks? (https://forums.graalonline.com/forums/showthread.php?t=61939)

jake13jake 10-27-2005 08:53 AM

gs2 line breaks?
 
How do you do line breaks in gs2? Is it still #b? I'd doubt it.

napo_p2p 10-27-2005 09:19 AM

\n

Velox Cruentus 10-27-2005 12:38 PM

Short and simple... ^_^ ( Napo got it )

Admins 10-27-2005 01:45 PM

Well it depends.
You can do
say2("Hello!\nThis is the next line.");
or you can do
say2("Hello!
This is the next line.");
The second way is easier readable if you have long text I guess.

Maniaman 10-27-2005 10:30 PM

RC always escapes \n for me when it is used in a script. Hitting end it will be converted from \n to \\n

ZeLpH_MyStiK 10-28-2005 01:23 AM

Quote:

Originally Posted by Maniaman
RC always escapes \n for me when it is used in a script. Hitting end it will be converted from \n to \\n

yes has happened to me too...\n becomes \\n when updating.

jake13jake 10-28-2005 04:51 AM

Quote:

Originally Posted by Stefan
Well it depends.
You can do
say2("Hello!\nThis is the next line.");
or you can do
say2("Hello!
This is the next line.");
The second way is easier readable if you have long text I guess.

Actually stefan, should scripted line breaks really be read as string line breaks when you can just do:
say2("Hello!\n"
+ "This is the next line.");
??

ForgottenLegacy 10-28-2005 05:51 AM

Quote:

Originally Posted by jake13jake
Actually stefan, should scripted line breaks really be read as string line breaks when you can just do:
say2("Hello!\n"
+ "This is the next line.");
??

Okay, few things here.
1) Stefan made GS1 and GS2, I'd assume he knows exactly what he's talking about regarding GraalScript, and I'd be supprised if someone corrected him on something completely wrong.
2) The character you want to use is '@', not '+'. The addition character treats both the strings as numbers and then tries to add them. I'm believing since both the strings are not NULL, you'll get a message saying '2'.
3) Scripted line breaks are string line breaks, but the only exception is that the line break is contained within the string. (Someone correct me on this, mmkay?)

I'd say use Stefan's idea for big, long messages, and use the "string\nstring" idea for shorter messages. The NPCServer's sendpm on a player's login uses Stefan's idea, typically, although I think I've seen it done the other way. I don't remember.

Anyway, use whichever way you please: either contain a line-break within the quotes, or contain a \n within the quotes. Up to you.

Skyld 10-28-2005 12:03 PM

Quote:

Originally Posted by ForgottenLegacy
3) Scripted line breaks are string line breaks, but the only exception is that the line break is contained within the string. (Someone correct me on this, mmkay?)

Line breaks are line breaks. However, the scripting engine will treat them differently depending on where they are.

\n is an escaped character which is eventually replaced by a line break.

Thus, using \n is unnecessary for many new lines, since
HTML Code:

say2("HELLO\n" @
"LOL\n" @
"foo");

eventually becomes:
HTML Code:

say2("HELLO
" @
"LOL
" @
"foo");

especially when this is shorter:
HTML Code:

say2("HELLO
LOL
foo");

Concerning \\n, \\n is probably escaping the first "\", so that it does not escape "n". When it is displayed in RC, it is possibly being escaped again when it shouldn't be.

Admins 10-28-2005 01:10 PM

Probably old RC?

jake13jake 10-28-2005 08:31 PM

Quote:

Originally Posted by ForgottenLegacy
Okay, few things here.
2) The character you want to use is '@', not '+'. The addition character treats both the strings as numbers and then tries to add them. I'm believing since both the strings are not NULL, you'll get a message saying '2'.

okay... so... why do you need to correct me? Sheesh, sorry for getting my scripting languages mixed up. Concatenation is the concept we're going for, and as far as we understand eachother on that level, what's the need?

Still I'd prefer

temp.message = "blah\n"
-indentation- @ "blah"
say2(temp.message);

just so I could line up the bottom string with the top string. I think that's a lot better readability, so you can see how all of the text lines up.

Maybe even

temp.message = "blah" @ "\n"
-indentation- @ "blah"
say2(temp.message);


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

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