Display a chat-like interface alongside dialogue? [Solved]
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- Milkymalk
- Miko-Class Veteran
- Posts: 753
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
Correct, though you can also put the viewport inside a normal screen layout. The viewport is just a type of screen element that allows you to scroll its content.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- Fuu
- Newbie
- Posts: 18
- Joined: Tue Mar 03, 2015 3:10 pm
- Completed: 404 Error: Connection Not Found Demo, NAOMI, Simple Answers
- Projects: 404 Error: Connection Not Found, Ashes//Dust
- Organization: CODE:Phantasm, Paper Star Studios
- Tumblr: Rottenadel
- itch: Codephantasm
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
How would one go about doing that? Or rather, what is the style code I would use with the new interface? Most of the recipes don't seem to apply anymore.
- Milkymalk
- Miko-Class Veteran
- Posts: 753
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
To be honest, I suck at using styles Someone else will have to help you there.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- Fuu
- Newbie
- Posts: 18
- Joined: Tue Mar 03, 2015 3:10 pm
- Completed: 404 Error: Connection Not Found Demo, NAOMI, Simple Answers
- Projects: 404 Error: Connection Not Found, Ashes//Dust
- Organization: CODE:Phantasm, Paper Star Studios
- Tumblr: Rottenadel
- itch: Codephantasm
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
I've been tinkering around with this a bit more and two things. Again, thank you for all the help!
the command delchat doesn't seem to do anything. I'm using
also, do you know how to get the viewport to focus on the bottom, so the newest text is shown automatically without having to scroll?
So far I've customized with
the command delchat doesn't seem to do anything. I'm using
Code: Select all
$ chat.delchat
So far I've customized with
Code: Select all
screen chatdisplay:
frame:
align (0.95, 0.2)
viewport id "chatwindow":
mousewheel True
##area (10, 25, 550, 500)
xsize 550
ysize 600
yinitial 0.0
xinitial 0.0
- Milkymalk
- Miko-Class Veteran
- Posts: 753
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
it's $ chat.delchat(), otherwise you are literally returning the function itself instead of calling it.
All about viewports is here:
https://www.renpy.org/doc/html/screens.html#viewport
You use
yinitial 1.0
for that. 0.0 would be the top as I understand it. If your viewport doesn't scroll horizontally, you don't need xinitial.
All about viewports is here:
https://www.renpy.org/doc/html/screens.html#viewport
You use
yinitial 1.0
for that. 0.0 would be the top as I understand it. If your viewport doesn't scroll horizontally, you don't need xinitial.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- Fuu
- Newbie
- Posts: 18
- Joined: Tue Mar 03, 2015 3:10 pm
- Completed: 404 Error: Connection Not Found Demo, NAOMI, Simple Answers
- Projects: 404 Error: Connection Not Found, Ashes//Dust
- Organization: CODE:Phantasm, Paper Star Studios
- Tumblr: Rottenadel
- itch: Codephantasm
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
Yep! That did the trick! Thanks again for the help!
As for the viewport...Hm...that doesn't seem to move it when something new is added. I'll do some more research on it! If push comes to shove I may just work around it with the delchat command
As for the viewport...Hm...that doesn't seem to move it when something new is added. I'll do some more research on it! If push comes to shove I may just work around it with the delchat command
- Milkymalk
- Miko-Class Veteran
- Posts: 753
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
Try adding renpy.restart_interaction() to Message.addmessage(), this should "reboot" the screen:
https://www.renpy.org/doc/html/other.ht ... nteraction
If that doesn't work, try adding the Python equivalent of showing the screen instead. Too lazy to look it up now, but there is a page in the docs about Python equivalents of Renpy statements.
https://www.renpy.org/doc/html/other.ht ... nteraction
If that doesn't work, try adding the Python equivalent of showing the screen instead. Too lazy to look it up now, but there is a page in the docs about Python equivalents of Renpy statements.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- Fuu
- Newbie
- Posts: 18
- Joined: Tue Mar 03, 2015 3:10 pm
- Completed: 404 Error: Connection Not Found Demo, NAOMI, Simple Answers
- Projects: 404 Error: Connection Not Found, Ashes//Dust
- Organization: CODE:Phantasm, Paper Star Studios
- Tumblr: Rottenadel
- itch: Codephantasm
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
No dice there. It's as if the yinitial isn't doing anything.Milkymalk wrote:Try adding renpy.restart_interaction() to Message.addmessage(), this should "reboot" the screen:
https://www.renpy.org/doc/html/other.ht ... nteraction
If that doesn't work, try adding the Python equivalent of showing the screen instead. Too lazy to look it up now, but there is a page in the docs about Python equivalents of Renpy statements.
I have
Code: Select all
$ chat.addmessage(" ", " Almost!")
$ renpy.restart_interaction()
- Milkymalk
- Miko-Class Veteran
- Posts: 753
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
I meant you should write the restart_interaction inside the function, where the class i declared, but it has the same effect.
No idea for now ...
No idea for now ...
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- Milkymalk
- Miko-Class Veteran
- Posts: 753
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
Okay, I found the solution in this thread:
viewtopic.php?f=8&t=32584&p=422238
I used the method in the second post as it is much shorter and easier to understand.
viewtopic.php?f=8&t=32584&p=422238
I used the method in the second post as it is much shorter and easier to understand.
Code: Select all
screen chatdisplay:
$ chatyadj.value = infyadjValue
frame:
### Here is where I added the viewport, and set its yadjustment property to the ui.adjustment object I created earlier.
viewport id "chatwindow":
yadjustment chatyadj
mousewheel True
xsize 550
ysize 600
scrollbars "vertical"
hbox:
vbox:
for i in chat.history:
text i.name
vbox:
for i in chat.history:
text i.message
init python:
class Message(object):
def __init__(self, name, message):
self.name = name
self.message = message
class Chatlog(object):
def __init__(self):
self.history = []
def addmessage(self, name, message):
self.history.append(Message(name, message))
def delchat(self):
self.history = []
### Set a variable to infinity, to be used later.
infyadjValue = float("inf")
### Create a ui.adjustment object and assign it to a variable so that we can reference it later. I'll assign it to the yadjustment property of our viewport later.
chatyadj = ui.adjustment()
init:
default chat = Chatlog()
label start:
show screen chatdisplay
$ n=0
while True:
$ n+=1
$ chat.addmessage(str(n), 'Blahblahblah')
""
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- Fuu
- Newbie
- Posts: 18
- Joined: Tue Mar 03, 2015 3:10 pm
- Completed: 404 Error: Connection Not Found Demo, NAOMI, Simple Answers
- Projects: 404 Error: Connection Not Found, Ashes//Dust
- Organization: CODE:Phantasm, Paper Star Studios
- Tumblr: Rottenadel
- itch: Codephantasm
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
You my friend are a veritable genius and I can't thank you enough! The code worked like a charm. I adjusted the chat so it shows on the right side and used the chat.addmessage you suggested previously to make the chat work as expected.
Again, thank you so much for your help!
Again, thank you so much for your help!
- Milkymalk
- Miko-Class Veteran
- Posts: 753
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
No problem at all I've been fiddling with screen language a lot these days in order to learn more about it. I always struggled for days just to make a simple screen so I thought it was time to get real and learn it.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- storykween
- Regular
- Posts: 154
- Joined: Mon Sep 30, 2013 1:17 pm
- Completed: Serafina's Saga, Quantum Conscience, Echoes of the Fey, miraclr - Divine Dating Sim
- Organization: Woodsy Studio
- Location: St Louis
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
Wow, all this code is very helpful, thanks for posting!
Sorry if this is a dumb question (my screen coding is really rusty) but how do you make sure that the vertical spacing between all the messages is consistent? A problem I'm having with the code provided in your example is that if one of the coded messages is really long and spans multiple lines, the name to its left does not appear with a sufficient gap between the name from the last message.
Image example below:
Sorry if this is a dumb question (my screen coding is really rusty) but how do you make sure that the vertical spacing between all the messages is consistent? A problem I'm having with the code provided in your example is that if one of the coded messages is really long and spans multiple lines, the name to its left does not appear with a sufficient gap between the name from the last message.
Image example below:
My website: woodsy-studio.com
- Milkymalk
- Miko-Class Veteran
- Posts: 753
- Joined: Wed Nov 23, 2011 5:30 pm
- Completed: Don't Look (AGS game)
- Projects: KANPEKI! ★Perfect Play★
- Organization: Crappy White Wings
- Location: Germany
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
I could have seen that coming, honestly.
Change the screen code to this and if you like try to understand the difference as a screen language and coding exercise
Change the screen code to this and if you like try to understand the difference as a screen language and coding exercise
Code: Select all
screen chatdisplay:
$ chatyadj.value = infyadjValue
frame:
### Here is where I added the viewport, and set its yadjustment property to the ui.adjustment object I created earlier.
viewport id "chatwindow":
yadjustment chatyadj
mousewheel True
xsize 550
ysize 600
scrollbars "vertical"
vbox:
for i in chat.history:
hbox:
text i.name:
xsize 150 # for bonus points: why is this necessary?
text i.message
Last edited by Milkymalk on Wed Jul 19, 2017 7:30 am, edited 1 time in total.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)
- zankizuna
- Veteran
- Posts: 416
- Joined: Fri May 04, 2012 2:20 am
- Completed: Monochrome Valentine
- Projects: Softwar
- Deviantart: raseru09
- itch: ZanKizuna
- Location: Manilaaaaaaaa
- Contact:
Re: Display a chat-like interface alongside dialogue? [Solve
Can you screenshot the output? It looks very interesting. Adding the screen to a viewport sounds genius.
Who is online
Users browsing this forum: Ahrefs [Bot], MorganFoster