| Engine | Godot 4.2 or newer |
|---|---|
| Language | GDScript |
| Time to run | ~3 minutes |
| Level | Beginner — comfortable with the FileAccess API |
| Output | One file (~50 lines) plus an example CSV |
| Dependencies | None. |
The prompt
Open claude.ai/new and paste this in.
$ Build me a Godot 4.2+ GDScript that loads a tilemap from a CSV file. // shape - A Node script TilemapLoader.gd with one public method: load_from_csv(tilemap: TileMap, path: String, layer: int = 0). - Each row in the CSV is a row of tiles. Cells are integers = tile source IDs. - A cell of -1 means "leave empty" (don't write any tile). - Lines starting with # are comments and skipped. - Rows with different lengths log a warning and pad/truncate to the longest row. // behavior - Use FileAccess.open(path, FileAccess.READ). - Use tilemap.set_cell(layer, Vector2i(x, y), source_id) to place tiles. - If source_id is not in tilemap.tile_set, log a warning with the row/col and skip that cell. // example data - After the script, include an example CSV (5 rows × 8 columns) demonstrating: comments, the -1 empty marker, and a missing-tile case. // return format - One .gd file in a code block, one .csv file in a separate code block. - No prose before or after.
Open in Claude ▸
Run · 3 min
What this gets you
The "edit in Google Sheets / Numbers, drop the CSV in, hit play" workflow. Faster than the built-in TileMap editor for prototyping, especially during a jam.
Quick checklist
- Uses set_cell with the layer index. Godot 4 made layer-aware setting mandatory; passing 0 is fine, but the parameter must exist.
- Handles trailing newlines and BOMs. If you exported from Excel, expect ugly invisible characters.
- Logs warnings, doesn't crash. A typo in the CSV shouldn't kill the loader.
Full breakdown coming soon
The walkthrough with a worked example, autotile handling, and a Tiled-format alternative is on the roadmap. Bookmark this page or check back on the blog.