How to change text color in say screen after player read it.

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
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.
Post Reply
Message
Author
alexei
Regular
Posts: 137
Joined: Mon Sep 09, 2019 10:31 am
Completed: re:shape, Monster Boys Doctor, Hearts and Hexes, The Prince's Heart, Dragon Gazer
Projects: Motifs, Longing for Change, The Sinking of the Dream Chaser, Town of the Damned, Monster Boy Wars
Organization: Funigami
itch: funigami
Discord: alexei#5190
Contact:

How to change text color in say screen after player read it.

#1 Post by alexei »

As the title suggests, I want to change the textbox color after someone read the text and moved on. So, when they click back, I want the text to have a different color to suggest it's already seen/read. Any idea how to do this?

Additionally, I want to add a button in the options to allow the player to turn it on/off.
Image
Last edited by alexei on Fri Sep 16, 2022 3:25 pm, edited 1 time in total.

alexei
Regular
Posts: 137
Joined: Mon Sep 09, 2019 10:31 am
Completed: re:shape, Monster Boys Doctor, Hearts and Hexes, The Prince's Heart, Dragon Gazer
Projects: Motifs, Longing for Change, The Sinking of the Dream Chaser, Town of the Damned, Monster Boy Wars
Organization: Funigami
itch: funigami
Discord: alexei#5190
Contact:

Re: [SOLVED] How to change text color in say screen after player read it.

#2 Post by alexei »

I found a solution. You just place:

Code: Select all

init python:

    style.say_dialogue['rollback'].color="#FC5580"
    style.say_thought['rollback'].color="#FC5580"


And it will get the job done.

User avatar
Andredron
Miko-Class Veteran
Posts: 738
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: [SOLVED] How to change text color in say screen after player read it.

#3 Post by Andredron »

alexei wrote: Tue Sep 13, 2022 1:42 pm As the title suggests, I want to change the textbox color after someone read the text and moved on. So, when they click back, I want the text to have a different color to suggest it's already seen/read. Any idea how to do this?

Additionally, I want to add a button in the options to allow the player to turn it on/off.
Image
https://www.renpy.org/doc/html/other.html#renpy.is_seen

screen.rpy

Code: Select all

screen say(who, what):
    style_prefix "say"
    
    zorder 50

    window:
        id "window"
        
        background Transform(Frame("gui/textbox.png",xpos=0, ypos=1), alpha=persistent.dialogueBoxOpacity)

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"
                
####################
    if persistent.renpy_is_seen and renpy.is_seen():
        text what id "what" color "#77f"
    else:
        text what id "what"
###############


    ## If there's a side image, display it above the text. Do not display on the
    ## phone variant - there's no room.
    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0

    
I'm writing from my phone so there may be errors.
Last edited by Andredron on Mon Dec 05, 2022 1:17 am, edited 4 times in total.

User avatar
Andredron
Miko-Class Veteran
Posts: 738
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: [SOLVED] How to change text color in say screen after player read it.

#4 Post by Andredron »

How to register a button to enable or disable the mode in the settings, I know, but I don’t understand how to attach say to the screen

viewtopic.php?f=51&t=65301

You can redo my code to activate the YouTube mode, but there are no ideas how to do it so that the axis is turned off in the settings. Above I threw the code so that the text would always be in a different color when passing

alexei
Regular
Posts: 137
Joined: Mon Sep 09, 2019 10:31 am
Completed: re:shape, Monster Boys Doctor, Hearts and Hexes, The Prince's Heart, Dragon Gazer
Projects: Motifs, Longing for Change, The Sinking of the Dream Chaser, Town of the Damned, Monster Boy Wars
Organization: Funigami
itch: funigami
Discord: alexei#5190
Contact:

Re: [SOLVED] How to change text color in say screen after player read it.

#5 Post by alexei »

Andredron wrote: Wed Sep 14, 2022 6:07 am
alexei wrote: Tue Sep 13, 2022 1:42 pm As the title suggests, I want to change the textbox color after someone read the text and moved on. So, when they click back, I want the text to have a different color to suggest it's already seen/read. Any idea how to do this?

Additionally, I want to add a button in the options to allow the player to turn it on/off.
Image
https://www.renpy.org/doc/html/other.html#renpy.is_seen

screen.rpy

Code: Select all

screen say(who, what):
    style_prefix "say"
    
    zorder 50

    window:
        id "window"
        
        background Transform(Frame("gui/textbox.png",xpos=0, ypos=1), alpha=persistent.dialogueBoxOpacity)

        if who is not None:

            window:
                id "namebox"
                style "namebox"
                text who id "who"
                
######################
        if renpy.is_seen():
                text what id "what" color "#77f"
         else:
                text what id "what"
 ######################


    ## If there's a side image, display it above the text. Do not display on the
    ## phone variant - there's no room.
    if not renpy.variant("small"):
        add SideImage() xalign 0.0 yalign 1.0

    
I'm writing from my phone so there may be errors.
Cool, I'll give it a try. It looks more robust than what I did. Thanks for this!

alexei
Regular
Posts: 137
Joined: Mon Sep 09, 2019 10:31 am
Completed: re:shape, Monster Boys Doctor, Hearts and Hexes, The Prince's Heart, Dragon Gazer
Projects: Motifs, Longing for Change, The Sinking of the Dream Chaser, Town of the Damned, Monster Boy Wars
Organization: Funigami
itch: funigami
Discord: alexei#5190
Contact:

Re: [SOLVED] How to change text color in say screen after player read it.

#6 Post by alexei »

Andredron wrote: Wed Sep 14, 2022 6:31 am How to register a button to enable or disable the mode in the settings, I know, but I don’t understand how to attach say to the screen

viewtopic.php?f=51&t=65301

You can redo my code to activate the YouTube mode, but there are no ideas how to do it so that the axis is turned off in the settings. Above I threw the code so that the text would always be in a different color when passing
So, I'm not at a level to understand this. I'll have to read more about it. Any idea if it can be further simplified? It looks like an overkill to me.

User avatar
Andredron
Miko-Class Veteran
Posts: 738
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

Re: How to change text color in say screen after player read it.

#7 Post by Andredron »

From the phone I write something like this, but I could be wrong

Code: Select all

init python:

    # Set the default value.
    if persistent.renpy.is_seen is None:
        persistent.renpy.is_seen = False

Code: Select all

label _("Read text")
                textbutton _("Enabled") action SetField(persistent, "renpy.is_seen", True)
                textbutton _("Disabled") action SetField(persistent, "renpy.is_seen", False)


alexei
Regular
Posts: 137
Joined: Mon Sep 09, 2019 10:31 am
Completed: re:shape, Monster Boys Doctor, Hearts and Hexes, The Prince's Heart, Dragon Gazer
Projects: Motifs, Longing for Change, The Sinking of the Dream Chaser, Town of the Damned, Monster Boy Wars
Organization: Funigami
itch: funigami
Discord: alexei#5190
Contact:

Re: How to change text color in say screen after player read it.

#8 Post by alexei »

Andredron wrote: Fri Sep 16, 2022 4:02 pm From the phone I write something like this, but I could be wrong

Code: Select all

init python:

    # Set the default value.
    if persistent.renpy.is_seen is None:
        persistent.renpy.is_seen = False

Code: Select all

label _("Read text")
                textbutton _("Enabled") action SetField(persistent, "renpy.is_seen", True)
                textbutton _("Disabled") action SetField(persistent, "renpy.is_seen", False)

cool, thanks!

Should the persistent is seen be placed along with the say screen you placed above?


alexei
Regular
Posts: 137
Joined: Mon Sep 09, 2019 10:31 am
Completed: re:shape, Monster Boys Doctor, Hearts and Hexes, The Prince's Heart, Dragon Gazer
Projects: Motifs, Longing for Change, The Sinking of the Dream Chaser, Town of the Damned, Monster Boy Wars
Organization: Funigami
itch: funigami
Discord: alexei#5190
Contact:

Re: How to change text color in say screen after player read it.

#10 Post by alexei »

Andredron wrote: Sat Sep 17, 2022 4:56 amYes
Here's what I'm getting.


Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/gui.rpy", line 417, in script
    init python:
  File "game/gui.rpy", line 417, in script
    init python:
  File "game/gui.rpy", line 445, in <module>
    if persistent.renpy.is_seen is None:
AttributeError: 'NoneType' object has no attribute 'is_seen'

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

Full traceback:
  File "D:\renpy\renpy-8.0.1-sdk\renpy\bootstrap.py", line 277, in bootstrap
    renpy.main.main()
  File "D:\renpy\renpy-8.0.1-sdk\renpy\main.py", line 558, in main
    renpy.game.context().run(node)
  File "game/gui.rpy", line 417, in script
    init python:
  File "/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/site-packages/future/utils/__init__.py", line 441, in raise_
  File "game/gui.rpy", line 417, in script
    init python:
  File "D:\renpy\renpy-8.0.1-sdk\renpy\ast.py", line 1131, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\renpy\renpy-8.0.1-sdk\renpy\python.py", line 1061, in py_exec_bytecode
    exec(bytecode, globals, locals)
  File "game/gui.rpy", line 445, in <module>
    if persistent.renpy.is_seen is None:
AttributeError: 'NoneType' object has no attribute 'is_seen'

Windows-10-10.0.22000 AMD64
Ren'Py 8.0.3.22090809
Project Motif 0.2
Sat Sep 17 22:34:35 2022
Any advice?

Post Reply

Who is online

Users browsing this forum: No registered users