I looked at other results and I applied their examples to my code.
I added this variable in my TimeCounter function, that gets evaluated value from custom property.
eval_text = TextObject.evaluated_get(depsgraph)
and also changed def TimeCounter(scene): to def TimeCounter(scene, depsgraph):
And in the end this script was here to recompile the results,
bpy.app.handlers.frame_change_post.clear()
bpy.app.handlers.frame_change_post.append(TimeCounter)
def unregister():
bpy.app.handlers.frame_change_post.remove(TimeCounter)
if name == "main":
register()
It also works without this long code.
bpy.app.handlers.frame_change_post.append(TimeCounter)
Here's full working code:
import bpy
scene = bpy.context.scene
TextObject = scene.objects['TimerText']
def TimeCounter(scene, depsgraph):
eval_tex = TextObject.evaluated_get(depsgraph)
value = eval_tex.data['time']
min = int(round(value/60, 60))
sec = value-(min*60)
TextObject.data.body = 'Time ' + str(min) + ':' + str(sec).zfill(2)
def register():
bpy.app.handlers.frame_change_post.clear()
bpy.app.handlers.frame_change_post.append(TimeCounter)
def unregister():
bpy.app.handlers.frame_change_post.remove(TimeCounter)
if name == "main":
register()