While playing your ren'py game, is there a way to output the currently executed code as you're clicking around?
Let's say you're currently left clicking to move the say text forward. Is there a way to have the code outputted to the console window?
Let's say you click an imagebutton in game, is there a way to have it output the code that's executed as a result of clicking that imagebutton?
Or maybe just show what line # from what file is being executed as you click about in the game?
[Solved] While playing your ren'py game, is there a way to output the currently executed code as you're clicking around?
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.
[Solved] While playing your ren'py game, is there a way to output the currently executed code as you're clicking around?
Last edited by henvu50 on Sat Jun 12, 2021 10:52 pm, edited 1 time in total.
Re: While playing your ren'py game, is there a way to output the currently executed code as you're clicking around?
There are callbacks on labels, so you can log what labels you've passed through:
There are more developer tools documented here: https://www.renpy.org/doc/html/developer_tools.html
If you open the Console, you can use renpy.get_return_stack() to see how you got to wherever you are.
None of this adds up to the full trace capability you seem to asking about, though. But since renpy is Python under the hood, you should be able to import a python tracing library (like https://pymotw.com/2/trace/) if you want one. I haven't tried it, though.
Code: Select all
init python:
def label_callback(name, abnormal):
renpy.log("label " + name)
define config.log = "debuglog.txt"
config.label_callback = label_callback
If you open the Console, you can use renpy.get_return_stack() to see how you got to wherever you are.
None of this adds up to the full trace capability you seem to asking about, though. But since renpy is Python under the hood, you should be able to import a python tracing library (like https://pymotw.com/2/trace/) if you want one. I haven't tried it, though.
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
Re: While playing your ren'py game, is there a way to output the currently executed code as you're clicking around?
Or just show current line
Code: Select all
frame:
background "#000A"
padding (16,8)
$ctx=renpy.game.context()
$node=renpy.game.script.lookup(ctx.current)
text "{}, line: {}".format(node.filename,node.linenumber) outlines [(2,"#000")]
I may be available for hire, check my thread: viewtopic.php?f=66&t=51350
Re: While playing your ren'py game, is there a way to output the currently executed code as you're clicking around?
Black belt! This is great! Thank you.drKlauz wrote: ↑Fri Jun 11, 2021 10:05 am Or just show current lineCode: Select all
frame: background "#000A" padding (16,8) $ctx=renpy.game.context() $node=renpy.game.script.lookup(ctx.current) text "{}, line: {}".format(node.filename,node.linenumber) outlines [(2,"#000")]
Definitely going to try this tomorrow.None of this adds up to the full trace capability you seem to asking about, though. But since renpy is Python under the hood, you should be able to import a python tracing library (like https://pymotw.com/2/trace/) if you want one. I haven't tried it, though.
Re: While playing your ren'py game, is there a way to output the currently executed code as you're clicking around?
I just found someone wrote an allegedly proper debugger for renpy. I have not tried it.
https://github.com/Enerccio/renpy-debugger
https://github.com/Enerccio/renpy-debugger
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
Re: While playing your ren'py game, is there a way to output the currently executed code as you're clicking around?
If you'll download a good old Ren'Py (like ver. 6.6.0), you could find the editor.rpy file in the demo-game folder. This code still working...
Code: Select all
# This file contains code that's used to display the editor button,
# and the code that launches the editor with the given filename.
# This file can serve as an example of how to use an overlay, I guess.
init:
# This lets us control if the editor button is shown or not.
$ show_editor_button = False
python hide:
# This function is called at least one per interaction.
def overlay():
# If we don't want to show the editor button, do nothing.
if not show_editor_button:
return
# Figure out the filename and the line number.
import os.path
filename, line = renpy.get_filename_line()
filename = os.path.basename(filename)
# The function that is called when the button is clicked.
def clicked():
# We want to look for the filename in config.gamedir,
# rather then using the full filename given by
# get_filename_line. This is because the filename is fixed
# when the file is compiled, and so may have changed before
# the script is run. config.gamedir is computed when Ren'Py
# starts up, and so should always be right.
fullfn = config.gamedir + "/" + filename
# If the file exists, then we launch it in the editor, using
# the undocumented launch_editor function.
if os.path.exists(fullfn):
renpy.launch_editor([ fullfn ], line)
# Display the button, modifying its look so that it doesn't
# take up an excessive amount of space.
ui.button(clicked=clicked,
xpos=798, xanchor=1.0, ypos=2, xpadding=6, xminimum=200,
background=RoundRect((0, 60, 120, 255), 6),
hover_background=RoundRect((0, 80, 160, 255), 6),
)
# The button contains this text. We can't use ui.textbutton,
# since we want to restyle things.
ui.text("%s:%d" % (filename, line),
style="button_text",
size=14)
# Append the overlay function to the list of overlay functions.
config.overlay_functions.append(overlay)
Code: Select all
# The game starts here.
label start:
$ show_editor_button = True
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot]