update only per interaction
don't shown in game menu
don't save watching list
I made more usuful variable viewer.
Please use dynamic_watch() and try it.
this code is public domain.
Code: Select all
init -10 python:
def dynamic_watch():
renpy.show_screen("_dynamic_watcher", _layer="debug")
def _watching_exp(expression):
return DynamicDisplayable(_dynamic_text, expression=expression)
def _dynamic_text(st, at, expression):
try:
return Text(unicode(renpy.python.py_eval(expression))), .1
except:
return Text("Exception"), .1
if persistent._watch_list is None:
persistent._watch_list = []
class Function(Action):
"""
:doc: other_action
This Action calls `callable` with `args` and `kwargs`.
`callable`
Callable object.
`args`
position arguments to be passed to `callable`.
`kwargs`
keyword arguments to be passed to `callable`.
"""
def __init__(self, callable, *args, **kwargs):
self.callable = callable
self.args = args
self.kwargs = kwargs
def __call__(self):
self.callable(*self.args, **self.kwargs)
init 1000 python:
config.locked = False
config.layers.append('debug')
config.top_layers.append('debug')
config.locked = True
screen _dynamic_watcher:
zorder 2000
frame:
background "#0004"
xfill True
ymaximum 300
has vbox
viewport:
scrollbars "both"
mousewheel True
grid 3 len(persistent._watch_list):
for i in persistent._watch_list:
hbox:
textbutton _("x") action [Function(persistent._watch_list.remove, i), Show("_dynamic_watcher", _layer="debug")]:
background None
xpadding 0
ypadding 0
xmargin 10
ymargin 0
yalign .5
text "[i]" yalign .5
text " -> " yalign .5
text _watching_exp(i) yalign .5
hbox:
xalign 1.
textbutton _("add") action Function(renpy.call_in_new_context, "_watch_list_add")
textbutton _("close") action [Function(renpy.hide_screen, "_dynamic_watcher", layer="debug"), renpy.restart_interaction]
screen _watch_list_add:
modal True
zorder 2500
frame:
xfill True
xmargin .05
ypos .1
yanchor 0
ypadding .05
has vbox:
xalign .5
yalign .5
spacing 30
label _("Enter adding expression"):
xalign 0.5
hbox:
xalign 0.5
input
label _watch_list_add:
python:
persistent._watch_list.append(renpy.call_screen('_watch_list_add', _layer="debug"))
return