from tdw.add_ons.output_data_writer import OutputDataWriter
Save raw output byte data to disk per frame. This data is encoded into base64 strings and saved as text files.
-
output_directory
The root output directory as aPath
. If this doesn't exist, it will be created. -
commands
These commands will be appended to the commands of the nextcommunicate()
call. -
initialized
If True, this module has been initialized.
__init__
OutputDataWriter(output_directory)
OutputDataWriter(output_directory, zero_padding=8)
Parameter | Type | Default | Description |
---|---|---|---|
output_directory | PATH | The root output directory as a string or Path . If this doesn't exist, it will be created. |
|
zero_padding | int | 8 | How many zeros to append to the file name. By default, the name of the file of the first frame will be 00000000.txt . |
self.reset()
This will reset the frame count.
self.read(path)
Read saved ouput data.
Parameter | Type | Default | Description |
---|---|---|---|
path | Union[str, Path, int] | The path to the frame file. This can be a string or Path file path or an integer. If this is an integer, it represents the frame number; the file is assumed to be in self.output_directory . |
Returns: A list of bytes that was saved as base64 data, equivalent to the return value of a c.communicate(commands)
call (i.e. resp
as it usually appears in our example controllers).
self.get_initialization_commands()
This function gets called exactly once per add-on. To re-initialize, set self.initialized = False
.
Returns: A list of commands that will initialize this add-on.
self.on_send(resp)
This is called within Controller.communicate(commands)
after commands are sent to the build and a response is received.
Use this function to send commands to the build on the next Controller.communicate(commands)
call, given the resp
response.
Any commands in the self.commands
list will be sent on the next Controller.communicate(commands)
call.
Parameter | Type | Default | Description |
---|---|---|---|
resp | List[bytes] | The response from the build. |
self.before_send(commands)
This is called within Controller.communicate(commands)
before sending commands to the build. By default, this function doesn't do anything.
Parameter | Type | Default | Description |
---|---|---|---|
commands | List[dict] | The commands that are about to be sent to the build. |
self.get_early_initialization_commands()
This function gets called exactly once per add-on. To re-initialize, set self.initialized = False
.
These commands are added to the list being sent on communicate()
before any other commands, including those added by the user and by other add-ons.
Usually, you shouldn't override this function. It is useful for a small number of add-ons, such as loading screens, which should initialize before anything else.
Returns: A list of commands that will initialize this add-on.