Utility for saving and loading painted terrain cells on TileMapLayer nodes. Terrain paint data (set via TileMapLayer.set_cells_terrain_connect()) is ephemeral — it lives only on the live TileMapLayer and is lost on scene reload. This class provides save_terrain() and load_terrain() to serialize/deserialize terrain cell data so painted terrain survives across sessions. Each cell record captures (cell, terrain_set, terrain) — the three values needed to restore via TileMapLayer.set_cells_terrain_connect(). The TileSet is assumed to be the same resource used at paint time; terrain indices are scoped to that TileSet. Usage: # Save TerrainPersistence.save_terrain(tile_map, "user://terrain_save.res") # Load TerrainPersistence.load_terrain(tile_map, "user://terrain_save.res") Authority contract: these save/load helpers are a convenience for plugin placement bookkeeping. The game owns its save file and must not persist the same terrain fact authoritatively in two places; do not call both this helper and the game save for the same terrain.
Source: addons/grid_placement/placement/terrain/terrain_persistence.gd
Syntax
class TerrainPersistence extends RefCountedMembers
| Name | Kind | Summary |
|---|---|---|
save_terrain | Method | |
load_terrain | Method | |
save_all_terrain | Method | |
load_all_terrain | Method |
Tutorials built on Grid Placement
- Godot multiplayer grid placement: one host, four sessions
- Godot 2D grid building system: paint, place, save
- Godot 3D grid building system: the runtime loop
- Godot 4 grid-building plugins: build mode vs editor tools
- 3D room placement in Godot: build rooms and stack storeys
- 3D grid placement in Godot 4: full setup tutorial
- Snap to a TileMap in Godot: 2D grid placement
- How to make a farming system in Godot
- How to snap objects to a 3D grid in Godot