Text History error when rolling back during transition

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
User avatar
aqua.soo
Newbie
Posts: 15
Joined: Tue Jun 03, 2014 4:27 am
Location: Korea
Contact:

Text History error when rolling back during transition

#1 Post by aqua.soo »

I was trying out Text History from the old wiki's cookbook and noticed that the game encounters an error when you try to scroll back during a with transition, if the with statement is in its own line—as opposed to being a clause like show ... with.

The problem seems to be that a standalone with statement has no text to show. How could this be fixed?

Code: Select all

Full traceback:
  File "renpy/common/00gamemenu.rpy", line 163, in script
    $ ui.interact()
  File "/home/user/renpy/renpy/ast.py", line 756, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "/home/user/renpy/renpy/python.py", line 1382, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/00gamemenu.rpy", line 163, in <module>
    $ ui.interact()
  File "/home/user/renpy/renpy/ui.py", line 264, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "/home/user/renpy/renpy/display/core.py", line 2058, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "/home/user/renpy/renpy/display/core.py", line 2302, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "/home/user/renpy/renpy/display/core.py", line 306, in visit_all
    d.visit_all(callback)
  File "/home/user/renpy/renpy/display/core.py", line 306, in visit_all
    d.visit_all(callback)
  File "/home/user/renpy/renpy/display/core.py", line 306, in visit_all
    d.visit_all(callback)
  File "/home/user/renpy/renpy/display/core.py", line 306, in visit_all
    d.visit_all(callback)
  File "/home/user/renpy/renpy/display/core.py", line 308, in visit_all
    callback(self)
  File "/home/user/renpy/renpy/display/core.py", line 2302, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "/home/user/renpy/renpy/display/screen.py", line 173, in per_interact
    self.update()
  File "/home/user/renpy/renpy/display/screen.py", line 277, in update
    self.screen.function(**self.scope)
  File "/home/user/renpy/renpy/screenlang.py", line 1236, in __call__
    renpy.python.py_exec_bytecode(self.code.bytecode, locals=scope)
  File "/home/user/renpy/renpy/python.py", line 1382, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/readback.rpy", line 296, in <module>
    text line[1]
  File "/home/user/renpy/renpy/ui.py", line 469, in __call__
    w = self.function(*args, **keyword)
  File "/home/user/renpy/renpy/text/text.py", line 1159, in __init__
    raise Exception("Cannot display {0!r} as text.".format(i))
Exception: Cannot display None as text.

While running game code:
  File "renpy/common/00gamemenu.rpy", line 163, in script
    $ ui.interact()
  File "renpy/common/00gamemenu.rpy", line 163, in <module>
    $ ui.interact()
  File "game/readback.rpy", line 296, in <module>
    text line[1]
Exception: Cannot display None as text.

JD_Mortal
Regular
Posts: 37
Joined: Mon Jul 21, 2014 3:01 am

Re: Text History error when rolling back during transition

#2 Post by JD_Mortal »

Try empty quotes...

"" or '' <- Nothing between the quotes, not even a space. (Or try adding a space, if that might help.)

Thus, it will not be "nothing" (Null=Never-existed), but (Empty=No-longer-exists), thus, may display as a blank-line in the roll-back.

However, the rollback needs to be programmed to handle (Null), and (Empty), as neither of them can be displayed, and should not be "jumped to", when returning from a roll-back. Since a (Null) or an (Empty), should return to the "next line", where it may be a transition at the current (position), as in your case.

Thus, the WITH will now be bound to "something" as opposed to "nothing", even if that "something" is not "displayable".

User avatar
aqua.soo
Newbie
Posts: 15
Joined: Tue Jun 03, 2014 4:27 am
Location: Korea
Contact:

Re: Text History error when rolling back during transition

#3 Post by aqua.soo »

The issue indeed was that the text history log was picking up the None say attached to standalone with statements.

After fiddling around with the code, I found the problem. The if-elif-else block in screen text_history is supposed to prevent this kind of error, but it has a mistake. Here's the fix.

Code: Select all

    if not current_line[1] and len(readback_buffer) == 0:
        $ lines_to_show = []

    elif current_line[1] and len(readback_buffer) == 0:
        $ lines_to_show = [current_line]

    elif current_line[1] and not ( ( len(readback_buffer) == 3 and current_line == readback_buffer[-2]) or current_line == readback_buffer[-1]):  
        $ lines_to_show = readback_buffer + [current_line]

    else:
        $ lines_to_show = readback_buffer
The wiki says that its cookbook is outdated and people should check the forum's cookbook section. Should I fix the wiki's code or just post here?

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot]