How can I output the value of a variable used in a screen for loop, during an exception?

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
henvu50
Veteran
Posts: 337
Joined: Wed Aug 22, 2018 1:22 am
Contact:

How can I output the value of a variable used in a screen for loop, during an exception?

#1 Post by henvu50 »

My renpy project is throwing an error: An exception has occurred. There are two variables presented that might be the problem, but I have no way of seeing what the value of those variables are.

1) How can I output the value of these variables from the console, to the console, or to a text file, or anywhere it can be seen?
2) Is it possible to use Renpy.say within a screen? Then I can output the value of the variable before it throws an error?
3) Is there a tutorial on how to debug like a pro in Ren'py? For example, how to debug from the console? Something that every Ren'py developer cannot live without?

User avatar
HEXdidnt
Regular
Posts: 63
Joined: Tue Aug 11, 2020 1:25 pm
Projects: A Night at the Office, Embracing Christmas, The Masquerade Benefit
Deviantart: HEXdidnt
Location: Harrow, London, UK
Contact:

Re: How can I output the value of a variable used in a screen for loop, during an exception?

#2 Post by HEXdidnt »

Not sure how helpful this would be in the long run, but you could certainly output a variable into a portion of the dialogue that happens just before the exception hits. Just enclose the variable name in square brackets within the flow of the text, eg.

Code: Select all

"The exception is about to hit! Variable 1 is currently [variable1name], variable 2 is currently [variable2name]. Click to see the error..."
As ever, dropping litter in the zen garden of your mind...

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: How can I output the value of a variable used in a screen for loop, during an exception?

#3 Post by Remix »

3) Is there a tutorial on how to debug like a pro in Ren'py? For example, how to debug from the console? Something that every Ren'py developer cannot live without?

Well, there are sort of two consoles, the Ren'Py one (Shift + 0) and a Python one that you can launch alongside your game (by doing Launcher > Preferences (Launcher Options) and tick the Console Output checkbox.
If that is ticked all Python print output ($ print("debug message") etc) will be shown in that console.
Note: This console is not for typing stuff in, it is just for outputting messages.
Frameworks & Scriptlets:

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot], Semrush [Bot]