Debugging Best Practices

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
Piccontroller
Regular
Posts: 47
Joined: Wed Dec 07, 2011 5:52 am
Contact:

Debugging Best Practices

#1 Post by Piccontroller » Thu Jan 12, 2012 11:09 am

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?

User avatar
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

#2 Post by redeyesblackpanda » Thu Jan 12, 2012 8:10 pm

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. :mrgreen:
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

#3 Post by Piccontroller » Fri Jan 13, 2012 11:22 am

ok. Try clarify my post. Full syntetic very very simple example. Real game logic is much more complex.

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
What way to find logical error in "someFunc"?

Code: Select all

$ b = B()
$ result = b.someFunc()
#invalid result
#how to see it? how to see fields of b? etc?
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.
Attachments
vsdebug.png
Last edited by Piccontroller on Fri Jan 13, 2012 11:38 am, edited 1 time in total.

User avatar
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

#4 Post by DragoonHP » Fri Jan 13, 2012 11:27 am

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...

Code: Select all

"[variableName]"

Piccontroller
Regular
Posts: 47
Joined: Wed Dec 07, 2011 5:52 am
Contact:

Re: Debugging Best Practices

#5 Post by Piccontroller » Fri Jan 13, 2012 11:43 am

Equals if I have function 20 lines of code then I have no way to find logical error. Only write lines to debug

Code: Select all

...
"[var]"
..
"[var1]"
..
"[varN]"
...
and after debug delete they? :shock:

User avatar
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

#6 Post by DragoonHP » Fri Jan 13, 2012 11:47 am

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

#7 Post by Piccontroller » Fri Jan 13, 2012 11:50 am

I'm only coder. And I must implement provided game logic. :cry:
If I use

Code: Select all

"[b]" #see example above
I get result like <store.B instance at 0x....> but not content of b :cry:

User avatar
SusanTheCat
Miko-Class Veteran
Posts: 952
Joined: Mon Dec 13, 2010 9:30 am
Location: New Brunswick, Canada
Contact:

Re: Debugging Best Practices

#8 Post by SusanTheCat » Fri Jan 13, 2012 12:55 pm

My quick and dirty is to use renpy.watch(variable)

Code: Select all

    renpy.watch("body_count")
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

Code: Select all

Exception: String 'events = []' ends with an open format operation
More here http://www.renpy.org/wiki/renpy/doc/ref ... oper_Tools

Susan
" 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

User avatar
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

#9 Post by SleepKirby » Fri Jan 13, 2012 6:55 pm

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.

User avatar
MoPark
Regular
Posts: 98
Joined: Sat Dec 31, 2011 7:05 pm
Projects: Kangaroo, Terminal Love
Location: DC
Contact:

Re: Debugging Best Practices

#10 Post by MoPark » Fri Jan 13, 2012 9:56 pm

Piccontroller wrote:I'm only coder. And I must implement provided game logic. :cry:
If I use

Code: Select all

"[b]" #see example above
I get result like <store.B instance at 0x....> but not content of b :cry:
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.

You initialized an instance of class B as follows:

Code: Select all

$ b = B()
This is correct. Here's an example I have with an implementation of my own:

Code: Select all

$ mainChar = mainCharacter()
"HP is initially set to [mainChar.currHP]."
Did that make sense? Notice how I called an element there, I think that may be your issue.

Piccontroller
Regular
Posts: 47
Joined: Wed Dec 07, 2011 5:52 am
Contact:

Re: Debugging Best Practices

#11 Post by Piccontroller » Sun Jan 15, 2012 6:38 am

Thanks to all for answers. I am very upset that there is no easy way to debug. :? I will use what we have. :(

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
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.
Attachments
variable_viewer.png
variable_viewer.png (7.28 KiB) Viewed 3067 times

GrimmisJP
Newbie
Posts: 2
Joined: Sun Jan 29, 2012 8:14 pm
Contact:

Re: Debugging Best Practices

#12 Post by GrimmisJP » Tue Jan 31, 2012 10:22 pm

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.

GrimmisJP
Newbie
Posts: 2
Joined: Sun Jan 29, 2012 8:14 pm
Contact:

Re: Debugging Best Practices

#13 Post by GrimmisJP » Thu Feb 02, 2012 10:46 pm

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.

User avatar
akakyouryuu
Regular
Posts: 153
Joined: Fri Nov 30, 2012 10:29 am
Contact:

Re: Debugging Best Practices

#14 Post by akakyouryuu » Tue Dec 01, 2020 12:47 pm

Enerccio developed debuger for Ren'Py
This allow user to add breakpoints to rpy files and display variables.

https://github.com/Enerccio/renpy-debugger

Post Reply

Who is online

Users browsing this forum: No registered users