Page 1 of 3

Display a chat-like interface alongside dialogue? [Solved]

Posted: Tue Jul 04, 2017 12:05 am
by Fuu
Is it possible to have both NVL and regular textbox (is this called ADV?) at the same time? I'm trying to replicate something like what I have drawn out below (pardon the language).

Basically I want the dialogue (left side) to run independently of the chatbox (right side). Is this possible? It doesn't necessarily have to be NVL/ADV.

Re: Displaying textbox and NVL at the same time?

Posted: Mon Jul 10, 2017 4:37 am
by vollschauer
Short answer would be no it's not possible... you can one set one kind (NVL or ADL) to your character. But what you can do is that you stay with the default ADL and create you own screen for the chat window... or your design a new say screen with 2 different window...maybe the better choice.

Re: Displaying textbox and NVL at the same time?

Posted: Mon Jul 10, 2017 6:55 am
by Fuu
Would you know of a way to do that, or could you point me to a guide? Sorry I'm having a hard time finding one on here.

Re: Displaying textbox and NVL at the same time?

Posted: Mon Jul 10, 2017 7:38 am
by chocoberrie
I'm curious to see how this can work! It sounds like an interesting game mechanic. :)

Here's the documentation about the say screen: https://www.renpy.org/doc/html/screen_s ... me-screens

And here's the documentation about screen language, which includes the kinds of things that go in the say screen: https://www.renpy.org/doc/html/screens.html

I also found this thread: viewtopic.php?f=8&t=41047 that seems to ask the same question you're asking here!

Re: Displaying textbox and NVL at the same time?

Posted: Mon Jul 10, 2017 8:50 pm
by Fuu
chocoberrie wrote:I'm curious to see how this can work! It sounds like an interesting game mechanic. :)

Here's the documentation about the say screen: https://www.renpy.org/doc/html/screen_s ... me-screens

And here's the documentation about screen language, which includes the kinds of things that go in the say screen: https://www.renpy.org/doc/html/screens.html

I also found this thread: viewtopic.php?f=8&t=41047 that seems to ask the same question you're asking here!
I did look over those links! I appreciate the help.

One thing I'm running into is that I really have no idea how to customize the vbox for text as it says. I want to be able to post in the window like I would normal say dialogue.

Example:

Code: Select all

character "This text goes in the normal say dialogue box."

chatroom1 "This text goes in the chat window but doesn't make the say window disappear."

chatroom 2 "This goes beneath the last line of dialogue in the chat window."

character "The chat window stays on the screen and you can see my thoughts on the matter!"
Obviously it doesn't have to be that easy. I can throw in extra strings of code. But ultimately, I need it to be displayed at the same time as the character's dialogue and not erasing each time.

Re: Displaying textbox and NVL at the same time?

Posted: Mon Jul 10, 2017 9:23 pm
by Milkymalk
You could make a viewport inside a screen and display a list inside it:

Code: Select all

python:
    class Message:
        def __init__(self, name, message):
            self.name = name
            self.message = message

    class Chatlog:
        def __init__(self):
            self.history = []

        def addmessage(self, name, message):
            self.history.append(Message(name, message))

        def delchat(self):
            self.history = []

screen chatdisplay:
    frame:
        viewport id "chatwindow":
            mousewheel True
            side_area (100, 100, 300, 600)
            yinitial 0.0
            scrollbars "vertical"
            hbox:
                vbox:
                    for i in chat.history:
                        text i.name
                vbox:
                    for i in chat.history:
                        text i.message

init:
    default chat = Chatlog()
Whenever you want something to appear in the chat, you would instead do

Code: Select all

$ chat.addmessage("Ren", "Hi, is anybody online?")
This is all untested and not guaranteed to work without bugfixing, but it's how I would start with this.

Re: Displaying textbox and NVL at the same time?

Posted: Mon Jul 10, 2017 9:57 pm
by Fuu
I get the following error when I try this.

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "renpy/common/00start.rpy", line 178, in script
    python:
  File "renpy/common/00start.rpy", line 179, in <module>
    renpy.execute_default_statement(True)
  File "game/screens.rpy", line 596, in set_default
    default chat = Chatlog()
  File "game/screens.rpy", line 596, in <module>
    default chat = Chatlog()
NameError: name 'Chatlog' is not defined

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "C:\Users\Adelei\Dropbox\Paper Star Studios\Ren'Py Engine and Tools\renpy-6.99.12.4-sdk\renpy\bootstrap.py", line 295, in bootstrap
    renpy.main.main()
  File "C:\Users\Adelei\Dropbox\Paper Star Studios\Ren'Py Engine and Tools\renpy-6.99.12.4-sdk\renpy\main.py", line 487, in main
    run(restart)
  File "C:\Users\Adelei\Dropbox\Paper Star Studios\Ren'Py Engine and Tools\renpy-6.99.12.4-sdk\renpy\main.py", line 147, in run
    renpy.execution.run_context(True)
  File "C:\Users\Adelei\Dropbox\Paper Star Studios\Ren'Py Engine and Tools\renpy-6.99.12.4-sdk\renpy\execution.py", line 761, in run_context
    context.run()
  File "renpy/common/00start.rpy", line 178, in script
    python:
  File "C:\Users\Adelei\Dropbox\Paper Star Studios\Ren'Py Engine and Tools\renpy-6.99.12.4-sdk\renpy\ast.py", line 814, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "C:\Users\Adelei\Dropbox\Paper Star Studios\Ren'Py Engine and Tools\renpy-6.99.12.4-sdk\renpy\python.py", line 1719, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00start.rpy", line 179, in <module>
    renpy.execute_default_statement(True)
  File "C:\Users\Adelei\Dropbox\Paper Star Studios\Ren'Py Engine and Tools\renpy-6.99.12.4-sdk\renpy\exports.py", line 3108, in execute_default_statement
    i.set_default(start)
  File "game/screens.rpy", line 596, in set_default
    default chat = Chatlog()
  File "C:\Users\Adelei\Dropbox\Paper Star Studios\Ren'Py Engine and Tools\renpy-6.99.12.4-sdk\renpy\python.py", line 1743, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/screens.rpy", line 596, in <module>
    default chat = Chatlog()
NameError: name 'Chatlog' is not defined

Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
404 0.0

Re: Displaying textbox and NVL at the same time?

Posted: Mon Jul 10, 2017 10:00 pm
by Milkymalk
Sorry, I should have seen that. Change "python:" into "init python:" The problem is the order of things, the classes need to be defined before that line with "default" is executed.

Maybe it's also necessary to change all "class Blah:" into "class Blah(object):"

Re: Displaying textbox and NVL at the same time?

Posted: Mon Jul 10, 2017 11:44 pm
by Fuu
Milkymalk wrote:Sorry, I should have seen that. Change "python:" into "init python:" The problem is the order of things, the classes need to be defined before that line with "default" is executed.

Maybe it's also necessary to change all "class Blah:" into "class Blah(object):"
You may be right. I'm getting the following error now.

Code: Select all

I'm sorry, but errors were detected in your script. Please correct the
errors listed below, and try again.


File "game/screens.rpy", line 565: expected statement.
    class Message:
                 ^

File "game/screens.rpy", line 570: expected statement.
    class Chatlog:
                 ^

Ren'Py Version: Ren'Py 6.99.12.4.2187
I apologize for all the questions!

EDIT: Also it seems changing the first line to "init python:" causes the game to not go past the start menu.

Re: Displaying textbox and NVL at the same time?

Posted: Mon Jul 10, 2017 11:57 pm
by Milkymalk
Sorry, tired. Will try to get it to run by myself after sleep :)

Re: Displaying textbox and NVL at the same time?

Posted: Tue Jul 11, 2017 12:50 am
by Fuu
Thank you so much for the help!

I switched from Legacy screens to the updated one and the errors cleared, however when I use the $ chat.addmessage bit in the script, nothing happens and the game just skips over it.

Re: Displaying textbox and NVL at the same time?

Posted: Tue Jul 11, 2017 2:31 am
by Milkymalk
Dumb question: Did you show the screen? ;)

Re: Displaying textbox and NVL at the same time?

Posted: Tue Jul 11, 2017 2:48 am
by Fuu
Milkymalk wrote:Dumb question: Did you show the screen? ;)
welp, I feel like a bloody idiot. After all the fiddling that's what was wrong!

Thank you so much for helping with this!

Re: Displaying textbox and NVL at the same time?

Posted: Tue Jul 11, 2017 9:31 am
by Milkymalk
:D
So it works now?

Re: Displaying textbox and NVL at the same time?

Posted: Tue Jul 11, 2017 11:47 am
by Fuu
Milkymalk wrote::D
So it works now?
It appears to! I haven't been able to do extensive testing yet but it's displaying as I wanted. I take it I would customize this as a viewport?