Lemma Soft Forums

Supporting creators of visual novels and story-based games since 2003.


Visit our new games list, blog aggregator, IRC, and wiki.
Activation problem? Email [email protected]
It is currently Sat May 25, 2013 12:21 pm

All times are UTC - 5 hours [ DST ]


Forum rules


Ask questions about one topic per thread, and use a descriptive subject. "NotImplemented error in script.rpy" is a good subject, "Tom's problems" is not. Remember to include all of traceback.txt or error.txt when reporting a problem, as well as the relevant lines of script. Use the [code] tag to format scripts.



Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: Debugging Best Practices
PostPosted: Thu Jan 12, 2012 11:09 am 
Regular

Joined: Wed Dec 07, 2011 5:52 am
Posts: 44
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?


Top
 Profile Send private message  
 
PostPosted: Thu Jan 12, 2012 8:10 pm 
Miko-Class Veteran
User avatar

Joined: Thu Dec 22, 2011 4:26 am
Posts: 993
Location: United States
Projects: Eternal Memories, plot bunnies that won't die.
Organization: HellPanda Studios
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. ^_^'

_________________
Know some awesome people? Want to thank them? Do it here!
For up to date info on my VN projects: HellPanda Studios Blog.
Tsundere VN
My new policy: All my games will have a redhead. Period.

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.


Top
 Profile Send private message  
 
PostPosted: Fri Jan 13, 2012 11:22 am 
Regular

Joined: Wed Dec 07, 2011 5:52 am
Posts: 44
ok. Try clarify my post. Full syntetic very very simple example. Real game logic is much more complex.

Code:
    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:
$ 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
vsdebug.png [ 35.13 KiB | Viewed 495 times ]


Last edited by Piccontroller on Fri Jan 13, 2012 11:38 am, edited 1 time in total.
Top
 Profile Send private message  
 
PostPosted: Fri Jan 13, 2012 11:27 am 
Miko-Class Veteran

Joined: Tue Jun 22, 2010 12:54 am
Posts: 572
Location: Zion Island, Solario
Completed: Christmas
Projects: [R-R]Christmas, (Un-named VN), I'M NOT A KILLER
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:
"[variableName]"

_________________
"You can't wait for inspiration. You have to go after it with a club." --Jack London
“One must be careful with words. Words turn probabilities into facts and by sheer force of definition translate tendencies into habits.” ― Fay Weldon
"A writer who waits for ideal conditions under which to work will die without putting a word on paper." -- E.B. WHITE
"I love writing but hate starting. The page is awfully white and it says, "You may have fooled some of the people some of the time but those days are over, giftless. I'm not your agent and I'm not your mommy. I'm a white piece of paper, you wanna dance with me?" And I really, really don't." -- Aaron Sorkin

My Completed Games: Christmas


Top
 Profile Send private message  
 
PostPosted: Fri Jan 13, 2012 11:43 am 
Regular

Joined: Wed Dec 07, 2011 5:52 am
Posts: 44
Equals if I have function 20 lines of code then I have no way to find logical error. Only write lines to debug
Code:
...
"[var]"
..
"[var1]"
..
"[varN]"
...


and after debug delete they? :shock:


Top
 Profile Send private message  
 
PostPosted: Fri Jan 13, 2012 11:47 am 
Miko-Class Veteran

Joined: Tue Jun 22, 2010 12:54 am
Posts: 572
Location: Zion Island, Solario
Completed: Christmas
Projects: [R-R]Christmas, (Un-named VN), I'M NOT A KILLER
Most probably... I may be wrong though... but then again why would you need to write such a complex function in Ren'Py anyway?

_________________
"You can't wait for inspiration. You have to go after it with a club." --Jack London
“One must be careful with words. Words turn probabilities into facts and by sheer force of definition translate tendencies into habits.” ― Fay Weldon
"A writer who waits for ideal conditions under which to work will die without putting a word on paper." -- E.B. WHITE
"I love writing but hate starting. The page is awfully white and it says, "You may have fooled some of the people some of the time but those days are over, giftless. I'm not your agent and I'm not your mommy. I'm a white piece of paper, you wanna dance with me?" And I really, really don't." -- Aaron Sorkin

My Completed Games: Christmas


Top
 Profile Send private message  
 
PostPosted: Fri Jan 13, 2012 11:50 am 
Regular

Joined: Wed Dec 07, 2011 5:52 am
Posts: 44
I'm only coder. And I must implement provided game logic. :cry:
If I use
Code:
"[b]" #see example above


I get result like <store.B instance at 0x....> but not content of b :cry:


Top
 Profile Send private message  
 
PostPosted: Fri Jan 13, 2012 12:55 pm 
Miko-Class Veteran
User avatar

Joined: Mon Dec 13, 2010 9:30 am
Posts: 842
Location: New Brunswick, Canada
Projects: Camp Renard
My quick and dirty is to use renpy.watch(variable)
Code:
    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:
Exception: String 'events = []' ends with an open format operation


More here http://www.renpy.org/wiki/renpy/doc/ref ... oper_Tools

Susan

_________________
In order to understand recursion, one must first understand recursion. (Anonymous)


Top
 Profile Send private message  
 
PostPosted: Fri Jan 13, 2012 6:55 pm 
Veteran
User avatar

Joined: Mon Aug 09, 2010 10:02 pm
Posts: 237
Location: California, USA
Projects: Eastern Starlight Romance, Touhou Mecha
Organization: Dai-Sukima Dan
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.

_________________
Dai-Sukima Dan blog


Top
 Profile Send private message  
 
PostPosted: Fri Jan 13, 2012 9:56 pm 
Regular
User avatar

Joined: Sat Dec 31, 2011 7:05 pm
Posts: 98
Location: DC
Projects: Kangaroo, Terminal Love
Piccontroller wrote:
I'm only coder. And I must implement provided game logic. :cry:
If I use
Code:
"[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:
$ b = B()


This is correct. Here's an example I have with an implementation of my own:
Code:
$ 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.


Top
 Profile Send private message  
 
PostPosted: Sun Jan 15, 2012 6:38 am 
Regular

Joined: Wed Dec 07, 2011 5:52 am
Posts: 44
Thanks to all for answers. I am very upset that there is no easy way to debug. :? I will use what we have. :(
Code:
$ 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 433 times ]
Top
 Profile Send private message  
 
PostPosted: Tue Jan 31, 2012 10:22 pm 
Newbie

Joined: Sun Jan 29, 2012 8:14 pm
Posts: 2
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.


Top
 Profile Send private message  
 
PostPosted: Thu Feb 02, 2012 10:46 pm 
Newbie

Joined: Sun Jan 29, 2012 8:14 pm
Posts: 2
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.


Top
 Profile Send private message  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: Anima


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Protected by Anti-Spam ACP
Powered by phpBB® Forum Software © phpBB Group