Debugging Best Practices
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.
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.
-
Piccontroller
- Regular
- Posts: 47
- Joined: Wed Dec 07, 2011 5:52 am
- Contact:
Debugging Best Practices
I may not found way to debug Ren'py. I may not found such information. It seems it is true problem.
I have some questions (may be foolish for veterans):
1) Is existed way to set breakpoints (like VS or Excel macros etc)?
2) If I have complex class what way to see its members?
3) If I have function what way to debug logic?
4) How I can see variable?
5) etc.....
It seems I try "To reinvent a wheel".
Veterans! What way are you use to debug Ren'py game logic?
I have some questions (may be foolish for veterans):
1) Is existed way to set breakpoints (like VS or Excel macros etc)?
2) If I have complex class what way to see its members?
3) If I have function what way to debug logic?
4) How I can see variable?
5) etc.....
It seems I try "To reinvent a wheel".
Veterans! What way are you use to debug Ren'py game logic?
- redeyesblackpanda
- Eileen-Class Veteran
- Posts: 1006
- Joined: Thu Dec 22, 2011 4:26 am
- Projects: Eternal Memories, plot bunnies that won't die.
- Organization: HellPanda Studios
- Location: United States
- Contact:
Re: Debugging Best Practices
Don't quite understand what your post is saying so I'm guessing here. To check bugs in a game you are making with Ren'Py, you can use Lint. You will still have to test the game yourself to be certain that everything is fine, but it does catch a lot of mistakes. Hopefully this answered your question. ^_^'
(All projects currently on a hiatus of sorts. I blame life.)
Tsundere VN
Not really checking the forums any more due to time constraints, so if you want to contact me, PM. I'll get a notification and log in.
Also, I've been hit and run posting, which means I don't see many replies. If you want to respond to something I've said, also feel free to PM me.
NOTE: if you've got questions about vnovel or things like that, it's Leon that you should be contacting. Leon's been pretty much handling everything, but due to various reasons, I've had to withdraw entirely.
Tsundere VN
Not really checking the forums any more due to time constraints, so if you want to contact me, PM. I'll get a notification and log in.
Also, I've been hit and run posting, which means I don't see many replies. If you want to respond to something I've said, also feel free to PM me.
NOTE: if you've got questions about vnovel or things like that, it's Leon that you should be contacting. Leon's been pretty much handling everything, but due to various reasons, I've had to withdraw entirely.
-
Piccontroller
- Regular
- Posts: 47
- Joined: Wed Dec 07, 2011 5:52 am
- Contact:
Re: Debugging Best Practices
ok. Try clarify my post. Full syntetic very very simple example. Real game logic is much more complex.
What way to find logical error in "someFunc"?
P.S. For example if I use vs2002-2010 I set breakpoint and use watch windows to see what I need to find error. I can see any field of object etc. I've attached VS sample debug view for clarify.
Code: Select all
class A:
def __init_(self, x, y):
self.x = x
self.y = y
class B:
def __init__(self):
self.list = []
self.list.append(A(1, 2))
self.list.append(A(3, 4))
def someFunc():
return self.list[0].x + self.list[1].y # error logic. lint ok need debug to find error. correct logical code self.list[0].x + self.list[1].x
Code: Select all
$ b = B()
$ result = b.someFunc()
#invalid result
#how to see it? how to see fields of b? etc?
Last edited by Piccontroller on Fri Jan 13, 2012 11:38 am, edited 1 time in total.
- DragoonHP
- Miko-Class Veteran
- Posts: 758
- Joined: Tue Jun 22, 2010 12:54 am
- Completed: Christmas
- IRC Nick: DragoonHP
- Location: Zion Island, Solario
- Contact:
Re: Debugging Best Practices
1) I don't think there's a way to put breakpoints in Ren'Py.. I could be wrong... but as far as I know, there is none...
2) I don't understand...
3) Not sure, but you will have to do it the manual way...
4) Umm... like this...
2) I don't understand...
3) Not sure, but you will have to do it the manual way...
4) Umm... like this...
Code: Select all
"[variableName]"
-
Piccontroller
- Regular
- Posts: 47
- Joined: Wed Dec 07, 2011 5:52 am
- Contact:
Re: Debugging Best Practices
Equals if I have function 20 lines of code then I have no way to find logical error. Only write lines to debug
and after debug delete they? 
Code: Select all
...
"[var]"
..
"[var1]"
..
"[varN]"
...
- DragoonHP
- Miko-Class Veteran
- Posts: 758
- Joined: Tue Jun 22, 2010 12:54 am
- Completed: Christmas
- IRC Nick: DragoonHP
- Location: Zion Island, Solario
- Contact:
Re: Debugging Best Practices
Most probably... I may be wrong though... but then again why would you need to write such a complex function in Ren'Py anyway?
-
Piccontroller
- Regular
- Posts: 47
- Joined: Wed Dec 07, 2011 5:52 am
- Contact:
Re: Debugging Best Practices
I'm only coder. And I must implement provided game logic. 
If I use
I get result like <store.B instance at 0x....> but not content of b 
If I use
Code: Select all
"[b]" #see example above
- SusanTheCat
- Miko-Class Veteran
- Posts: 952
- Joined: Mon Dec 13, 2010 9:30 am
- Location: New Brunswick, Canada
- Contact:
Re: Debugging Best Practices
My quick and dirty is to use renpy.watch(variable)
More details here: http://www.renpy.org/wiki/renpy/doc/ref ... enpy.watch
Another fun thing to do is hit [SHIFT]+[D] to bring up the developer menu for a bunch of useful utilities. I just tried it and the variable viewer gave me an error which most likely has more to do with my game than Ren'Py
More here http://www.renpy.org/wiki/renpy/doc/ref ... oper_Tools
Susan
Code: Select all
renpy.watch("body_count")
Another fun thing to do is hit [SHIFT]+[D] to bring up the developer menu for a bunch of useful utilities. I just tried it and the variable viewer gave me an error which most likely has more to do with my game than Ren'Py
Code: Select all
Exception: String 'events = []' ends with an open format operationSusan
" It's not at all important to get it right the first time. It's vitally important to get it right the last time. "
— Andrew Hunt and David Thomas
— Andrew Hunt and David Thomas
- SleepKirby
- Veteran
- Posts: 255
- Joined: Mon Aug 09, 2010 10:02 pm
- Projects: Eastern Starlight Romance, Touhou Mecha
- Organization: Dai-Sukima Dan
- Location: California, USA
- Contact:
Re: Debugging Best Practices
Ren'Py does not generally have support for breakpoint/step-by-step debugging. Though, a lot of Ren'Py is just pure Python, so you could potentially try running a Python breakpoint debugger on some Python code that's part of your game - but I haven't personally tried this.
I think Susan has the best tips for debugging Ren'Py. Note, though, that renpy.watch is not as smart as an IDE debugger; it'll literally just evaluate the expression that you give it. So if you tell renpy.watch to evaluate b, and b is an object, it probably won't give you all the fields in the object b. You'll have to say renpy.watch("[b.var1, b.var2, b.var3]") or something like that.
A few other things that may help you find bugs:
config.debug_image_cache
config.debug_sound
config.debug_text_overflow
And more advanced things you could try:
config.label_callback - This should be a function that is called whenever a label is called. In this label callback function, use an if statement checking if the label name is something specific. If so, make something happen (e.g. make some special text show up onscreen). This way you could figure out whether a certain label is being called or not.
config.label_overrides - Another thing you can use to check whether a certain label is being called or not.
I think Susan has the best tips for debugging Ren'Py. Note, though, that renpy.watch is not as smart as an IDE debugger; it'll literally just evaluate the expression that you give it. So if you tell renpy.watch to evaluate b, and b is an object, it probably won't give you all the fields in the object b. You'll have to say renpy.watch("[b.var1, b.var2, b.var3]") or something like that.
A few other things that may help you find bugs:
config.debug_image_cache
config.debug_sound
config.debug_text_overflow
And more advanced things you could try:
config.label_callback - This should be a function that is called whenever a label is called. In this label callback function, use an if statement checking if the label name is something specific. If so, make something happen (e.g. make some special text show up onscreen). This way you could figure out whether a certain label is being called or not.
config.label_overrides - Another thing you can use to check whether a certain label is being called or not.
- MoPark
- Regular
- Posts: 98
- Joined: Sat Dec 31, 2011 7:05 pm
- Projects: Kangaroo, Terminal Love
- Location: DC
- Contact:
Re: Debugging Best Practices
In that line, you're asking for the class B, not for an element within B, so you're being returned an instance stored at a particular memory address.Piccontroller wrote:I'm only coder. And I must implement provided game logic.
If I useI get result like <store.B instance at 0x....> but not content of bCode: Select all
"[b]" #see example above
You initialized an instance of class B as follows:
Code: Select all
$ b = B()Code: Select all
$ mainChar = mainCharacter()
"HP is initially set to [mainChar.currHP]."-
Piccontroller
- Regular
- Posts: 47
- Joined: Wed Dec 07, 2011 5:52 am
- Contact:
Re: Debugging Best Practices
Thanks to all for answers. I am very upset that there is no easy way to debug.
I will use what we have.
method 4
[shift + d]
All methods give me equals results. But metod 3 doesn't work =( I have exeption. Method 4 give result attached file.
Code: Select all
$ b = B()
$ b1 = b.someFunc()
#metod 1
"[b]"
"[b1]"
#metod 2
$ renpy.say("debug", str(b))
$ renpy.say("debug", str(b1))
#metod 3?
#$ renpy.watch(str(b)) #error during call
#$ renpy.watch(str(b1)) #error during call
[shift + d]
All methods give me equals results. But metod 3 doesn't work =( I have exeption. Method 4 give result attached file.
- Attachments
-
- variable_viewer.png (7.28 KiB) Viewed 3067 times
Re: Debugging Best Practices
I just started looking at RenPy a couple days ago. My initial thought is to start debugging the python code using an IDE such as Eclipse with PyDev.
The first thing I tried to do after running renpy.exe was to attempt running "python renpy.py" thinking that the exe is just a wrapper. I'm new to programming in Python, but the code is readable enough to notice that the dependencies are missing when running it this way. It crashed right away in the bootstrapper code looking for pygame. So, I tried downloading the dependency package from the Renpy website.
There's a lot in the download... Much that can go wrong when attempting to install each of those items and you're not sure what you're doing. For instance when extracting pygame 1.8, I don't know the correct way to install it. The pygame package from the official website has an installer. It's also kind of a pain to find hunt down the websites for each item to find installation instructions. (Half the time newer versions have been released and old ones buried deep down in an archive directory)
Can someone tell me if there is a document that describes how to setup renpy and its dependencies on a Windows machine for development? Sorry if there's one at some obvious link (I couldn't find one), or if I'm asking a silly question. Again, my knowledge of Python and this app is pretty limited.
The first thing I tried to do after running renpy.exe was to attempt running "python renpy.py" thinking that the exe is just a wrapper. I'm new to programming in Python, but the code is readable enough to notice that the dependencies are missing when running it this way. It crashed right away in the bootstrapper code looking for pygame. So, I tried downloading the dependency package from the Renpy website.
There's a lot in the download... Much that can go wrong when attempting to install each of those items and you're not sure what you're doing. For instance when extracting pygame 1.8, I don't know the correct way to install it. The pygame package from the official website has an installer. It's also kind of a pain to find hunt down the websites for each item to find installation instructions. (Half the time newer versions have been released and old ones buried deep down in an archive directory)
Can someone tell me if there is a document that describes how to setup renpy and its dependencies on a Windows machine for development? Sorry if there's one at some obvious link (I couldn't find one), or if I'm asking a silly question. Again, my knowledge of Python and this app is pretty limited.
Re: Debugging Best Practices
Well, it wasn't too hard create a remote break point command that connects to a debug server on eclipse. So, I can do something like:
label start:
BreakPoint
e "You've created a new Ren'Py game."
BreakPoint
e "Once you add a story, pictures, and music, you can release it to the world!"
For me that's more interest in learning Python, the interpreter, and the underlying layers with the intent of creating my own commands, this is useful. I can start stepping through the Python code at the breakpoint, and then play to another breakpoint in Eclipse in my customized code.
Obviously, this debugs Python code not Renpy scripts directly. So, I'm not sure how helpful it is to others.
label start:
BreakPoint
e "You've created a new Ren'Py game."
BreakPoint
e "Once you add a story, pictures, and music, you can release it to the world!"
For me that's more interest in learning Python, the interpreter, and the underlying layers with the intent of creating my own commands, this is useful. I can start stepping through the Python code at the breakpoint, and then play to another breakpoint in Eclipse in my customized code.
Obviously, this debugs Python code not Renpy scripts directly. So, I'm not sure how helpful it is to others.
- akakyouryuu
- Regular
- Posts: 153
- Joined: Fri Nov 30, 2012 10:29 am
- Contact:
Re: Debugging Best Practices
Enerccio developed debuger for Ren'Py
This allow user to add breakpoints to rpy files and display variables.
https://github.com/Enerccio/renpy-debugger
This allow user to add breakpoints to rpy files and display variables.
https://github.com/Enerccio/renpy-debugger
Who is online
Users browsing this forum: No registered users
