Ren'Py memo

Ren'Pyの個人的なメモ

バックログにロールバックのボタンをつける

参照 little-used history chips - Lemma Soft Forums
資料1 Adding a history/backlog jump button - Lemma Soft Forums
資料2 https://ja.renpy.org/doc/html/config.html#var-config.hard_rollback_limit
資料3 https://ja.renpy.org/doc/html/config.html#var-config.rollback_length


define config.hard_rollback_limit = 128
define config.rollback_length = 128

screen history():

 style_prefix "history"
 for h in _history_list:

   window:

(省略)

    textbutton "Jump":
     action Confirm(_('このテキストまでジャンプしますか?'), yes=RollbackToIdentifier(h.rollback_identifier), no=None, confirm_selected=False)

config.rollback_lengthはデフォルトの128より下回ると不安定になるので注意。

名前入力などのスクリーンを挟むなど想定外っぽいことをした場合、挙動がおかしくなる場合があります。

        call name_change(1) from _call_name_change
        call pronoun_change(1) from _pronoun_change
        $ renpy.block_rollback()

こんな感じでロールバックを防いで応急処置はできます。