Looking to create a Message Log or Chat Log

boolsisboolsis Member, PRO Posts: 29

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:

  1. A sheet with the various lines of dialog
  2. The game cycles through this sheet and displays text to the player
  3. Each text displayed to the player is added to a variable (ie, messageLog) followed by a new line break
  4. An actor on screen displays messageLog
  5. 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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited December 2019

    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

  • boolsisboolsis Member, PRO Posts: 29

    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.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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

  • boolsisboolsis Member, PRO Posts: 29

    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!

  • boolsisboolsis Member, PRO Posts: 29

    @tatiang said:
    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.).

    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.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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

  • boolsisboolsis Member, PRO Posts: 29
    edited December 2019

    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.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    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

  • boolsisboolsis Member, PRO Posts: 29

    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!

  • Twayne2Twayne2 Member Posts: 458
    edited December 2019

    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

                If game.attribute a is 2, 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! :smile:

  • Twayne2Twayne2 Member Posts: 458
    edited December 2019

    How is that line so orderly-looking? I love it! Haha. :smiley:
    Hey, Why isn't my strikethrough not striking through?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Fixed. I had to use < s > and < / s >

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,879

    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

  • Twayne2Twayne2 Member Posts: 458
    edited December 2019

    @tatiang said:
    Fixed. I had to use < s > and < / s >

    Thanks! :)

    How did this happen? -
    "

            If game.attribute a is 2, change linear velocity y to ex. -300.
    

    "

    Is it because of the spaced line in between? And indented?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    I'm not sure!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • raibk.01raibk.01 Member Posts: 6

    @tatiang Hello can you please share this template?

Sign In or Register to comment.