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: 714
Joined: Thu Dec 28, 2017 2:37 pm
Location: Russia
Contact:

little-used history chips

#1 Post by Andredron »

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

https://old.reddit.com/r/RenPy/comments ... ?context=3

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

You may be interested in the following materials:
Last edited by Andredron on Mon Jan 29, 2024 7:09 am, edited 9 times in total.

User avatar
Johan
Regular
Posts: 76
Joined: Mon Jan 14, 2019 5:58 pm
Organization: DMEOW
itch: dmeow
Location: Perú
Discord: Johan#7444
Contact:

Re: little-used history chips

#2 Post by Johan »

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!! ^^
dmeow !
Check my silly blog!

◤ And I saw the stars ★ falling down... ◢
Check the game!! IT'S OUT!!!
.

User avatar
Tess
Regular
Posts: 59
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 »

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

User avatar
Li yuanlin
Regular
Posts: 88
Joined: Sat Aug 04, 2018 8:42 pm
Location: Hong Kong
Contact:

Re: little-used history chips

#4 Post by Li yuanlin »

13)Implementation of a history scrollbar scrolling to the end to close
This one has no effect in my new project,I don't kown why
stay hungry,stay foolish.

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

Re: little-used history chips

#5 Post by Andredron »

Li yuanlin wrote: Wed Feb 21, 2024 10:50 am 13)Implementation of a history scrollbar scrolling to the end to close
This one has no effect in my new project,I don't kown why
Try this, I tried to update the code from my phone, so it's not a sure working method.

Code: Select all


init python:
import renpy.display.behavior.Adjustment

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)

def my_change_function(value):
    if value > self._range and self._value == self._range:
        # 
        renpy.scene("game_menu")

###screen game_menu add
default adj = MyAdjustment(range = 100, changed = my_change_function, adjustable=True)

###viewport
    adj

Post Reply

Who is online

Users browsing this forum: No registered users