Per K Grok wrote: ↑Mon Nov 04, 2019 5:50 pm
Karrion wrote: ↑Mon Nov 04, 2019 4:10 pm
----
Is there a way to interact with variables from one script to another?
All scripts in the game talk to each other. To split the code up in different scripts is mostly for having stuff more easily organized for us humans. For the computer it is all the same.
Yes, I've seen that you don't need to import the other script to access its variables, but when I refer to it normaly by name, like this
Code: Select all
imagebutton idle "images/menu.png" action SetVariable(imageFlag, "images/caparoja.png")
I get an error saying that imageFlag is not defined.
The traceback shows the error is thrown after the last line on script.rpy, so it is after being defined in that script:
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 39, in script
"Bueno, pero podría relajarse un poco fuera de las aulas. Ojalá aprendiera un poco de vuestro tutor, normal que tenga tanto éxito entre las estudiantes de la academia."
File "renpy/common/000window.rpy", line 98, in _window_auto_callback
_window_show()
File "renpy/common/000window.rpy", line 60, in _window_show
renpy.with_statement(trans)
File "game/screens.rpy", line 244, in execute
screen quick_menu():
File "game/screens.rpy", line 244, in execute
screen quick_menu():
File "game/screens.rpy", line 249, in execute
if quick_menu:
File "game/screens.rpy", line 251, in execute
hbox:
File "game/screens.rpy", line 257, in execute
imagebutton idle "images/menu.png" action SetVariable(imageFlag, "images/caparoja.png")
File "game/screens.rpy", line 257, in keywords
imagebutton idle "images/menu.png" action SetVariable(imageFlag, "images/caparoja.png")
NameError: name 'imageFlag' is not defined
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 39, in script
"Bueno, pero podría relajarse un poco fuera de las aulas. Ojalá aprendiera un poco de vuestro tutor, normal que tenga tanto éxito entre las estudiantes de la academia."
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\ast.py", line 653, in execute
statement_name("say")
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\ast.py", line 45, in statement_name
i(name)
File "renpy/common/000window.rpy", line 98, in _window_auto_callback
_window_show()
File "renpy/common/000window.rpy", line 60, in _window_show
renpy.with_statement(trans)
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\exports.py", line 1560, in with_statement
return renpy.game.interface.do_with(trans, paired, clear=clear)
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\core.py", line 2237, in do_with
clear=clear)
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\core.py", line 2687, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\core.py", line 3071, in interact_core
root_widget.visit_all(lambda i : i.per_interact())
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\core.py", line 531, in visit_all
d.visit_all(callback, seen)
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\screen.py", line 424, in visit_all
callback(self)
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\core.py", line 3071, in <lambda>
root_widget.visit_all(lambda i : i.per_interact())
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\screen.py", line 434, in per_interact
self.update()
File "C:\Users\karri\Downloads\renpy-7.1.0-sdk\renpy\display\screen.py", line 619, in update
self.screen.function(**self.scope)
File "game/screens.rpy", line 244, in execute
screen quick_menu():
File "game/screens.rpy", line 244, in execute
screen quick_menu():
File "game/screens.rpy", line 249, in execute
if quick_menu:
File "game/screens.rpy", line 251, in execute
hbox:
File "game/screens.rpy", line 257, in execute
imagebutton idle "images/menu.png" action SetVariable(imageFlag, "images/caparoja.png")
File "game/screens.rpy", line 257, in keywords
imagebutton idle "images/menu.png" action SetVariable(imageFlag, "images/caparoja.png")
File "<screen language>", line 257, in <module>
NameError: name 'imageFlag' is not defined
Windows-8-6.2.9200
Ren'Py 7.1.4.1266
Tests 1.0
Tue Nov 05 10:55:52 2019
The flag itself is defined as
Code: Select all
image imageFlag = "images/capa.png"
Maybe I'm missing some kind of special syntax to refer to that flag or I've defined the flag incorrectly? Maybe the default is missing? Maybe it is indeed a race condition?