[Solved] Say Function (in Screen) Bug
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.
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.
- haydengames3
- Newbie
- Posts: 13
- Joined: Wed Mar 17, 2021 9:56 am
- Contact:
[Solved] Say Function (in Screen) Bug
Hello I am very new to the Ren'py engine and have been trying to create an instance where I can use the screen function with the say function, this was mostly because I needed a way to always display a namebox. Anyway I encountered a strange bug where my dialogue that was being loaded from a screen was constantly running, even before it should have been called in the script. I have created a simplified example to isolate this issue, images below.
Base Script: Problem Code: Effect: I was also getting an error message in my main project when the script reached the part of the code where it should have ran the screen.
Error:
```
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 86, in script
$ renpy.pause(hard=True)
File "game/script.rpy", line 86, in <module>
$ renpy.pause(hard=True)
File "game/image.rpy", line 29, in execute
screen test_screen():
File "game/image.rpy", line 29, in execute
screen test_screen():
File "game/image.rpy", line 30, in execute
imagebutton:
File "game/image.rpy", line 30, in keywords
imagebutton:
File "game/image.rpy", line 32, in <module>
action say("Test Name","This is a test")
File "renpy/common/00library.rpy", line 268, in say
who(what, interact=interact, *args, **kwargs)
Exception: ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?
Stack was <Layer: u'transient'>
<Many: <Fixed at 35d7750>>
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 86, in script
$ renpy.pause(hard=True)
File "renpy/ast.py", line 922, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "renpy/python.py", line 2218, in py_exec_bytecode
exec(bytecode, globals, locals)
File "game/script.rpy", line 86, in <module>
$ renpy.pause(hard=True)
File "renpy/exports.py", line 1525, in pause
rv = renpy.ui.interact(mouse='pause', type='pause', roll_forward=roll_forward, pause=delay)
File "renpy/ui.py", line 298, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "renpy/display/core.py", line 3101, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
File "renpy/display/core.py", line 3512, in interact_core
root_widget.visit_all(lambda i : i.per_interact())
File "renpy/display/core.py", line 567, in visit_all
d.visit_all(callback, seen)
File "renpy/display/core.py", line 567, in visit_all
d.visit_all(callback, seen)
File "renpy/display/core.py", line 567, in visit_all
d.visit_all(callback, seen)
File "renpy/display/screen.py", line 432, in visit_all
callback(self)
File "renpy/display/core.py", line 3512, in <lambda>
root_widget.visit_all(lambda i : i.per_interact())
File "renpy/display/screen.py", line 443, in per_interact
self.update()
File "renpy/display/screen.py", line 631, in update
self.screen.function(**self.scope)
File "game/image.rpy", line 29, in execute
screen test_screen():
File "game/image.rpy", line 29, in execute
screen test_screen():
File "game/image.rpy", line 30, in execute
imagebutton:
File "game/image.rpy", line 30, in keywords
imagebutton:
File "game/image.rpy", line 32, in <module>
action say("Test Name","This is a test")
File "renpy/common/00library.rpy", line 268, in say
who(what, interact=interact, *args, **kwargs)
File "renpy/character.py", line 1205, in __call__
self.do_display(who, what, cb_args=self.cb_args, dtt=dtt, **display_args)
File "renpy/character.py", line 871, in do_display
**display_args)
File "renpy/character.py", line 621, in display_say
rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
File "renpy/ui.py", line 292, in interact
raise Exception("ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?\nStack was " + ('\n'.join([str(item) for item in stack])))
Exception: ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?
Stack was <Layer: u'transient'>
<Many: <Fixed at 35d7750>>
Windows-10-10.0.19041
Ren'Py 7.4.3.1414
Test 1.0
Thu Mar 18 01:28:48 2021
```
If anyone knows how I can run this function inside a screen or if it's just not possible with the base ui, please let me know.
Base Script: Problem Code: Effect: I was also getting an error message in my main project when the script reached the part of the code where it should have ran the screen.
Error:
```
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 86, in script
$ renpy.pause(hard=True)
File "game/script.rpy", line 86, in <module>
$ renpy.pause(hard=True)
File "game/image.rpy", line 29, in execute
screen test_screen():
File "game/image.rpy", line 29, in execute
screen test_screen():
File "game/image.rpy", line 30, in execute
imagebutton:
File "game/image.rpy", line 30, in keywords
imagebutton:
File "game/image.rpy", line 32, in <module>
action say("Test Name","This is a test")
File "renpy/common/00library.rpy", line 268, in say
who(what, interact=interact, *args, **kwargs)
Exception: ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?
Stack was <Layer: u'transient'>
<Many: <Fixed at 35d7750>>
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 86, in script
$ renpy.pause(hard=True)
File "renpy/ast.py", line 922, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "renpy/python.py", line 2218, in py_exec_bytecode
exec(bytecode, globals, locals)
File "game/script.rpy", line 86, in <module>
$ renpy.pause(hard=True)
File "renpy/exports.py", line 1525, in pause
rv = renpy.ui.interact(mouse='pause', type='pause', roll_forward=roll_forward, pause=delay)
File "renpy/ui.py", line 298, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "renpy/display/core.py", line 3101, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, pause=pause, pause_start=pause_start, **kwargs)
File "renpy/display/core.py", line 3512, in interact_core
root_widget.visit_all(lambda i : i.per_interact())
File "renpy/display/core.py", line 567, in visit_all
d.visit_all(callback, seen)
File "renpy/display/core.py", line 567, in visit_all
d.visit_all(callback, seen)
File "renpy/display/core.py", line 567, in visit_all
d.visit_all(callback, seen)
File "renpy/display/screen.py", line 432, in visit_all
callback(self)
File "renpy/display/core.py", line 3512, in <lambda>
root_widget.visit_all(lambda i : i.per_interact())
File "renpy/display/screen.py", line 443, in per_interact
self.update()
File "renpy/display/screen.py", line 631, in update
self.screen.function(**self.scope)
File "game/image.rpy", line 29, in execute
screen test_screen():
File "game/image.rpy", line 29, in execute
screen test_screen():
File "game/image.rpy", line 30, in execute
imagebutton:
File "game/image.rpy", line 30, in keywords
imagebutton:
File "game/image.rpy", line 32, in <module>
action say("Test Name","This is a test")
File "renpy/common/00library.rpy", line 268, in say
who(what, interact=interact, *args, **kwargs)
File "renpy/character.py", line 1205, in __call__
self.do_display(who, what, cb_args=self.cb_args, dtt=dtt, **display_args)
File "renpy/character.py", line 871, in do_display
**display_args)
File "renpy/character.py", line 621, in display_say
rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
File "renpy/ui.py", line 292, in interact
raise Exception("ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?\nStack was " + ('\n'.join([str(item) for item in stack])))
Exception: ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?
Stack was <Layer: u'transient'>
<Many: <Fixed at 35d7750>>
Windows-10-10.0.19041
Ren'Py 7.4.3.1414
Test 1.0
Thu Mar 18 01:28:48 2021
```
If anyone knows how I can run this function inside a screen or if it's just not possible with the base ui, please let me know.
Last edited by haydengames3 on Mon Mar 22, 2021 2:30 pm, edited 1 time in total.
Re: Say Function (in Screen) Bug
Screens are called many times before they ever get displayed, by Ren'Py's "prediction" scheme. Basically, Ren'Py is constantly looking ahead (by default, 32 statements ahead) to see what images are going to be needed soon so they can be preloaded into the buffer. That means any given screen could be easily called 32 separate times before it ever gets displayed to the player.
What *that* means is that it's important that screens don't *do* anything except display themselves.
What *that* means is that it's important that screens don't *do* anything except display themselves.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
Re: Say Function (in Screen) Bug
If I understand you right, all you need to do is set the variable
Code: Select all
define config.window = "show"I've never used this config so I can't say what the gotchas are, though.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
- haydengames3
- Newbie
- Posts: 13
- Joined: Wed Mar 17, 2021 9:56 am
- Contact:
Re: Say Function (in Screen) Bug
More so looking how to keep a name of a character on the screen, so in this case the name "Character" being on the top left of the textbox. so if I were to use something like:
$ other_name = renpy.input("What is your name?\n ")
I would be able to display who is asking the question without creating another dialogue box.
$ other_name = renpy.input("What is your name?\n ")
I would be able to display who is asking the question without creating another dialogue box.
Re: Say Function (in Screen) Bug
It seems like it would be easier/better to alter the input and choice screens to show a character name, if that's specifically what you want. Or if that's not it, then could you mock up an image of what you want things to look like so we can better understand what you're looking for?
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
- haydengames3
- Newbie
- Posts: 13
- Joined: Wed Mar 17, 2021 9:56 am
- Contact:
Re: Say Function (in Screen) Bug
renpy.input() to my knowledge, doesn't have a way of having both the name of a character and dialogue both being displayed at once. What I want to do is have a named character ask a question such as "What is your name?" and allow the player to input their name as part of the same dialogue.
Example: Thank you for the help by the way.
Example: Thank you for the help by the way.
- hell_oh_world
- Miko-Class Veteran
- Posts: 777
- Joined: Fri Jul 12, 2019 5:21 am
- Projects: The Button Man
- Organization: NILA
- Github: hell-oh-world
- Location: Philippines
- Contact:
Re: Say Function (in Screen) Bug
you can try this.
This works, but you might need to adjust the screen `input` in `screens.rpy` and add a `background None` to the `window` container.
Code: Select all
define mc = Character("Jake")
label start:
python:
renpy.say(mc, "", interact=False)
name = renpy.input("What's your name?").strip()
- haydengames3
- Newbie
- Posts: 13
- Joined: Wed Mar 17, 2021 9:56 am
- Contact:
Re: Say Function (in Screen) Bug
Thank you, that worked perfectly.
Who is online
Users browsing this forum: No registered users