Ren'Py [Solved] Call screen variables issue

Deleted member 416612

The 'landlord'
Donor
Game Developer
Feb 2, 2018
923
3,925
Hi mates,

I am having an issue with the current development when I am trying to call a screen, depending on a variable
I have this:

Label.rpy
Code:
label bath_opened_day_01:

if morrigan_bath_var_01 == False:
        jump morrigan_bath_scene_01
    elif morrigan_bath_var_01 == True:
        jump bath_opened_day_02

label bath_opened_day_02:
    call screen bath_opened_day_sc
Script.rpy
Code:
label start;
"text"
$ morrigan_bath_var_01 == True
"text"
$ morrigan_bath_var_01 == False
jump credits_ending_part

label credits_ending_part:
"text"
jump label_hall
In the label hall, I can navigate, in the game from that point to the bath screen.
I wanted to create a condition where if the player hasn't passed the morrigan_bath_scene_01, to be redirected to that scene. Else if he did complete that scene to be directed to the bath screen where he can explore freely.
The problem is that when I start from the point where the player hasn't experience the morrigan_bath_scene_01 (where the condition is False) I am getting an error that is saying:


Code:
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 5550, in script
    $ morrigan_bath_var_01 == False
  File "game/script.rpy", line 5550, in <module>
    $ morrigan_bath_var_01 == False
NameError: name 'morrigan_bath_var_01' is not defined

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

Full traceback:
  File "game/script.rpy", line 5550, in script
    $ morrigan_bath_var_01 == False
  File "D:\renpy-7.1.0-sdk\renpy\ast.py", line 912, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\renpy-7.1.0-sdk\renpy\python.py", line 1959, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 5550, in <module>
    $ morrigan_bath_var_01 == False
NameError: name 'morrigan_bath_var_01' is not defined

Windows-8-6.2.9200
Ren'Py 7.3.0.271
Vis 0.5
Mon Jun 24 12:28:00 2019
I've loaded the game before the variable to be triggered but I get the same message.

Is there any solution to this?

Thank you in advance
 

jon95

Member
Game Developer
Sep 29, 2018
176
393
Hi mates,

I am having an issue with the current development when I am trying to call a screen, depending on a variable
I have this:

Label.rpy
Code:
label bath_opened_day_01:

if morrigan_bath_var_01 == False:
        jump morrigan_bath_scene_01
    elif morrigan_bath_var_01 == True:
        jump bath_opened_day_02

label bath_opened_day_02:
    call screen bath_opened_day_sc
Script.rpy
Code:
label start;
"text"
$ morrigan_bath_var_01 == True
"text"
$ morrigan_bath_var_01 == False
jump credits_ending_part

label credits_ending_part:
"text"
jump label_hall
In the label hall, I can navigate, in the game from that point to the bath screen.
I wanted to create a condition where if the player hasn't passed the morrigan_bath_scene_01, to be redirected to that scene. Else if he did complete that scene to be directed to the bath screen where he can explore freely.
The problem is that when I start from the point where the player hasn't experience the morrigan_bath_scene_01 (where the condition is False) I am getting an error that is saying:


Code:
I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/script.rpy", line 5550, in script
    $ morrigan_bath_var_01 == False
  File "game/script.rpy", line 5550, in <module>
    $ morrigan_bath_var_01 == False
NameError: name 'morrigan_bath_var_01' is not defined

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

Full traceback:
  File "game/script.rpy", line 5550, in script
    $ morrigan_bath_var_01 == False
  File "D:\renpy-7.1.0-sdk\renpy\ast.py", line 912, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\renpy-7.1.0-sdk\renpy\python.py", line 1959, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/script.rpy", line 5550, in <module>
    $ morrigan_bath_var_01 == False
NameError: name 'morrigan_bath_var_01' is not defined

Windows-8-6.2.9200
Ren'Py 7.3.0.271
Vis 0.5
Mon Jun 24 12:28:00 2019
I've loaded the game before the variable to be triggered but I get the same message.

Is there any solution to this?

Thank you in advance
Hey man, according to the error report you should first define your variable before starting the game
Code:
default morrigan_bath_var_01 = False
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,229
Code:
    $ morrigan_bath_var_01 == False
NameError: name 'morrigan_bath_var_01' is not defined
You doubled the "=", so you're not assigning a value, but testing it. Just remove one of the "=" and it will works fine.

It's not an error, it's the season. Summer started, the heat rise and, paradoxically, the brain start to freeze more often.


Hey man, according to the error report you should first define your variable before starting the game
Which would just move the error. Ren'py will now works fine, but it's game would still be broke.
 

jon95

Member
Game Developer
Sep 29, 2018
176
393
You doubled the "=", so you're not assigning a value, but testing it. Just remove one of the "=" and it will works fine.

It's not an error, it's the season. Summer started, the heat rise and, paradoxically, the brain start to freeze more often.




Which would just move the error. Ren'py will now works fine, but it's game would still be broke.
Sorry, I didn't see the == in
$ morrigan_bath_var_01 == False
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,971
16,229
Sorry, I didn't see the == in
You don't need to be sorry, I didn't quoted you as a criticism, but more as an advice.
Like I said, it's now summer (well, at least in half the world), we need to be more careful and double our attention when we code. So, never stop at the obvious (especially with Ren'py that say where the error happen, but not necessarily where the error effectively is). Take note of your observation, test it, but stay vigilant and test, not just if it remove the error, but also if what's around it still works correctly.