[SOLVED] Rollback problems

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
Dreamtale
Regular
Posts: 28
Joined: Tue Jan 11, 2011 8:15 pm
Contact:

[SOLVED] Rollback problems

#1 Post by Dreamtale »

Ok, so here's the thing: I try to implement this (http://www.renpy.org/wiki/renpy/doc/cookbook/Readback) with some modifications. What I want: if you click on the phrase in the log, the game rollbacks to this phrase. Here's the code (I will not post all the code from the link, beacause it' pretty much the same, only the parts that differ):

Code: Select all

window:
        style_group "readback"
    
        side "c r":
            
            frame:
                
                $ vp = ui.viewport(mousewheel = True, offsets=(0.0, yvalue), yadjustment = adj)

                vbox:
                    null height 10
                    
                    python:
                        count=1
                        total=0
                        
                        mass = lines_to_show
                        for i in mass:
                            if i[1]:
                                if not i[2]:
                                    total+=1
                    
                    for line in lines_to_show:
                        
                        if line[0] and line[0] != " ":
                            label line[0] # name

                        if line[1]:
                            # if there's no voice just log a dialogue
                            if not line[2]:
                                python:
                                    cn=total-count                   
                                    count+=1
                                if font_size == "small":
                                    textbutton line[1] text_size 28 style "log_button" text_style "log_button_text" action FunctionCallback(do_rollback,cn)
                                elif font_size == "large":
                                    textbutton line[1] text_size 35 style "log_button" text_style "log_button_text" action FunctionCallback(do_rollback,cn)
                                else:
                                    null height 
                            else: 
                                textbutton line[1] action Play("voice", line[2] )
                        
                        null height 10
                    python:
                        count=None
                        total=None
                        mass=None
Next:

Code: Select all

        
class FunctionCallback(Action):
            def __init__(self,function,*arguments):
                self.function=function
                self.arguments=arguments
            def __call__(self):
                return self.function(self.arguments)#"script.rpy", line 50

def do_rollback(cnt):
            k=cnt[0]
            renpy.rollback(True, k)#"script.rpy", line 78
Then, comes the problem: if I try to jump like 15-20 lines back, it works fine, but if I go ~40 lines, this exception occurs:
I'm sorry, but an uncaught exception occurred.

While running game code:
File "scenario/prologue/prologue.rpy", line 97, in script
File "renpy/common/00action_menu.rpy", line 78, in python
File "renpy/common/00gamemenu.rpy", line 144, in script
File "renpy/common/00gamemenu.rpy", line 144, in python
File "script.rpy", line 50, in python
File "script.rpy", line 78, in python
Exception: Couldn't find a place to stop rolling back. Perhaps the script changed in an incompatible way?

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

Full traceback:
File "c:\renpy\renpy\bootstrap.py", line 265, in bootstrap
renpy.main.main()
File "c:\renpy\renpy\main.py", line 332, in main
run(restart)
File "c:\renpy\renpy\main.py", line 90, in run
renpy.execution.run_context(True)
File "c:\renpy\renpy\execution.py", line 509, in run_context
context.run()
File "c:\renpy\renpy\execution.py", line 288, in run
node.execute()
File "c:\renpy\renpy\ast.py", line 453, in execute
renpy.exports.say(who, what, interact=self.interact)
File "c:\renpy\renpy\exports.py", line 757, in say
who(what, interact=interact)
File "c:\renpy\renpy\character.py", line 795, in __call__
self.do_display(who, what, cb_args=self.cb_args, **display_args)
File "c:\renpy\renpy\character.py", line 671, in do_display
**display_args)
File "c:\renpy\renpy\character.py", line 474, in display_say
rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
File "c:\renpy\renpy\ui.py", line 237, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "c:\renpy\renpy\display\core.py", line 1853, in interact
repeat, rv = self.interact_core(preloads=preloads, **kwargs)
File "c:\renpy\renpy\display\core.py", line 2392, in interact_core
rv = root_widget.event(ev, x, y, 0)
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\screen.py", line 319, in event
rv = self.child.event(ev, x, y, st)
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\layout.py", line 175, in event
rv = d.event(ev, x - xo, y - yo, st)
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\behavior.py", line 625, in event
rv = run(self.clicked)
File "c:\renpy\renpy\display\behavior.py", line 211, in run
return var(*args, **kwargs)
File "renpy/common/00action_menu.rpy", line 78, in __call__
renpy.call_in_new_context("_game_menu", _game_menu_screen=screen)
File "c:\renpy\renpy\game.py", line 369, in call_in_new_context
return renpy.execution.run_context(False)
File "c:\renpy\renpy\execution.py", line 509, in run_context
context.run()
File "c:\renpy\renpy\execution.py", line 288, in run
node.execute()
File "c:\renpy\renpy\ast.py", line 718, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "c:\renpy\renpy\python.py", line 1297, in py_exec_bytecode
exec bytecode in globals, locals
File "renpy/common/00gamemenu.rpy", line 144, in <module>
$ ui.interact()
File "c:\renpy\renpy\ui.py", line 237, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "c:\renpy\renpy\display\core.py", line 1853, in interact
repeat, rv = self.interact_core(preloads=preloads, **kwargs)
File "c:\renpy\renpy\display\core.py", line 2392, in interact_core
rv = root_widget.event(ev, x, y, 0)
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\transition.py", line 45, in event
return self.new_widget.event(ev, x, y, st) # E1101
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\screen.py", line 319, in event
rv = self.child.event(ev, x, y, st)
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\layout.py", line 175, in event
rv = d.event(ev, x - xo, y - yo, st)
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\layout.py", line 175, in event
rv = d.event(ev, x - xo, y - yo, st)
File "c:\renpy\renpy\display\layout.py", line 175, in event
rv = d.event(ev, x - xo, y - yo, st)
File "c:\renpy\renpy\display\layout.py", line 1382, in event
rv = super(Viewport, self).event(ev, x, y, st)
File "c:\renpy\renpy\display\layout.py", line 175, in event
rv = d.event(ev, x - xo, y - yo, st)
File "c:\renpy\renpy\display\layout.py", line 749, in event
rv = i.event(ev, x - xo, y - yo, cst)
File "c:\renpy\renpy\display\behavior.py", line 625, in event
rv = run(self.clicked)
File "c:\renpy\renpy\display\behavior.py", line 211, in run
return var(*args, **kwargs)
File "script.rpy", line 50, in __call__
return self.function(self.arguments)
File "script.rpy", line 78, in do_rollback
renpy.rollback(True, k)
File "c:\renpy\renpy\exports.py", line 994, in rollback
renpy.game.log.rollback(checkpoints, greedy=greedy, label=label, force=force)
File "c:\renpy\renpy\python.py", line 1148, in rollback
raise Exception("Couldn't find a place to stop rolling back. Perhaps the script changed in an incompatible way?")
Exception: Couldn't find a place to stop rolling back. Perhaps the script changed in an incompatible way?
I've commented the lines from traceback in my code mentioned above.

Any help would be appreciated!
Last edited by Dreamtale on Wed Oct 16, 2013 9:16 am, edited 1 time in total.

User avatar
jesusalva
Regular
Posts: 88
Joined: Mon Jul 22, 2013 5:05 pm
Organization: Software in Public Interest, Inc.
IRC Nick: jesusalva
Github: pazkero
itch: tmw2
Location: Brazil
Discord: Jesusalva#4449
Contact:

Re: Rollback problems

#2 Post by jesusalva »

I'm a newbie also, but there are some things that I would like to you check:

Code: Select all


    config.rollback_enabled = True  # rollback is enabled?
    config.hard_rollback_limit = 50  # How much can you rollback?
    config.rollback_length = 100      # I don't remember what it does. It have something about log, I think? I don't remember.

Place that in your options.rpy file. I don't know if it will work, but, give it a try.
check also if you have at least 40 readable lines in your script. Ren'py said that there are no point to stop rolling back (The rollback historic ended). Maybe that help.
Jesusaves/Jesusalva

Dreamtale
Regular
Posts: 28
Joined: Tue Jan 11, 2011 8:15 pm
Contact:

Re: Rollback problems

#3 Post by Dreamtale »

jesusalva wrote: check also if you have at least 40 readable lines in your script.
I have much-much more, but still it makes sense - game crashes, if I try to rollback ~40 lines back. This is like, what, renpy's limit to roll back?

User avatar
jesusalva
Regular
Posts: 88
Joined: Mon Jul 22, 2013 5:05 pm
Organization: Software in Public Interest, Inc.
IRC Nick: jesusalva
Github: pazkero
itch: tmw2
Location: Brazil
Discord: Jesusalva#4449
Contact:

Re: Rollback problems

#4 Post by jesusalva »

Yes.
by default, Ren'Py limits rollback to... 40, just as you noticed. :lol:
just test this:

Code: Select all

    e "Very Well, let's test the 0-40 rollback interactions."
    e "0"
    e "1"
    e "2"
    e "3"
    e "4"
    e "5"
    e "6"
    e "7"
    e "8"
    e "9"
    e "10"
    e "11"
    e "12"
    e "13"
    e "14"
    e "15"
    e "16"
    e "17"
    e "18"
    e "19"
    e "20"
    e "21"
    e "22"
    e "23"
    e "24"
    e "25"
    e "26"
    e "27"
    e "28"
    e "29"
    e "30"
    e "31"
    e "32"
    e "33"
    e "34"
    e "35"
    e "36"
    e "37"
    e "38"
    e "39"
    e "40"
    e "Try rollback now."
Run util you eileen say "Try rollback now", and then, try rollback. it will stop in 1. and no more.
Jesusaves/Jesusalva

Dreamtale
Regular
Posts: 28
Joined: Tue Jan 11, 2011 8:15 pm
Contact:

Re: Rollback problems

#5 Post by Dreamtale »

jesusalva wrote: it will stop in 1. and no more.
No, it won't... It goes straight to "Very well...". So the problem's still here :(

User avatar
Alex
Lemma-Class Veteran
Posts: 3094
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Rollback problems

#6 Post by Alex »

Rollback length is 128 by default (see \renpy-6.15.4-sdk\renpy\config.py), so you need to re-set it in your script.

Dreamtale
Regular
Posts: 28
Joined: Tue Jan 11, 2011 8:15 pm
Contact:

Re: Rollback problems

#7 Post by Dreamtale »

Alex wrote:Rollback length is 128 by default (see \renpy-6.15.4-sdk\renpy\config.py), so you need to re-set it in your script.
It didn't help...

User avatar
jesusalva
Regular
Posts: 88
Joined: Mon Jul 22, 2013 5:05 pm
Organization: Software in Public Interest, Inc.
IRC Nick: jesusalva
Github: pazkero
itch: tmw2
Location: Brazil
Discord: Jesusalva#4449
Contact:

Re: Rollback problems

#8 Post by jesusalva »

Hmm... I will give you a quick solution. Granted, it won't do the rollback. but the game won't crash at it :)

So... that is it. if it cannot rollback, it won't do anything. that won't solve your problem. but... for quick solutions...

Code: Select all

def do_rollback(cnt):
            try:
                k=cnt[0]
                renpy.rollback(True, k)#"script.rpy", line 78? now it is line 79.
            except:
                pass
it will try the code. EXCEPT, it will pass.

It will avoid the notification. If you want keep a notification:

Code: Select all

def do_rollback(cnt):
            try:
                k=cnt[0]
                renpy.rollback(True, k)#"script.rpy", line 78? now it is line 79.
            except:
                raise Exception("Cannot rollback. Not rolling back.")
                #pass                       # that is anymore necessary. :)
Jesusaves/Jesusalva

Dreamtale
Regular
Posts: 28
Joined: Tue Jan 11, 2011 8:15 pm
Contact:

Re: Rollback problems

#9 Post by Dreamtale »

jesusalva wrote:I will give you a quick solution
Thanks, but I know what exceptions is. But I still want to make it work properly.
Apparently, the problem lies here:
renpy.rollback(True, k)
So, maybe there is an other way to roll back exact number of lines in renpy?

Dreamtale
Regular
Posts: 28
Joined: Tue Jan 11, 2011 8:15 pm
Contact:

Re: Rollback problems

#10 Post by Dreamtale »

Ok, I guess I solved it, at least partially, by setting like this:
config.rollback_length = 1000
config.hard_rollback_limit = 1000
Don't know if it will affect perfomance or something, but the game doesn't crush anymore.

Elmiwisa
Veteran
Posts: 476
Joined: Sun Jul 21, 2013 8:08 am
Contact:

Re: Rollback problems

#11 Post by Elmiwisa »

Wouldn't that still cause problem if you rollback further though?

Dreamtale
Regular
Posts: 28
Joined: Tue Jan 11, 2011 8:15 pm
Contact:

Re: Rollback problems

#12 Post by Dreamtale »

Elmiwisa wrote:Wouldn't that still cause problem if you rollback further though?
Well, no, because problem was only when I roll back using this:

Code: Select all

renpy.rollback(True, k)
If I just use mouse wheel, it goes pretty ok (and in release I intend to fully replace all rollback features with history log). So, while script from the cookbook has a limit to its own buffer:

Code: Select all

config.readback_buffer_length = 100
It cant go any further than this.

Post Reply

Who is online

Users browsing this forum: No registered users