Tool Ren'Py Current label and call depth tracker - For walkthrough authors, game authors and modders - Version 1.0

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,969
16,222
Hi,

Like you perhaps know, debugging a game relying on called label can be really hard.
How many label have I called to get here ? How many time still have I to return ? And if you add jump in this, you can easily end totally in your code. So, I wrote a small tool to help you (and in fact also me) with this.
It's really a small tool, 117 lines only, and it really do the minimal. But it do it well.

  1. It will constantly display the name of the current label, as well as the call stack depth on the top of the screen, helping you know where exactly you are, and how many labels you called to get there.
  2. If the label have effectively be called, you'll know in what file and at what line is the line that called it.
  3. If you hover the "depth" word (see screenshot) it will display all the labels at each stack level. This will help you have a more precise view, telling you not only where you are, but also how you got there.
  4. It will log in a file named "logFile.txt" every time you enter a label, and every time you returned from a label. What can help you to have a view of your code behavior over a longer run.

Some technical details are needed:

Firstly, Ren'Py have two modes when entering a label, one of them being said as "abnormal".
A label entering will be seen as abnormal when it's an implicit jump, or when it return from a call someLabel from someFromLabel. In this last case, Ren'Py will act as if you entered a new label, but the tracker will continue to display the name defined in the label whatever line ; therefore the name of the label as you know it.
Note that from the tool, abnormal labels will be displayed in red, while normal labels will be displayed on green. This can help you quickly find that you forgot something.
You don't have permission to view the spoiler content. Log in or register now.

Secondly, there's no simple way to know when you returned from a label.
Therefore, for the log file, I cheated. Every 1/20th of second I check if the game came back to a previous stack level. If it happen, this mean that the game returned, so the tool will log it.
Be warned that this mean that some return statement can be not logged, because happening too fast. But the log include the current depth, so you'll not be totally lost.

Thirdly, it's a quick tool.
It's designed to help you have a better view of the code flow, but it don't replace a careful approach of your code.
Plus, the code is designed to works, not to looks good, nor is it really optimized. It's a helper more than anything else.


Download: tool


You don't have permission to view the spoiler content. Log in or register now.


labelTracker.jpg
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,969
16,222
Ok, I've been warned that there's an issue with the tracker.

I haven't anticipated the possibility that the game, or a mod/tool for it, will also use the config.label_callback value. What is stupid since all my mods and tools do it...

Obviously, when this happen, the tracker don't like it at all. I'll works on this and search a way to fix this problem.
 
  • Like
Reactions: Meushi

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Donor
Respected User
Jun 10, 2017
10,969
16,222
I updated the tool.

Among other fixes, it should now not conflict anymore with games/mods using the config.label_callback.
I also fixed an issue with the savability of the tracked labels, and changed a bit the information you get when the label is "abnormal" ; you now also know the "main label".

I'm still not totally satisfied with the result, but it's already much better that it was before.
 
  • Like
Reactions: Twistty

IridescentTaste

Newbie
Game Developer
Oct 29, 2022
69
287
Thanks, this is great. Showing file/line is actually very useful feature for me - I've modified it to always show it for the current label so I don't have to hover all the time. If I find the time I'll try to figure out how to add some kind of timestamps to the log so I know how long I stayed in a label.