Depends how complex you want it, I've built ones that run off external Lua scripts that were pretty damn tricky. The way to make text appear one letter at a time is basically like this:
if len(string$("Speech Text")) < len("The Message you want written") {
Text of Speech = left$("The Message you want written",value("Counter"))
value("Counter") += 1
}
Horrible pseudo code there!
I'd upload my Lua example, but I don't think you'd learn from it since it assumes a far bit of knowledge >_>.
@fish - you could also probably get away with loading the message you want into a 2 dimensional array character by character so you can allow for multiple lines of text. then run through the array and print out each one by one. (probably too complex for you at the moment tho).
@ben - im guessing theres more to your lua code example to allow for multiple lines?
would you mind posting it for others who have the knowledge to understand it? pretty please?
in c++, character arrays are far more useful than strings. at least thats what you're taught. and i have found it personally so as well.
Well the breakdown of my Lua system is like this (it's not just text it does all sorts, basically cutscene control):
function TheNameOfMySetOfDialogue()
s("This is a line of text.")
s("do you like my system?");
yn("TESTYN","Yeah, I do","Nope!");
if (TESTYN == 1) then
s("Yay! You said yes.");
endtext();
else
s("No?!");
endtext();
end
end
So what it does is (with some extreme trickyness, that I can't recall exactly) runs through the script and finds which line to execute. So on the first loop it runs line 1, then 2 etc. This allows for both lines that pause and ones that go to the next line and perform their function in one MMF tick.
I've got all sorts in it though, heaps of functions like:
... You get the idea; it's basically the exact sorta thing The Underside does . So yeah all the conversations are stored in an external file that can be encrypted when the game is done.
Phew!
EDIT: Oh and James, you look like you're just using a string object in the videos - Text Blitter ftw!
Aye capitan. It's the lack of global support why I decided against the text blitter. I might switch back to it later, I mean I'm using the text blitter for selectable text options since it can calculate how many lines its using. Just couldn't find a proper use for it in speech text!
Yea, that's the easy bit. The tricky part is to get it to print it out properly, without the text jumping around every time it reaches the end of the line (á la the first Underside demo, and pretty much all other klik games that I've seen). One solution is to manually insert linebreaks where needed, but it's possible to do it with code as well.
Yeah axel I've always had trouble with that :\. You can probably count the number of characters in a line and if it's greater than a limit you set it can scan backwards for the last space and insert a line break in the source text. I might have a go at something like that later actually...