I'm playing with someone else's project and notice that they have a .tres file with a bunch of .obj files inside of it. What is a .tres file?

in code they are able to access it via:

var _voxel_library := preload("res://blocky_game/blocks/voxel_library.tres")

then they are able to access the index of a .obj file with this method: var id = _voxel_library.get_voxel_index_from_name(vname)

If .tres files are built-in part of Godot, then how did the name: get_voxel_index_from_name get created? since its specific to the type of object being stored in the .tres file

If I want to add a .obj file to the .tres file how would I do that? Would I need to create a new .tres file from scratch?

.tres = text resource

What type of resource is it? You can determine that by viewing the .tres file in the Inspector, or with a text editor.

@DaveTheCoder

I'm not sure. Its from the godot open-source voxel engine:

[gd_resource type="VoxelLibrary" load_steps=54 format=2]

[ext_resource path="res://blocky_game/blocks/grass/grass.obj" type="ArrayMesh" id=1]
[ext_resource path="res://blocky_game/blocks/dirt/dirt.obj" type="ArrayMesh" id=2]
[ext_resource path="res://blocky_game/blocks/log/log_y.obj" type="ArrayMesh" id=3]
[ext_resource path="res://blocky_game/blocks/log/log_x.obj" type="ArrayMesh" id=4]
[ext_resource path="res://blocky_game/blocks/log/log_z.obj" type="ArrayMesh" id=5]
[ext_resource path="res://blocky_game/blocks/stairs/stairs_nx.obj" type="ArrayMesh" id=6]
[ext_resource path="res://blocky_game/blocks/planks/planks.obj" type="ArrayMesh" id=7]
[ext_resource path="res://blocky_game/blocks/tall_grass/tall_grass.obj" type="ArrayMesh" id=8]
[ext_resource path="res://blocky_game/blocks/stairs/stairs_px.obj" type="ArrayMesh" id=9]
[ext_resource path="res://blocky_game/blocks/stairs/stairs_pz.obj" type="ArrayMesh" id=10]
[ext_resource path="res://blocky_game/blocks/stairs/stairs_nz.obj" type="ArrayMesh" id=11]
[ext_resource path="res://blocky_game/blocks/glass/glass.obj" type="ArrayMesh" id=12]
[ext_resource path="res://blocky_game/blocks/water/water_full.obj" type="ArrayMesh" id=13]
[ext_resource path="res://blocky_game/blocks/water/water_top.obj" type="ArrayMesh" id=14]
[ext_resource path="res://blocky_game/blocks/rail/rail_slope_nz.obj" type="ArrayMesh" id=15]
[ext_resource path="res://blocky_game/blocks/rail/rail_slope_px.obj" type="ArrayMesh" id=16]
[ext_resource path="res://blocky_game/blocks/rail/rail_slope_pz.obj" type="ArrayMesh" id=17]
[ext_resource path="res://blocky_game/blocks/rail/rail_turn_px.obj" type="ArrayMesh" id=18]
[ext_resource path="res://blocky_game/blocks/rail/rail_turn_nz.obj" type="ArrayMesh" id=19]
[ext_resource path="res://blocky_game/blocks/rail/rail_x.obj" type="ArrayMesh" id=20]
[ext_resource path="res://blocky_game/blocks/rail/rail_z.obj" type="ArrayMesh" id=21]
[ext_resource path="res://blocky_game/blocks/rail/rail_turn_nx.obj" type="ArrayMesh" id=22]
[ext_resource path="res://blocky_game/blocks/rail/rail_turn_pz.obj" type="ArrayMesh" id=23]
[ext_resource path="res://blocky_game/blocks/rail/rail_slope_nx.obj" type="ArrayMesh" id=24]
[ext_resource path="res://blocky_game/blocks/leaves/leaves.obj" type="ArrayMesh" id=25]
[ext_resource path="res://blocky_game/blocks/dead_shrub/dead_shrub.obj" type="ArrayMesh" id=26]

[sub_resource type="Voxel" id=1]
voxel_name = "air"

[sub_resource type="Voxel" id=2]
voxel_name = "dirt"
geometry_type = 2
custom_mesh = ExtResource( 2 )
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]

. . .


[sub_resource type="Voxel" id=27]
voxel_name = "stairs_nz"
geometry_type = 2
custom_mesh = ExtResource( 11 )
collision_aabbs = [ AABB( 0, 0, 0, 1, 1, 1 ) ]

[resource]
voxels/0 = SubResource( 1 )
voxels/1 = SubResource( 2 )
voxels/2 = SubResource( 13 )
voxels/3 = SubResource( 21 )
voxels/4 = SubResource( 22 )
voxels/5 = SubResource( 23 )
voxels/6 = SubResource( 24 )
voxels/7 = SubResource( 25 )
voxels/8 = SubResource( 26 )
voxels/9 = SubResource( 27 )
voxels/10 = SubResource( 3 )
voxels/11 = SubResource( 4 )
voxels/12 = SubResource( 5 )
voxels/13 = SubResource( 6 )
voxels/14 = SubResource( 7 )
voxels/15 = SubResource( 8 )
voxels/16 = SubResource( 9 )
voxels/17 = SubResource( 10 )
voxels/18 = SubResource( 11 )
voxels/19 = SubResource( 12 )
voxels/20 = SubResource( 14 )
voxels/21 = SubResource( 15 )
voxels/22 = SubResource( 16 )
voxels/23 = SubResource( 17 )
voxels/24 = SubResource( 18 )
voxels/25 = SubResource( 19 )
voxels/26 = SubResource( 20 )

the tres file format is a plain text resource file format as opposed to the binary .res format and is indeed godot's but you can essentially store anything plain-text in it. Scenes, materials and shaders are just some of the things you can save as .tres

The project you mentioned likely is using/has a custom plugin or module for voxels that has a method for storing data in a plain-text format save into and loaded from the .tres file.

The resource type is "VoxelLibrary", shown at the top of the file. That's apparently a custom resource type, and I'm not familiar with it.

If you view the resource in the Inspector, does it have any fields you can change?

@DaveTheCoder yeah thanks. I was able to edit it that way!

a year later