making reusable text object I want to simulate a multi-agent system with Blender. It's almost done, but I experience a problem.

System agents speak to each other by passing messages, and I want to pass messages between them. I considered a text object as container of these messages. There is no constraint on the number of agents.

I want to create one (or some) text object and reuse it many times, by only changing source and destination locations and body texts.

After some search, I realized, that there is no data_path that supports keyframe_insert() to change the body text. Beside that I found dynamic text, but my context is extremely different with that method's context.

I want to change text on every keyframe, and it depends on my simulation's input.
An application handler could be used to read subtitle data from your simulation module and display it by editing a text object.

import bpy
from bpy.app.handlers import persistent


@persistent
def frame_change(arg):
    print("Load Handler:", bpy.data.filepath)
    t = bpy.data.objects["Text"]
    # here get the text you want to display
    label = ("Frame # %d" % bpy.context.scene.frame_current)
    t.data.body = label

bpy.app.handlers.frame_change_pre.append(frame_change)