How to make non-blocking scrolling text?

Started by Hobo Joe, Mon 05/01/2009 16:25:46

Previous topic - Next topic

Hobo Joe

I don't know how best to explain what I want, so I made a video to show you.

http://www.youtube.com/watch?v=jfOxpOrbP0I

Looking for text in a game that can function like it does in the old KQ. Any help would be much appreciated.
Yay, I'm Hobo..... Joe...

Khris

There's no simple, straigthforward solution to this.
You could use a Listbox and a Textfield for the line the player can type into.
Then you'd need an array to keep track of the 4 or 5 lines, write some sort of echo() function that'll print the text word by word, taking care of the line breaks.
You'd probably have to adjust the listbox's and textfield's size and position whenever necessary and so on.

I might try this later but I don't have time right now.

Hobo Joe

Oh, sorry, forgot to mention: I'm not going to be using a parser. It's point and click. Just want the text to DISPLAY like that. Sorry again for not being more specific.
Yay, I'm Hobo..... Joe...

Khris

It's more or less the same, just without the textfield.

Hobo Joe

Okay. I'll fiddle around. I can get a listbox to display, but not much else. I'm not really clear on how arrays work and I don't know what an echo command is either. Sorry!
Yay, I'm Hobo..... Joe...

Dualnames

#5
It's possible thing is I'm not in the time to do it. How about you wait  a little longer?

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=32630.0
The link might be of use.
Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Khris

I meant you'd have to use a custom echo() function to display text, i.e. write the function yourself. Of course you can call it whatever you want, echo is just a common name for the process of / command for outputting text.

Arrays are pretty simple, string arrays are still a bit more complicated though.
Like I said, I might post working code if I get to try out some things later.

Khris

#7
*bump*

Download the module, GUI and demo game.

-Import the GUI and module into your game, make sure the module is above the global script in the script list.

-put this line in game_start in the global script:
Code: ags
  if (LineDisplay.Init(gLineDisplay_MG, 4, 0)) Display(LineDisplay.Err_Message());


-To use your own GUI, put labels on it that use subsequent ID numbers.
Then adjust the parameters, e.g. if your GUI is called "gScrolltext" and you want to display the text in five labels with IDs 3 to 7, you have to call LineDisplay.Init(gScrolltext, 5, 3) in the code line above.

-The default speed is 8 words per second, i.e. the default delay is 5 game loops in between words. You can change that by calling e.g.
Code: ags
  LineDisplay.SetDelay(20);  // two words per second

(by default, 1 second == 40 game loops)

The module will warn you if you didn't set up the GUI and its labels correctly; it won't quit the game though.

Edit: It was really late yesterday, or rather pretty early...

Actually use the module by employing these two commands:

DisplayLD(String message);
Adds the message to the buffer and displays it, word by word, in the GUI.

Character.SayLD(String message);
Same as above, but "CharacterName: " is put before the message.

Hobo Joe

That is absolutely and utterly perfect. You are my hero. Thank you so much!
Yay, I'm Hobo..... Joe...

Khris

You're welcome; I was eager to write more than three lines of code for a change anyway :)

Hobo Joe

#10
Just one more thing: Is there a way I can make it so the text disappears when you walk off the screen?

EDIT: Crap. I've hit a snag. I got an "Increase buffer size" error. It's weird though, I have 2 identical scripts set up in 2 different rooms, it works fine in the first and then gives me that error in the second one. I'll keep looking at it to see what's wrong, but help on that would be appreciated also.
Yay, I'm Hobo..... Joe...

Khris

#11
I've added a function:
LineDisplay.Clear()
Call it anytime to clear the lines and the buffer.
(You could put it inside on_event(...) and call it upon eEventLeaveRoom)

The buffer size can be set at the top of the module script; there's a define line.
I've increased it from 50 to 200, just increase it further until you don't get the error.

http://www.2dadventure.com/ags/LineDisplay_v0.2.zip

(The buffer is an array of strings that gets filled up one by one every time a DisplayLD or SayLD is called. Once a line is fully printed, the string is removed from the buffer, freeing up one slot. Calling many consecutive DisplayLDs or SayLDs, together with a high word delay can result in a full buffer. The downside of increasing the buffer to, say, 1000 is that every saved game is 1000 times string space bigger in file size. String space is at least 200 bytes I believe, so a buffer of 1000 adds 200k to every save.)

Hobo Joe

The buffer exploded because the function hHotspot5_WalkOn() was firing repeatedly for some reason. I changed it so the character disappears and an object animates there instead and that fixed it. All good now. Thanks!
Yay, I'm Hobo..... Joe...

Khris

In the future, you should use a region and the step on event (because it will only be called once).

SMF spam blocked by CleanTalk