Prefabs

From 7 Days to Die Wiki
Jump to: navigation, search
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.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[edit | edit source]

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

Block Names[edit | edit source]

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[edit | edit source]

The purpose of files ending in .ins is unknown. Not every prefab has an INS file. They were introduced in Alpha 17.

Thumbnail[edit | edit source]

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

Mesh[edit | edit source]

Mesh files were introduced in Alpha 16. They end in .mesh and are not present for every prefab. It is not yet known what their purpose is.

TTS[edit | edit source]

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 15 Version 13
Header
char[4] tts
uint32 version
uint16 x_dimension
uint16 y_dimension
uint16 z_dimension

The header for a tts prefab file is 14 bytes long.

Same as version 15
Block Data
struct blocks[x_dimension * y_dimension * z_dimension]
    uint32 block_data

After the header, every block is represented in 4 bytes of data, meaning this section is x_dimension * y_dimension * z_dimension * 4 bytes long.

There are two parts to each 4 byte (32 bit) block 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.

Same as version 15
End
byte[x_dimension * y_dimension * z_dimension * 3] unknown
uint16 size_of_end_header
byte[size_of_end_header] end_header
byte[?] unknown

After the blocks section, there is some extra data. It is unknown what this data is used for at this time.

Same as version 15

XML[edit | edit source]

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[edit | edit source]

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

External links[edit | edit source]