Looking to create a Message Log or Chat Log
Hi everyone!
I'm working on a text-based adventure game where players get fed dialog based off their decisions. I bounced back and forth between some ideas on how best to proceed, but in the end opted for a message log to display their progression to the player.
That said, I've been having trouble actually creating a working message log. I have the following set up:
- A sheet with the various lines of dialog
- The game cycles through this sheet and displays text to the player
- Each text displayed to the player is added to a variable (ie, messageLog) followed by a new line break
- An actor on screen displays messageLog
- The actor height increases by X amount each time a new message is added
The issue I'm running into is that after so many lines of text, it actually dwarfs the height of the actor displaying the text. I tried a few different solutions, such as adding 30 to the actor's height each time a new line is added (which didn't work).
I also tried another, what I thought was smarter (it wasn't), way where I would multiple the number of new lines within messageLog by 30 to determine the actor's height, thereby always having enough space to encompass the entire messageLog contents. That also didn't work.
I think, at this point, the solution I'm looking for is a way to always keep the actor's height just bigger than the height of the text it's displaying (ie, the value of messageLog). But...how do I determine the height of the displayed text? Is that even possible to determine?
I searched on here for a "message log" or a "chat log", hoping that it's already been solved/created. But I have had no luck. Perhaps I was not searching for the right parameters. In either case, I'm hoping someone has run into the same issue and has found a way around it! Thanks!
Comments
This is how I would do it (see attached). It shows the last ten lines of the dialog.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thank, Tatiang! That's an interesting approach. Funny enough, I thought about a similar solution...but it was not as elegant as this. I'm going to give it a try and see how it looks!
I originally was thinking of displaying the entire dialog (from the very beginning) so that players can scroll back and review their gameplay, but it may end up being out of scope/too heavy for the app.
You can certainly display the entire conversation but you'll either need to scroll -- which I always have trouble getting to work well -- or to allow the user to flip through pages. In the demo I made, it wouldn't be too hard to use an attribute within the tableMerge function and have a couple up and down buttons that change the range of that function so that you're always viewing 10 or so rows from the table but those rows can shift up or down (e.g. 1-10, 11-20, 21-30, etc.).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Just tested it out on my project. Works like a charm! Changes the design a bit, but overall, it accomplishes what I wanted to do. Thank again, Tatiang!
The only problem that I kept running into here was ensuring the actor was always big enough to display everything. I ran into issues where the growth of the actor's height was not matching the growth of the wrapped text it was displaying. I found a potential solution for scrolling that I may try out, but until I figure out the whole actor's height vs wrapped text height, I may stick with locking the player to only seeing the last 10 or so lines.
Yeah, I wasn’t too thrilled with how the text was flowing in my demo. Given more time, I would place or spawn one actor for each potential row of text and then have that actor retrieve its corresponding table row. That way things like line height can be dialed in to a very specific decimal number rather than relying on GameSalad’s default line spacing.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Another good solution. That would negate the need to have a single actor supporting the entire log. I wonder if I'll have performance issues though. I have a minimum of 2.5k lines of text. That doesn't include replays if the user dies. Worth a try though. I'll look into it.
But I'm guessing you don't need the player to be able to read all 2500 lines of text at once. That's where a range variable comes into play. You can display 10 or 20 or 30 lines at a time and just keep changing the range with page up & page down buttons.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Ah, I see what you mean. I had hoped on making it more fluid so that the player can swipe up without having to "flip pages" but that's probably a more viable solution. I'm going to play around with it a bit more. Thanks again!
What if you had the whole actor displaying everything at once, and had two buttons that literally move the actor, and thus the text, up and down? Using move rules, for example:
Rule in Button 1:
If actor is pressed, move up at such and such a speed. (Positive number on y-axis).
(no otherwise).
Rule in Button 2:
If actor is pressed,
Scratch that, that just makes each button move.
New plan: Buttons stay in position, displaying actor moves behind them:
Rule in Button 1:
If actor is pressed, change game.attribute a to 1.
Else: change game.attribute to 0.
Rule for Button 2:
If actor is pressed, change game.attribute a to 2.
Else: change game.attribute to 0.
Rule for Displaying Actor:
If actor position y is less than or equal to "limit at top, so actor doesn't go off screen"
If actor position y is greater than "limit at bottom, so actor doesn't go off screen"
(make sure both of these are a number plus half the height of the display actor so it doesn't go off the screen at all).
Do: (Rule) If game.attribute a is 1, change linear velocity y to ex. 300
Else: change linear velocity to 0.
If a player presses both buttons at the same time it could get a little wonky, but that's not a problem.
I don't know how heavy 2.5k lines of text would be. It would also show the text along the entire vertical row. Hm. You could try spawning different actors with chunks of text as the player needs them, just off screen or something, I don't know. Using variables like @tatiang said. Could work. Best of luck!
How is that line so orderly-looking? I love it! Haha.
Hey, Why isn't my strikethrough not striking through?
Fixed. I had to use < s > and < / s >
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Here is a way to scroll up and down a table. It might be fun to see it it holds up for a 2500 row table.
https://forums.gamesalad.com/discussion/comment/504291/#Comment_504291
Thanks!
How did this happen? -
"
"
Is it because of the spaced line in between? And indented?
I'm not sure!
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
@tatiang Hello can you please share this template?