Errors in screens after upgrading to 6.18 [solved]

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
korova
Veteran
Posts: 217
Joined: Sat Jun 27, 2009 5:15 pm
Completed: Ivy, Chocolate, Time, Clair Obscur
Projects: Writing exercises, The House [Nano18]
Tumblr: korova08
itch: korova
Location: Normandie, France
Contact:

Errors in screens after upgrading to 6.18 [solved]

#1 Post by korova »

Hello !

I need your help to solve errors that have appeared after I upgraded to the new version of Ren'Py.

My code that used to work perfectly now causes errors.

I suppose that this is linked to the rewrite of screen language, but i don't know what to do to solve this.

Here is extracts of (I hope) relevant code

Code: Select all

##############################################################################
# Menu "Histoires"
#
# Écran utilisé pour choisir entre les différentes histoires de la compilation
screen histoires:
    
    tag menu
    
    #navigation avec une image map
    imagemap:
        auto "gui/histoires/histoire_%s.png"
        alpha True
        
        # section pour revenir au menu principal
        hotspot (0,0,999,150):
            action If(main_menu,Return(),MainMenu())
            hovered Show("aide_gui",message=_("Refermer ce tiroir"),position=(410,65))
            unhovered Hide ("aide_gui")
                    
        hotspot (209,425,215,82): # Ivy
            action Show("dossier_action",legende="ivy",souris=(316,466))
            hovered Show("dossier_hover",legende="ivy",souris=(316,466))
            unhovered Hide("dossier_hover")

# Affichage de la couverture du dossier
screen dossier_hover():
    
    tag dossier
     
    # simple affichage, sans interaction
    use dossier_couv(souris=souris,r=True) 
    use dossier_illu(souris=souris,r=True)
        
    
    # on rajoute un cache pour simuler la semi-sortie du dossier
    $ nom_cache = "gui/dossiers/cache_" + legende + ".png"
    add nom_cache yalign 1.0
    
    # on ajoute une bulle d'aide
    use aide_gui(message=_("Cliquer pour\nexaminer\nce dossier"),position=(souris[0],souris[1]+15))
            
First screen act as a menu with an imagemap, and second screen shows an image and texts relevant to the choices.

When this "cover" is supposed to show, I get this error message

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
Exception: Unknown keyword arguments: souris, legende

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

Full traceback:
  File "renpy/common/_layout/screen_main_menu.rpym", line 29, in script
    $ ui.interact()
  File "/home/psct/Programmes/renpy/renpy/ast.py", line 785, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "/home/psct/Programmes/renpy/renpy/python.py", line 1382, in py_exec_bytecode
    exec bytecode in globals, locals
  File "renpy/common/_layout/screen_main_menu.rpym", line 29, in <module>
    $ ui.interact()
  File "/home/psct/Programmes/renpy/renpy/ui.py", line 247, in interact
    rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
  File "/home/psct/Programmes/renpy/renpy/display/core.py", line 2149, in interact
    repeat, rv = self.interact_core(preloads=preloads, **kwargs)
  File "/home/psct/Programmes/renpy/renpy/display/core.py", line 2397, in interact_core
    root_widget.visit_all(lambda i : i.per_interact())
  File "/home/psct/Programmes/renpy/renpy/display/core.py", line 338, in visit_all
    d.visit_all(callback)
  File "/home/psct/Programmes/renpy/renpy/display/core.py", line 338, in visit_all
    d.visit_all(callback)
  File "/home/psct/Programmes/renpy/renpy/display/core.py", line 338, in visit_all
    d.visit_all(callback)
  File "/home/psct/Programmes/renpy/renpy/display/screen.py", line 382, in visit_all
    callback(self)
  File "/home/psct/Programmes/renpy/renpy/display/core.py", line 2397, in <lambda>
    root_widget.visit_all(lambda i : i.per_interact())
  File "/home/psct/Programmes/renpy/renpy/display/screen.py", line 394, in per_interact
    self.update()
  File "/home/psct/Programmes/renpy/renpy/display/screen.py", line 555, in update
    self.screen.function(**self.scope)
  File "/home/psct/Programmes/renpy/renpy/ast.py", line 148, in apply_arguments
    return parameters.apply(args, kwargs, ignore_errors)
  File "/home/psct/Programmes/renpy/renpy/ast.py", line 136, in apply
    raise Exception("Unknown keyword arguments: %s" % ( ", ".join(values.keys())))
Exception: Unknown keyword arguments: souris, legende

Linux-3.16-3-686-pae-i686-with-debian-8.0
Ren'Py 6.18.3.761
Exercices-compil 0.1alpha
What I understand is that I am supposed to somehow define or initialise some variables I use - "souris" "legende" (what did not seem necessary before). Theses variables are beeing used as argumetns passed from one screen to another.

How do I do that ?
Last edited by korova on Sun Dec 14, 2014 3:00 pm, edited 1 time in total.

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Errors in screens after upgrading to version 6.18

#2 Post by xela »

Offhand, did you try:

Code: Select all

screen dossier_hover:
without brackets...?

Otherwise they should be assigned to store or define them as arguments to the main screen, they should work in both cases. It is likely that you'd have to add transition to your Show action if you add them as args/kwargs.
Like what we're doing? Support us at:
Image

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Errors in screens after upgrading to version 6.18

#3 Post by xavimat »

Or you can use the new screen code:

Code: Select all

screen dossier_hover(legende=legende, souris=souris):
Those are the two variables that renpy is complaining about. (not tested).
Last edited by xavimat on Sun Dec 14, 2014 6:08 pm, edited 1 time in total.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Errors in screens after upgrading to version 6.18

#4 Post by xela »

xavimat wrote:Or you can use the new screen code:

Code: Select all

screen dossier_hover(legende=legende, souris=souris):
That are the two variables that renpy is complaining about. (not tested).
I am not sure this will work, game would try to do a lookup of legende and souris in store on definition with this code which, unless they were defined before the screen, will fail (unless something is happening I am not aware of in new SL2).

I suggested:

Code: Select all

screen dossier_hover:

Code: Select all

screen dossier_hover(legende, souris):

Code: Select all

screen dossier_hover(legende=None, souris=()):
The latter two may cause errors when used with Show() action as it expects transition as the second argument which is easy to fix.
Like what we're doing? Support us at:
Image

User avatar
korova
Veteran
Posts: 217
Joined: Sat Jun 27, 2009 5:15 pm
Completed: Ivy, Chocolate, Time, Clair Obscur
Projects: Writing exercises, The House [Nano18]
Tumblr: korova08
itch: korova
Location: Normandie, France
Contact:

Re: Errors in screens after upgrading to version 6.18 [solve

#5 Post by korova »

xela wrote:Offhand, did you try:

Code: Select all

screen dossier_hover:
without brackets...?
Actually I added the brackets as a first try.... Original (with error) didn't have the brackets.
xavimat wrote:Or you can use the new screen code:

Code: Select all

screen dossier_hover(legende=legende, souris=souris):
That are the two variables that renpy is complaining about. (not tested).
Surprisingly, that did the trick.

I'm not sure I understand why, though.

I suppose with the new Ren'Py version, you need more presision in variables definition.
I'll have to reveiw variable definition and scope...

Thanks for your help anyway !

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Errors in screens after upgrading to version 6.18

#6 Post by xela »

Code: Select all

screen test(test=test):
    $ pass
is valid... I would expect this to throw error on project launch. Well, as long as it's working :)
Like what we're doing? Support us at:
Image

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Errors in screens after upgrading to 6.18 [solved]

#7 Post by xavimat »

The line:

Code: Select all

hovered Show("dossier_hover",legende="ivy",souris=(316,466))
passes the values to the parameters "legende" and "souris" that will be used in the dossier_hover screen.
The former screen language used the "default" statement, without brackets:

Code: Select all

screen dossier_hover:
    default legende = "something"
    default souris = (some_value, some_value)
   
    tag dossier
     
    # simple affichage, sans interaction
    use dossier_couv(souris=souris,r=True)
    use dossier_illu(souris=souris,r=True)
    # ...
(see doc in http://renpy.org/doc/html/screens.html#default )

As PyTom said, the new screen language improves performance, but needs the brackets. And the default variables are declared in there (that was the main change in the screens.rpy file of the template).

In your screen definition:

Code: Select all

screen dossier_hover():
Ren'Py didn't know what to do with the variables and values you provided in the Show action of "screen histories".

In the screen definition I've given

Code: Select all

screen dossier_hover(legende=legende, souris=souris):
there is also an error that I've checked now. You actually only need this (already suggested by xela):

Code: Select all

screen dossier_hover(legende, souris):
But it's better to supply default values, just in case the screen is called without them:

Code: Select all

screen dossier_hover(legende='', souris=(0,0)):
The code I've given before does throw an error if you call the screen without parameters.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Errors in screens after upgrading to 6.18 [solved]

#8 Post by xela »

xavimat wrote:...
I know what works for me... and not all of what you wrote is true.

For example you can use variables inside of the screen without providing them as arguments or positional arguments or a default arguments. As long as you provide them on call, it will work. The reason it didn't work for OP (I think) is that they are passed to other screens using "use" statement and that is where it fails.

Code: Select all

screen test:
    vbox:
        pos pos
should work as long as you provide pos as a positional argument when you call the screen.

Code: Select all

screen test():
    vbox:
        pos pos
will fail due to SL2...

The reason I thought that your original suggestion would fail is because I expected screen to be checked for some basic evaluation when it's being defined. Just like:

Code: Select all

def func(arg=arg):
    pass
should throw an error (it will try to find arg it store), I expected:

Code: Select all

screen test(test=test):
    $ pass
to throw an error, it does not. I think it did in previous versions but I am too lazy to check and don't care all that much anyway :)

The whole thing is pretty confusing... it is made worse by new SL2 rules like "constants". It's not hard to figure out but will take a good while to get used to + there is little intensive because most screens do work really fast anyway.
Like what we're doing? Support us at:
Image

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Errors in screens after upgrading to 6.18 [solved]

#9 Post by xavimat »

xela wrote:you can use variables inside of the screen without providing them as arguments or positional arguments or a default arguments. As long as you provide them on call, it will work.
Ok. My fault here was not using the words with their precise meaning. I meant that you must provide the values of that variables, one way or another (they could be global variables as well).
xela wrote: I expected screen to be checked for some basic evaluation when it's being defined
I think that that evaluation is not done because you can also use in a screen global variables defined after the "label start". For example, this code works:

Code: Select all

label start:
    $ my_text = "bla bla"
    show screen test1
    show screen test2
    pause
    return

screen test1:
    text my_text

screen test2():
    text my_text xalign 1.0
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: Errors in screens after upgrading to 6.18 [solved]

#10 Post by xela »

I figured... just pointed out that it's a bit confusing :)
Ren'Py Documentation wrote:When a screen is defined without a parameter list, any name used in that screen can be redefined when the screen is show. This requires Ren'Py to be more conservative when analyzing the screen, which can limit the optimization it performs.
so:

Code: Select all

label start:
    $ renpy.show_screen("test1", my_text="meow")
    pause
    $ renpy.show_screen("test2", my_text="meow")
    pause
    return

screen test1:
    text my_text

screen test2():
    text my_text xalign 1.0
One works perfectly fine, the other throws an error.

The thing is that in SL1 my_text provided to screen one test1 could be passed as an argument to other screens called using the "use" SL statement. In it's core it's a bug because behavior of old screens should remain the same when updating to 6.18.
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: juliaa__