problems showing a screen inside the novel

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
CharlieFuu69
Regular
Posts: 30
Joined: Mon Nov 11, 2019 10:32 pm
Projects: Current projects using Ren'Py : "Tears: The First Love!" (Visual Novel at 90%) , "ElectroBasics Electronic Quiz!" (Educative game at 45%).
Location: Chile
Contact:

problems showing a screen inside the novel

#1 Post by CharlieFuu69 » Sat May 02, 2020 3:52 pm

Hello again. Here I come again with a novice level question.
I have declared a screen where I added with "add" a clock and the clock background which is a PNG image, next to the transformations that I have defined in another RPY file for each object.

Image

In the novel script, I call this screen using "show screen Realtime_Clock" and it appears correctly on the screen.

Image

But there is a problem when I save the game, close the game and start it again. When loading that same game, the objects on the screen get out of control and disobey the transformations that I assigned them previously.

Image

What can I do to avoid this problem? I have already tried using zorder not to use "show screen" but the clock does not even appear on the screen, even if I use a high digit.

Any help I appreciate it.

User avatar
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: problems showing a screen inside the novel

#2 Post by hell_oh_world » Sat May 02, 2020 4:30 pm

CharlieFuu69 wrote:
Sat May 02, 2020 3:52 pm
Hello again. Here I come again with a novice level question.
I have declared a screen where I added with "add" a clock and the clock background which is a PNG image, next to the transformations that I have defined in another RPY file for each object.

Image

In the novel script, I call this screen using "show screen Realtime_Clock" and it appears correctly on the screen.

Image

But there is a problem when I save the game, close the game and start it again. When loading that same game, the objects on the screen get out of control and disobey the transformations that I assigned them previously.

Image

What can I do to avoid this problem? I have already tried using zorder not to use "show screen" but the clock does not even appear on the screen, even if I use a high digit.

Any help I appreciate it.
Here's the thing, I see that you've defined your wall clock and other images, which is bad as defined variables are not saved by the game. That's the reason why it prolly breaks when you're loading it. Try doing it with image statement.

Code: Select all

image wall_clock = DynamicDisplayable(wall_clock_function)
# and so on...

screen wall_clock:
    add "wall_clock" at wall_clock_transform
    # and so on...
Then just show it as what you normally do.

User avatar
CharlieFuu69
Regular
Posts: 30
Joined: Mon Nov 11, 2019 10:32 pm
Projects: Current projects using Ren'Py : "Tears: The First Love!" (Visual Novel at 90%) , "ElectroBasics Electronic Quiz!" (Educative game at 45%).
Location: Chile
Contact:

Re: problems showing a screen inside the novel

#3 Post by CharlieFuu69 » Sat May 02, 2020 4:42 pm

Try doing it with image statement.
No problem if I put the image definition inside an init block? Now I will start the test with your advice.

User avatar
CharlieFuu69
Regular
Posts: 30
Joined: Mon Nov 11, 2019 10:32 pm
Projects: Current projects using Ren'Py : "Tears: The First Love!" (Visual Novel at 90%) , "ElectroBasics Electronic Quiz!" (Educative game at 45%).
Location: Chile
Contact:

Re: problems showing a screen inside the novel

#4 Post by CharlieFuu69 » Sat May 02, 2020 4:53 pm

I get an error if I use "image" instead of "define". The same error occurs when calling the clock ...

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/chapter_01.rpy", line 115, in script
    "Aqui voy de nuevo... Saliendo de mi casa para regresar a los estudios..."
  File "game/screens.rpy", line 126, in execute
    screen Realtime_Clock():
  File "game/screens.rpy", line 126, in execute
    screen Realtime_Clock():
  File "game/screens.rpy", line 128, in execute
    add clock_bg at clock_base_pos
NameError: name 'clock_bg' is not defined

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

Full traceback:
  File "game/chapter_01.rpy", line 115, in script
    "Aqui voy de nuevo... Saliendo de mi casa para regresar a los estudios..."
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\ast.py", line 706, in execute
    renpy.exports.say(who, what, *args, **kwargs)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\exports.py", line 1336, in say
    who(what, *args, **kwargs)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\character.py", line 1139, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\character.py", line 842, in do_display
    **display_args)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\character.py", line 591, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\ui.py", line 295, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 2699, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 3091, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\screen.py", line 430, in visit_all
    callback(self)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 3091, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\screen.py", line 440, in per_interact
    self.update()
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\screen.py", line 625, in update
    self.screen.function(**self.scope)
  File "game/screens.rpy", line 126, in execute
    screen Realtime_Clock():
  File "game/screens.rpy", line 126, in execute
    screen Realtime_Clock():
  File "game/screens.rpy", line 128, in execute
    add clock_bg at clock_base_pos
  File "<screen language>", line 128, in <module>
NameError: name 'clock_bg' is not defined

Windows-8-6.2.9200
Ren'Py 7.3.2.320
Tears : The First Love! v1.20
Sat May 02 17:52:19 2020
Last edited by CharlieFuu69 on Sat May 02, 2020 5:02 pm, edited 1 time in total.

User avatar
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: problems showing a screen inside the novel

#5 Post by hell_oh_world » Sat May 02, 2020 4:56 pm

CharlieFuu69 wrote:
Sat May 02, 2020 4:53 pm
I get an error if I use "image" instead of "define"

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/chapter_01.rpy", line 115, in script
    "Aqui voy de nuevo... Saliendo de mi casa para regresar a los estudios..."
  File "game/screens.rpy", line 126, in execute
    screen Realtime_Clock():
  File "game/screens.rpy", line 126, in execute
    screen Realtime_Clock():
  File "game/screens.rpy", line 128, in execute
    add clock_bg at clock_base_pos
NameError: name 'clock_bg' is not defined

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

Full traceback:
  File "game/chapter_01.rpy", line 115, in script
    "Aqui voy de nuevo... Saliendo de mi casa para regresar a los estudios..."
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\ast.py", line 706, in execute
    renpy.exports.say(who, what, *args, **kwargs)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\exports.py", line 1336, in say
    who(what, *args, **kwargs)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\character.py", line 1139, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\character.py", line 842, in do_display
    **display_args)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\character.py", line 591, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\ui.py", line 295, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 2699, in interact
    repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 3091, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 541, in visit_all
    d.visit_all(callback, seen)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\screen.py", line 430, in visit_all
    callback(self)
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\core.py", line 3091, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\screen.py", line 440, in per_interact
    self.update()
  File "E:\@CharlieFuu69 OT-SUR\renpy-7.3.2-sdk\renpy\display\screen.py", line 625, in update
    self.screen.function(**self.scope)
  File "game/screens.rpy", line 126, in execute
    screen Realtime_Clock():
  File "game/screens.rpy", line 126, in execute
    screen Realtime_Clock():
  File "game/screens.rpy", line 128, in execute
    add clock_bg at clock_base_pos
  File "<screen language>", line 128, in <module>
NameError: name 'clock_bg' is not defined

Windows-8-6.2.9200
Ren'Py 7.3.2.320
Tears : The First Love! v1.20
Sat May 02 17:52:19 2020
Please look very carefully, my example uses string in the add statement. And yeah, image statements should be declared with 0 level of indentation outside screens and labels. Still you can do it inside init blocks, but that depends. I prefer the former.

User avatar
CharlieFuu69
Regular
Posts: 30
Joined: Mon Nov 11, 2019 10:32 pm
Projects: Current projects using Ren'Py : "Tears: The First Love!" (Visual Novel at 90%) , "ElectroBasics Electronic Quiz!" (Educative game at 45%).
Location: Chile
Contact:

Re: problems showing a screen inside the novel

#6 Post by CharlieFuu69 » Sat May 02, 2020 5:13 pm

Mire con mucho cuidado, mi ejemplo usa cadena en la declaración de agregar. Y sí, las declaraciones de imágenes deben declararse con 0 niveles de sangría fuera de las pantallas y etiquetas. Aún así puedes hacerlo dentro de los bloques de inicio, pero eso depende. Prefiero lo primero.
Image

It worked again, but it has the same out-of-control error. It just doesn't obey the transformation when the game loads.

User avatar
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: problems showing a screen inside the novel

#7 Post by hell_oh_world » Sat May 02, 2020 5:24 pm

Quoting from the docs
Note that these dynamic displayables always display their current state. Because of this, a dynamic displayable will not participate in a transition. (Or more precisely, it will display the same thing in both the old and new states of the transition.)

By design, dynamic displayables are intended to be used for things that change rarely and when an image define this way is off screen (Such as a character customization system), and not for things that change frequently, such as character emotions.
If that didn't fix the problem, then you prolly want to change it to other displayable types. Other than Dynamic Displayables. Refer from the above quote and in the docs.
Make sure also that youre not using the old save. Try saving new after making the changes, then load that instead.

Post Reply

Who is online

Users browsing this forum: span4ev