SUGGESTION: Compiler support for new Strings (SOLVED)

Started by GarageGothic, Fri 09/06/2006 03:03:23

Previous topic - Next topic

GarageGothic

I spent several days rewriting the html-like hypertext module I've developed for Shadowplay, so that it would accept the new String format rather than old strings with their 200 character limit. It seemed worth the effort because the old system was a pain in the ass and required an external linebreaker program to convert longer text files. This way I thought, I would be able to add whole blocks of text at a time instead of just single paragraphs. But just as I had finished rescripting the whole thing and started testing, I discovered that it had been one big waste of time.

1) You see, my main function is called AddText(String htmltext), and inside the function everything is handled with Strings rather than strings. But when I call the function from the script, I get a compiler error if it exceeds a seemingly arbitrary character limit (not the 200 chars of strings)

An example (temp text from AGS manual with some additions):

Code: ags
AddText("AddText("AGS now has the ability to dump all of your in-game text out to a flat text file, which you can edit by hand and then import back later. This is useful you need to edit lots of scripts or messages for some reason, and then recombine them all back into the game.
When does this get too long? Two more words will break it. Or will it? Most likely .");


This compiles fine (with 345 characters). But if I add ONE character, even just inserting a space, I get this compiler error:

QuoteError (line 1120): Parse error in expr near '"AGS now has the ability to dump all of your in-game text out to a flat text file, which you can edit by hand and then import back later. This is useful you need to edit lots of scripts or messages for some reason, and then recombine them all back into the game.
When does this get too long? Two more words will break it. Or will it? Most likely n.'

2) Another problem that limits the use of new Strings is the 300 character limit in the script editor. Unless you insert a linebreak in your code, you get this:

QuoteError (line 1120): line too long (300 chars max)

Usually this isn't a problem. But if the linebreak has to be inserted in the middle of a String, it will show up as two square characters in the text when displayed in the game (at least using RawPrint, haven't tested otherwise).

I hope there is some workaround or that a fix can be implemented soon, since I can't progress much in development before I know what kind of input I can expect for my text functions. I was very happy when the apparent no-limit Strings were introduced, but now they're becoming a problem rather than the solution.

Thanks for reading this, CJ.

scotch

I've had a few people bring up this limitation on IRC before, including GarageGothic.Ã,  Sylpher was constantly hitting up against string literal and compiler limits when writing his text based AGS game, it seemed.

Within the line limit an alternate string form could be work, perhaps, something like

"""This is a way of writing long text strings
that many languages have, with varying
syntax. It can have line breaks and different
types of "quotes" in it, and it keeps
this formatting without having to escape
anything.
"""


Am I right in assuming that string literals are still compiled as old style strings? I guess that's another problem... and maybe a tricky one to work around for backward compatability reasons.

SSH

er, your code snippet doesn't have matching brackets or quotes...

i assume that was just a cut-and-paste thing.

Is there a reason why you can't do:

AddText(String.Format("%s%s", "Very long string 1", "Very long string 2"));
12

scotch

That'd work, and it's more or less the workaround I've had to tell people to use. That or .appending a lot of strings to each other.

GarageGothic

#4
Quote from: SSH on Fri 09/06/2006 07:40:54
er, your code snippet doesn't have matching brackets or quotes...

This is the exact way it shows up in the error message. The only change between the original code and the one that gives this error is the addition of the character n before the period. Perhaps part of the bug is that the compiler doesn't interpret the last part of the line and thus doesn't see the end quote and bracket?

QuoteIs there a reason why you can't do:

AddText(String.Format("%s%s", "Very long string 1", "Very long string 2"));

You're right, this works as a way of creating a non-limited String, and since you can add linebreaks between the individual strings, that issue is also avoided. Thanks, this is a very good suggestion. However, the whole point of rewriting the code for Strings was to avoid this. Since I deal with large amounts of the text (on one of the websites you can even read a short story) I wanted to avoid any kind of manual splitting so I could just cut-n-paste from my text doc. In addition, it seems that String.Format uses old strings for the "%s" strings, so the individual pieces of text would have to be even shorter.

SSH

#5
Why not just load the text doc in AGS? It coudl even be encrytped if you like, using the EncryptedFile module. With a bit of coding, you could probably even append the text files to the end of the AGS executable and extratc them, , if you dont want other files lying aroudn the game directory.
12

GarageGothic

It's not really possible since each page consists of many elements including plain text, formatted text, headers, images, different kinds of hyperlinks as well as script trigger codes. Each of these are added using their own commands. I'm too far into development to rescript this to handle external files and interpret the formatting code from them.

In addition, I'm not thrilled about the idea of using external txt files. Even if encrypted not to be read, the user would still be able to modify them and change the text that appears in the game. I also suspect the encryption would be too CPU intensive since I'm already getting framerate drops when rendering long pages due to the linebreaking code.

Pumaman

#7
I'll see what I can do about increasing the line length limit in the script editor.

(Edit by strazer: AGS v2.72 RC 2: * Increased script editor line length limit from 300 to 500 characters.)


SMF spam blocked by CleanTalk