Jump to content
A 2021 backup has been restored. Forums are closed and work in progress. Join our Discord server for more updates! ×
SoaH City Message Board

Text Printout, Wrap-Around?


Recommended Posts

https://dl.dropbox.com/u/27392295/texttest.mfa

I have a custom typewriter engine. I want the text to type out in the way that games like Advance Wars, Fire Emblem etc manage - e.g. they don't print out a word if it's going to overrun the line, they don't start printing out the word if some of the letters will fit on the line but the rest won't, they just skip to the next line and print it there. The effect is explained here but in Game Maker and I have no idea how to transfer that 'don't print out the word halfway through and then transfer it to the next line' programming to Multimedia Fusion 2.

Link to comment
Share on other sites

This is me thinking out loud, but hopefully it'll help in some way.

You would need the following objects...

--------------

'Display' String/Textbox

'Token' String

'Full Text' String

'Size Limit' variable

---------------

Alright, once you have your full text entered, you break it up into tokens using the Split function (IE: in "I want a ham sandwich, dadgum it!", tokens would be "I", "want", "a", "ham", "sandwich,", "dadgum", and "it!" as they're all separated by white space).

Next, you loop through token by token and add the length of the Display string to the length of the token. If the sum is less than 'Size Limit', then add that token to the display string using the Type Writer effects. (IE: length of 'I' is 1 and length of Display is 0, so add 'I' to Display. Next, length of 'want' is 4 and length of Display is 1, so add 'want' to Display. And so on...)

If length of Token + length of Display is greater than 'Size Limit', then add a newline to Display (putting you on the next line down), add the line width to Size Limit (IE: If you're restricting it to 30 characters per line, add another 30 to Size Limit), and add the token to Display; it should now be on the next row.

---------------------

Hope that helps. Let me know if I need to explain more clearly, or if MMF2 doesn't have all those abilities.

Link to comment
Share on other sites

If length of Token + length of Display is greater than 'Size Limit', then add a newline to Display (putting you on the next line down), add the line width to Size Limit (IE: If you're restricting it to 30 characters per line, add another 30 to Size Limit), and add the token to Display; it should now be on the next row.

One minor flaw in the detail.

Suppose the limited number of characters on a row is 22, and the sentence we parse as an example is "There are a good number of people working on Let's Plays of the Sonic series."

There are a good (17 characters including the spaces between words - the next word, "number", would make the number of characters 23, exceeding the limit - we add another 22 to the limit, making it now 44)

number of people (16 characters included - the next word, "working", should make the number of characters 24, exceeding the limit - but that only works if we're adding 24 to 23, and we never got 23 because the next row began with 17 characters - 17+24=41, which means "working" will continue to type out until it wraps around the string object, messily creating a new row - then the system recognises that the next word will breach the limit of 44 characters and creates another row to prepare for this)

There are a good

number of people

working

on Let's Plays of the

Sonic series.

Instead of changing the Size Limit by a multiple of itself, resulting in an ever widening gap between Size Limit and Display that causes multiple wraparounds, I created another counter to record the length of the string the instant it creates a line break. This counter begins the frame with a value of 0 and is removed from (Length(Display)+Length(Token)) to compare that value to Size Limit*. I haven't been able to find an adequate way to say "separate this row of text from the previous row, count the number of characters in this row alone and compare that to the Size Limit", so this will do for now.

*EDIT: Alternatively you can simply make this counter increase in increments of 22 and remove that from (Length(Display)+Length(Token)).

Link to comment
Share on other sites

Ah, okay, didn't think of that. You could just pad each row with spaces (IE: "There are a good " to fit it to 22) after you get a token that surpasses SizeLimit to keep the count accurate.

That could be done with either a loop - Add " " (SizeLimit - Display.size) times - or by having a String that's 22 spaces long and taking a substring of it (0 to (SizeLimit - Display.size)).

Link to comment
Share on other sites

Ah, okay, didn't think of that. You could just pad each row with spaces (IE: "There are a good " to fit it to 22) after you get a token that surpasses SizeLimit to keep the count accurate.

That could be done with either a loop - Add " " (SizeLimit - Display.size) times - or by having a String that's 22 spaces long and taking a substring of it (0 to (SizeLimit - Display.size)).

I gave it a bash and set up a fastloop to make the string of Display [[Display+" "]] until the length of Display equals SizeLimit. This also removes the need for [[Display+NewLine$]] since the spaces wrap the position of the next word to type, at the start of the next row. There doesn't seem to be any problems with this setup at the moment, but if I find something I'll let you know.

EDIT: I've further customised the engine so that it no longer relies on String Objects using paragraphs. If you insert the entire text into one paragraph the engine will relay it all on-screen as usual, including pressing the button to advance text, but the engine will also allow for page breaks; when you need a critical pause during a line of dialog you can separate the text with a custom character (in my case "£").

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...