7 Days to Die Wiki
Advertisement
Factory lg 01 prefab

factory_lg_01.tts prefab file version 4. This image was made with a python script, giving random colors to each block.

Factory lg 01 prefab v8

factory_lg_01.tts prefab file version 8. This image shows the difference between version 4 and 8.

Prefabs are pre-built world objects such as buildings, doors and signs that are scattered around the map. They allow developers and users to make maps more easily because they can be copied, pasted and reused any number of times.

The Prefabs in Navezgane are reflected in the file Data/Worlds/Navezgane/prefabs.xml. This file contains a list of every prefab in Navezgane including their coordinates and rotation.

For information on how Prefabs are placed outside of Navezgane see Random World Generation.

The path to all of the default prefab files is Data/Prefabs/.

See List of Prefabs for a list of every prefab and its properties.

Technical[ | ]

Each Prefab has between four and six files associated with it.

Block Names[ | ]

Files ending in .blocks.nim associate block ids with their in-game names. These ids are referenced in the TTS file. By changing a block name in this file all blocks referenced by that id in the TTS file will be changed. This feature was introduced in Alpha 17.

INS[ | ]

The purpose of files ending in .ins is to store the `PrefabInsideDataFile`. Not every prefab has an INS file. They were introduced in Alpha 17.

Thumbnail[ | ]

Prefabs optionally have .jpg thumbnail images used to preview the prefab in the in-game editor. This was introduced in Alpha 17.

Mesh[ | ]

Mesh files were introduced in Alpha 16. They end in .mesh and are not present for every prefab. They store the prefab imposters.

TTS[ | ]

Files ending in .tts contain the voxel block data for each prefab. They are binary files, and the format is explained below for the currently used versions. All numbers are in little endian.

Version 16
Header The header for a tts prefab file is 8 bytes long.
char[4] tts\0 # file type
uint32 version # compatibility
Block Data First we store another static header giving the size of the prefab
ushort size.x
ushort size.y
ushort size.z
We need to store exactly size.x*size.y*size.z blocks:
uint32[x*y*z] rawBlockData
byte[x*y*z] blockDensity
byte[x*y*z][2] blockDamageData
Next we have special SimpleBitStream storing which block has a texture (>0):
# SimpleBitStream as encoded binary
int32 numberOfBytes
byte[numberOfBytes] data
Each block that has a texture (>0) is now also stored:
long[blocksWithTextureCount] texture

There are two parts to each 4 byte (32 bit) block raw-data:

  • Bits (0 - 14) are for the block id.
  • Bits (15 - 31) are for flags.

The block id found in the lower 15 bits of each block integer corresponds to a block id in the .blocks.nim file associated with that prefab. Block properties can then be looked up by name using the file Data/Config/blocks.xml. Every block id has to be less than 32768 (2^15). At the very end of the blocks.xml file there is a comment that says: Block limit: There can be 32k blocks in the game. 0-255 are reserved for air/terrain blocks..

The first two flag bits (15 - 16) encode the rotation of a block around the vertical axis.

It is unknown what the rest of the flag bits do at this time.

Tile Entity Data
short count
  # repeated for every tileEntity
  short dataSizeForTile
  byte tileEntityType
  # each type has different data to store
  byte[dataSizeForTile] data
Trigger Data
short count
  # repeated for every triggerData
  short dataSizeForTrigger
  Vector3i position # int[3]
  # each type has different data to store
  byte[dataSizeForTrigger] data

XML[ | ]

Every prefab has an XML file ending in .xml that stores attributes about the model such as what Biome, Zone and Township they can spawn in.

Versions[ | ]

As the game has been updated, the prefab format has changed slightly. These changes are reflected in the version number found in the header of each prefab file.

Alpha 17 (b240)

File Version Number of Prefabs
13 356
15 94

Video Tutorial[ | ]

Guide how to import a prefab into a new/existing game world.

External links[ | ]

Advertisement