little-used history chips

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
Andredron
Miko-Class Veteran
Posts: 535
Joined: Thu Dec 28, 2017 2:37 pm
Completed: Kimi ga nozomu renpy-port(demo), Albatross Koukairoku(demo)
Projects: Sisters ~Natsu no Saigo no Hi~(renpy-port)
Location: Russia
Contact:

little-used history chips

#1 Post by Andredron » Sat Jul 30, 2022 4:53 pm

Image
1)Add a play sound button

Code: Select all

screen history():

    tag menu

    ## Avoid predicting this screen as it can be very
    ## massive.
    predict False

    use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=1.0):

        style_prefix "history"

        for h in _history_list:

            windows:

                ## This will properly equalize if history_height is
                ## is set to None.
                has fixed:
                    yfit True

                if h.who:
############################################################################
                    if h.voice and h.voice.filename:                                          ###Here, of course, it is better to put a graphic button, less hassle with setting its location
                        textbutton "Play" action Play("voice", h.voice.filename)
############################################################################
                    label h.who:
                        style "history_name"
                        substitute False

                        ## Gets the color from the character's who parameter, if it
                        ## installed.
                        if "color" in h.who_args:
                            text_color h.who_args["color"]

                $ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags)
                text what:
                    substitute False

        if not _history_list:
            label _("History of dialogs is empty.")
2)Roll back to this text

Code: Select all

screenhistory():

    tag menu

    ## Avoid predicting this screen as it can be very
    ## massive.
    predict False

    use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=1.0):

        style_prefix "history"

        for h in _history_list:

            windows:

                ## This will properly equalize if history_height is
                ## is set to None.
                has fixed:
                    yfit True

                if h.who:

                    if h.voice and h.voice.filename:
                        textbutton "Play" action Play("voice", h.voice.filename)
#############################################################################################
                       textbutton "ROLL BACK" action Confirm("Jump?", yes=RollbackToIdentifier(h.rollback_identifier), no=None, confirm_selected=False) ​​xpos 0 ypos 30           ##########After pressing the button, you will roll back
############################################################################################
                    label h.who:
                        style "history_name"
                        substitute False

                        ## Gets the color from the character's who parameter, if it
                        ## installed.
                        if "color" in h.who_args:
                            text_color h.who_args["color"]

                $ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags)
                text what:
                    substitute False

        if not _history_list:
            label _("History of dialogs is empty.")
And in the gui file, you will have to change the size of the saved points, and the size of the control points

Code: Select all

define config.hard_rollback_limit = 100
define config.rollback_length = 100

3) How to change the text on the history screen

Code: Select all

label start:
	"Hi! I couldn't wait to see you again!"
	$ _history_list[-1].what = "I hate you. Wish you were dead."
	"If you check history now, you will notice that the last entry changed"


4) Add head

Code: Select all

screenhistory():

    tag menu

    ## Avoid predicting this screen as it can be very
    ## massive.
    predict False

    use game_menu(_("History"), scroll=("vpgrid" if gui.history_height else "viewport"), yinitial=1.0):

        style_prefix "history"

        for h in _history_list:

            windows:

                ## This will properly equalize if history_height is
                ## is set to None.
                has fixed:
                    yfit True
#####################################################################
                    if h.who:
                        hbox:
                            if h.image_tag:
                                add "history" + h.image_tag
                            else:
                                null width 100
######################################################################

                    if h.voice and h.voice.filename:
                        textbutton "Play" action Play("voice", h.voice.filename)

                    textbutton "ROLL BACK" action RollbackToIdentifier(h.rollback_identifier) ​​xpos 0 ypos 30

                    label h.who:
                        style "history_name"
                        substitute False

                        ## Gets the color from the character's who parameter, if it
                        ## installed.
                        if "color" in h.who_args:
                            text_color h.who_args["color"]

                $ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags)
                text what:
                    substitute False

        if not _history_list:
            label _("History of dialogs is empty.")
script.rpy

Code: Select all

define character.yesod = Character("Yesod", image="yesod")
image yesod smiling = "_YesodSmiling.png"
image history yesod = "yesod-6.png"

label start:
    show yesod smiling
    yesod "Hello"
    yesod ". . ."
    ". . ."
    yesod "Test"
    return
another option viewtopic.php?p=517246#p517246

5) change text color

Code: Select all

$ what = renpy.filter_text_tags(h.what, allow=gui.history_allow_tags)
                 text what:
                     color "#FFD700" ###################color
                     substitute False

         if not _history_list:
             label _("History of dialogs is empty.")
6) Adding choices selected to History without showing to user
viewtopic.php?t=40329

7) Having unselected choices in History?
viewtopic.php?p=548775#p548775

8) disable history

Code: Select all


     $ store._history = True ### history on
     
     voice "voice/003.ogg"
     nez "{w=0.5}How are you feeling?{w=1.0}{nw}"

     $ store._history = False ### # history off
     show mor02
     nez "How do you feel?{fast}"
     
9) Replace rollback with History
viewtopic.php?p=545688#p545688

10) Scrollbar thumb has a white border
viewtopic.php?p=534763#p534763

11) add images to history log [works with layeredimages]
viewtopic.php?p=534271#p534271

12) How to register a mouse call with a wheel

Code: Select all

screen my_keys:
    key "mousedown_5" action ShowMenu("history")
    key 'K_ESCAPE' action ShowMenu('preferences')
    key 'mouseup_3' action ShowMenu('save')
    
label start:
    show screen my_keys
    "text"
13)Implementation of a history scrollbar scrolling to the end to close

Code: Select all

init python:
    class MyAdjustment(renpy.display.behavior.Adjustment):
        def change(self, value):
            if value > self._range and self._value == self._range:
                # *Return to the game screen*
                return Return()
            else:
                # Otherwise, just do what the Adjustment normally does
                return renpy.display.behavior.Adjustment.change(self, value)
screen game_menu add

Code: Select all

default adj = MyAdjustment(range = 100,changed =None,adjustable=True)
viewport

Code: Select all

yadjustment adj
14)Start from latest dialogue

viewtopic.php?f=8&t=50647

15)Changing dialogue history in rollback


viewtopic.php?p=542946#p542946
Last edited by Andredron on Wed Sep 14, 2022 5:31 am, edited 6 times in total.
I'm writing a Renpy textbook (in Russian). https://disk.yandex.ru/i/httNEajU7iFWHA (all information is out of date) Update 22.06.18

Help me to register in QQ International

Honest Critique

User avatar
Johan
Regular
Posts: 75
Joined: Mon Jan 14, 2019 5:58 pm
Projects: "And I saw the stars falling down..."
Organization: Novel & You
itch: johanww
Location: Perú
Discord: Johan#7444
Contact:

Re: little-used history chips

#2 Post by Johan » Sun Aug 21, 2022 1:34 pm

Oh my god, thank you so much!!
I had used other code for some of these but yours are way simpler, so I'm using it!! Thanks!! ^^
My newsletter: dev cats!
Check it out here!

◤ And I saw the stars ★ falling down... ◢
Check the official DEMO!
.

User avatar
Tess
Newbie
Posts: 23
Joined: Thu Aug 04, 2022 3:43 pm
Projects: The Songbird Guild
Organization: Yurisoft
Github: wainwt2
Discord: Tess#7782
Contact:

Re: little-used history chips

#3 Post by Tess » Fri Sep 16, 2022 12:14 am

This is insanely cool! Thanks so much for writing it up.

Post Reply

Who is online

Users browsing this forum: No registered users