Menu/Choice bug

In this forum we discuss the future of Ren'Py, both bug fixes and longer-term development. Pre-releases are announced and discussed here.
Post Reply
Message
Author
drKlauz
Veteran
Posts: 204
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Menu/Choice bug

#1 Post by drKlauz » Mon Sep 02, 2019 10:47 am

Click on "Click me" textbutton, click again to return to menu, see bug.
After you return from test_label menu is visible, yet "Testing menu bug" is not there.
Any simple workaround for this?

Code: Select all

default bob=Character('Bob')

label test_label:
  hide screen test_screen
  'Click to return to menu.\nCharacter line will not appear unless spoken by narrator.'
  return

screen test_screen():
  textbutton 'Click me' action Call('test_label',from_current=True) text_size 50

label start:
  show screen test_screen
  menu:
#    'Testing menu bug'
    bob 'Testing menu bug'
    'Quit':
      pass
  return
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

rames44
Veteran
Posts: 231
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Menu/Choice bug

#2 Post by rames44 » Mon Sep 02, 2019 12:55 pm

You are displaying the screen with “show” and it’s not modal, so execution is going to proceed to the next statement. When you get to the menu, it is only then that the game is waiting for an interaction. But when you execute the “call” from the shown screen, if you read the docs, it says it “ends the current statement and calls label.” In this case, the “current statement” is your menu, since that’s where Ren’py was when you clicked on the button.

So this isn’t a bug - it’s expected behavior. Using a “call” screen statement from inside a screen that is displayed using “show” is a ver weird combination

drKlauz
Veteran
Posts: 204
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Menu/Choice bug

#3 Post by drKlauz » Mon Sep 02, 2019 2:09 pm

Why it works as expected without character, but with default narrator?
Screen displayed during menu interaction, so call to label happens from menu statement and test_label returns to menu statement. I believe it should work just fine, but likely there is separate code paths when menu caption spoken by narrator and by normal character. Probably when spoken by character it generate two nodes, instead on one, as result label return to menu node, not to say node.

It is not very weird combination, i placed button in say screen what will show speaker character information etc, in this screen some functionality allow to interact with some item by calling that item label. After you done with information screen you close it and game returns to exact dialog line you opened information screen. Works perfectly except one specific case, when menu is displayed.
So it is perfectly valid code with one minor glitch, nothing lethal, but looks weird when say screen disappear.

P.S.:
Try this and see it works flawlessly:

Code: Select all

default bob=Character('Bob')

label test_label:
  hide screen test_screen
  'Click to return to menu.\nCharacter line will not appear unless spoken by narrator.'
  return

screen test_screen():
  textbutton 'Click me' action Call('test_label',from_current=True) text_size 50

label start:
  show screen test_screen
  menu:
    'Testing menu bug'
#    bob 'Testing menu bug'
    'Quit':
      pass
  return
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

drKlauz
Veteran
Posts: 204
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Menu/Choice bug

#4 Post by drKlauz » Mon Sep 02, 2019 3:02 pm

Ok, i looked what happens in RenPy guts and managed to hack proper behavior (for my use cases it works perfectly, no bugs seen so far, save/load/rollback works), tho i really would prefer official solution.

renpy/parser.py, at bottom of parse_menu:

Code: Select all

    rv.append(ast.Menu(loc, items, set, with_, has_say or has_caption, arguments, item_arguments))

    if has_say:                  ## ADDED
      rv[-1].has_caption=rv[-2]  ## ADDED

    for index, i in enumerate(rv):
renpy/execution.py, at Content.run method:

Code: Select all

            except renpy.game.CallException as e:

                if e.from_current:
                    if hasattr(node,'has_caption') and hasattr(node.has_caption,'name'):  ## ADDED
                        return_site = node.has_caption.name                               ## ADDED
                    else:                                                                 ## ADDED
                        return_site = node.name
                else:
P.S.: Force recompile project in launched or manually delete .rpyc files in project folder.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3038
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Menu/Choice bug

#5 Post by Imperf3kt » Mon Sep 02, 2019 3:16 pm

Remove the hash from the beginning of the line
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Free Android GUI - Updated occasionally

drKlauz
Veteran
Posts: 204
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Menu/Choice bug

#6 Post by drKlauz » Mon Sep 02, 2019 3:26 pm

Eh?
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3038
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: Menu/Choice bug

#7 Post by Imperf3kt » Mon Sep 02, 2019 5:19 pm

You said the line "testing menu bug" doesn't show, it's because you have a hash at the beginning of that line.

Code: Select all

  menu:
#    'Testing menu bug'
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Free Android GUI - Updated occasionally

drKlauz
Veteran
Posts: 204
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Menu/Choice bug

#8 Post by drKlauz » Mon Sep 02, 2019 5:26 pm

I said when line is said by defined character and not narrator it is not shown when returned from label.
Line was commented to show line what do not works, if you comment another line and uncomment this, then everything works, because line will be said by narrator.

Just start new project and copy code from first post intro script.rpy, run, click "Click me", click on chat box, see menu, but no "Testing menu bug" text.

Problem is: when that line is said by character, parser generate two nodes - Say and Menu - during menu interaction using call(label,from_current=True) mark Menu, but not Say node as return target. Patch i posted add special case handling for this.
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

User avatar
PyTom
Ren'Py Creator
Posts: 15478
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Menu/Choice bug

#9 Post by PyTom » Sun Sep 08, 2019 8:38 pm

I just landed a fix to this, patterned on drKlauz's suggestion.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

drKlauz
Veteran
Posts: 204
Joined: Mon Oct 12, 2015 3:04 pm
Contact:

Re: Menu/Choice bug

#10 Post by drKlauz » Mon Sep 09, 2019 5:07 am

Thank you very much!
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350

Post Reply

Who is online

Users browsing this forum: No registered users