common¶
Module for everything in common between all kinds of Terraria save files.
Assuming a save file is not encrypted, as is the case for character files, you can use the items made available by this module to determine the kind of save file you’re dealing with.
Example
from lihzahrd.terraria.utils.packer import Packer
from lihzahrd.terraria.common.file_metadata import FileMetadata
with open("tests/lihzahrd/terraria/world/Honey_of_Privacy.wld") as stream:
fp = Packer(stream)
metadata = FileMetadata.read(fp).instance
print(metadata.kind)
metadata.revision.value += 1
print(metadata.revision)
file_metadata¶
Submodule collecting all parts of the Terraria save file header in a single class.
- class lihzahrd.terraria.common.file_metadata.FileMetadata(*args: Pack, **kwargs)¶
PackCompositefor all parts of the Terraria save file header.- version: Field[Self, PackFileVersion]¶
The version with which the save file was written with.
- Type:
- signature: Field[Self, PackFileSignature]¶
The signature of the save file.
- Type:
- kind: Field[Self, PackFileKind]¶
The kind of the save file.
- Type:
- revision: Field[Self, PackFileRevision]¶
The revision of the save file.
The save file revision should increase by
1each time a save file is saved.- Type:
- flags: Field[Self, PackFileFlags]¶
The flags of the save file.
- Type:
file_version¶
Submodule for distinguishing between the Terraria game versions with which a save file was written with.
- class lihzahrd.terraria.common.file_version.FileVersion(*values)¶
IntEnumcontaining all known associations between Terraria version strings and file version numbers.See also
Desktop version history on the Terraria wiki.
- __str__() str¶
Get the properly-formatted version name.
Example
>>> str(FileVersion["V.1.4.5.5"]) "v1.4.5.5"
- Returns:
The properly-formatted version name, such as
"v1.4.5.5".
- V_1_0_5 = 12¶
- V_1_0_6 = 20¶
- V_1_0_6_1 = 22¶
- V_1_1_1 = 37¶
- V_1_1_2 = 39¶
- V_1_2 = 67¶
- V_1_2_0_3_1 = 71¶
- V_1_2_1_1 = 72¶
- V_1_2_1_2 = 73¶
- V_1_2_2 = 77¶
- V_1_2_3_1 = 94¶
- V_1_2_4 = 101¶
- V_1_2_4_1 = 102¶
- V_1_3_0_1 = 140¶
- V_1_3_0_2 = 147¶
- V_1_3_0_3 = 149¶
- V_1_3_0_4 = 151¶
- V_1_3_0_5 = 153¶
- V_1_3_0_6 = 154¶
- V_1_3_0_7 = 155¶
- V_1_3_0_8 = 156¶
- V_1_3_1 = 168¶
- V_1_3_1_1 = 169¶
- V_1_3_2 = 170¶
- V_1_3_2_1 = 173¶
- V_1_3_3 = 174¶
- V_1_3_3_1 = 175¶
- V_1_3_3_2 = 176¶
- V_1_3_3_3 = 177¶
- V_1_3_4 = 178¶
- V_1_3_4_1 = 185¶
- V_1_3_4_2 = 186¶
- V_1_3_4_3 = 187¶
- V_1_3_4_4 = 188¶
- V_1_3_5 = 191¶
- V_1_3_5_1 = 192¶
- V_1_3_5_2 = 193¶
- V_1_3_5_3 = 194¶
- V_1_4_0_1 = 225¶
- V_1_4_0_2 = 226¶
- V_1_4_0_3 = 227¶
- V_1_4_0_4 = 228¶
- V_1_4_0_5 = 230¶
- V_1_4_2_3 = 238¶
- V_1_4_4_5 = 274¶
- V_1_4_4_8 = 278¶
- V_1_4_4_9 = 279¶
- V_1_4_5_4 = 317¶
- V_1_4_5_5 = 318¶
- class lihzahrd.terraria.common.file_version.PackFileVersion(value: Value)¶
PackforFileVersionas represented in the save file metadata header.- ENUM¶
alias of
FileVersion
file_signature¶
Submodule for distinguishing between the possible file signature that a Terraria save file may have.
- class lihzahrd.terraria.common.file_signature.FileSignature(*values)¶
StrEnumcontaining all known Terraria save file signatures.- RELOGIC = 'relogic'¶
Signature of international Terraria save files.
- XINDONG = 'xindong'¶
Signature of some Chinese Terraria save files.
- __str__()¶
Return str(self).
- class lihzahrd.terraria.common.file_signature.PackFileSignature(value: Value)¶
PackforFileSignatureas represented in the save file metadata header.Validates that the contained signature is exactly 7-characters long.
- ENUM¶
alias of
FileSignature
file_kind¶
Submodule for distinguishing between Terraria save file kinds.
- class lihzahrd.terraria.common.file_kind.FileKind(*values)¶
IntEnumdescribing a kind of Terraria save file.- INVALID = 0¶
A specifically-invalid value.
- MAP = 1¶
A minimap.
- WORLD = 2¶
A world save file.
See also
The
lihzahrd.terraria.worldmodule.
- PLAYER = 3¶
A player character save file.
Note
Player character save files are usually encrypted with a static key, and must be unencrypted before they can be processed with
FileMetadata.
file_revision¶
Submodule for processing the save file revision number.
file_flags¶
Submodule for distinguishing between Terraria save file kinds.