Message Boxes
By Dunc2403
Getting Started
Note: CS will always mean Cave Story in this guide.
You may think that message boxes would be the easiest things ever in TSC, but you're wrong. And I mean really wrong. Well, I may be exaggerating a bit here, but it can be difficult if you don't know what you're doing. It could also make your mod explode in the badly wrapped text of your message boxes, half of it unreadable because of faces. But we can prevent that!
To get started, simply copy and paste the following TSC into event #200 on the Start Point map with your preferred CS editor and run CS, then choose New. The message boxes should do as they say.
Code:
<KEY<MSGThis is a message box.<NOD<CLR<MS3This is a message box on top of thescreen.<NOD<CLR<MS2This is an invisible message box
on top of the screen.<NOD<END
You may be wondering why there isn't a space between the "the" and the "screen" on the second message box. That is because CS' text wrapping system doesn't get rid of whitespace, like you may be accustomed to because of MS Word or the like. If you counted, you would be able to tell that CS' message box can only fit 35 characters on one line. (An exception to this is when you have a fecpic in the message box, but we'll get to that later.) Beyond that, it will go to the next line, which is usually good, but it can mess with some sentences, so always remember that. A big mistake you might make is making a carriage return after exactly 35 characters. That may be what you want to do, and it may seem like it should be that way, but it isn't. It will end up looking like this.
Do you see the problem? There's two line breaks, not one! This is because CS wraps whitespace, including carriage returns. Now, you can actually start learing how this stuff works! I'm only going to describe the dedicated message box commands, so not all the commands in the sample code are going to be explained. But that's fine, you can find that stuff in any genereal TSC tutorial. I'll break the commands down to make it easier to understand.
<KEY
Okay, I lied. But this command should always be used before a message box! (Or <PRI.) That is, unless you're experienced and know exactly what you're doing if you don't have one of these commands. This is a simple command. (In fact, all but the <FAC command are, and that only has one paramater.) No weird syntax, and the only feature you're likely to care about if you're reading this guide is that it stops you from moving, and only you. That's what makes it diferent from...
<PRI
This command is pretty much the same as <KEY, except that it stops everything.
<MSG
This is yet another no-paramaters command. Simply opens a message box at the bottom of the screen. You'll be using this for most message boxes. The other two are...
<MS2 and <MS3
These two have the same paramaters as <MSG. (hint: nothing.) The only difference is these two appear on top of the screen, and that <MS2 appears to be just text, with no message box. Although it may appear to have none, it is simply invisible. Don't beilieve me? Put this bit of script in, and I can prove it.
Code:
<MS2<FAC0001This is a test.<NODaaaaaaaaaaaaaaaaa<NODaaaaaa<NOD<END
Now if you were good and tested that, you would see that one of the <NODs went out of the message box, but you couldn't see the text! That alone proves there is a message box when you use <MS2, even if you don't see it. And I'm sorry if you did believe me, but things like this are pretty much mandatory in a guide like this.
<NOD
This command is your best friend. It is. Don't even try to argue, without this command your mod's dialog will suck because people won't be able to stop and read it. And that's what this command does! It makes the text stop until the player presses either their shoot or their jump button.
<CLR
This command is really useful in dialog, especially when you have faces. It clears the message box of all text.
<CLO
This command wasn't in the sample script, I know, but all it does is close the message box. It's useful in cutscenes.
<END
This one's pretty self-explanatory. Marks the end of an event. (You can write notes in TSC by putting them after an <END.)
The only command left that a beginner modder needs to know is the <FAC command. This brings us to our final section, which is...
Faces
What I think is the most annoying think about message boxes in CS is faces. Sure, it's cool to see a mega-res version of the person you're talking to's face, but boy are they a pain. The following bit of code is a simple message box that scrolls through all the faces in regular CS. Do the same with this as you did (or should have done) with the different message boxes code.
Code:
<KEY<MSG<FAC0000<NOD<FAC0001<NOD<FAC0002<NOD<FAC0003<NOD<FAC0004<NOD<FAC0005<NOD<FAC0006<NOD<FAC0007<NOD<FAC0008<NOD<FAC0009<NOD<FAC0010<NOD<FAC0011<NOD<FAC0012<NOD<FAC0013<NOD<FAC0014<NOD<FAC0015<NOD<FAC0016<NOD<FAC0017<NOD<FAC0018<NOD<FAC0019<NOD<FAC0020<NOD<FAC0021<NOD<FAC0022<NOD<FAC0023<NOD<FAC0024<NOD<FAC0025<NOD<FAC0026<NOD<FAC0027<NOD<FAC0028<NOD<FAC0029<NOD<END
That's every face in the game. That looks fine, right? So what's bad about them? The fact that they have the same rules for text wrapping as when there is no face. That is to say, it still wraps at 35 characters, not the 27 that fit in the message box when there's a face.
Wow, <FAC is the first message box command that takes paramaters! (Unless you count the text for <MSG, <MS2 and <MS3, but that's not actually TSC paramaters. TSC paramaters are four characters or CS will kill you.) The syntax for <FAC is <FACXXXX. The paramater is the index for the face you want. The first face is at index 0, but it is nothing, and is used if you have a dialog between characters, one with a faceset, and one without. The next ones are indexes 1, 2, 3, 4, etc. And that's it! The only problem is the wrapping. You have to remember that you DO have to put a line break at 27 characters, unlike when you don't have a face and it does it for you.
Conclusion
If you want to see an excellent example of a mod with bad text wrapping, see
this mod.
Thanks for taking the time to read this!