Skip to content

Commit

Permalink
Added minimal code snippet to enable saves
Browse files Browse the repository at this point in the history
  • Loading branch information
Zylann committed Apr 6, 2024
1 parent f0ec8d3 commit bea140e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions doc/source/streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,25 @@ Saving only occurs under the following conditions:
- The block gets unloaded when too far away
- [save_modified_blocks()](api/VoxelTerrain.md#i_save_modified_blocks) is called on the terrain node (you may want to call this when the player saves, on a timer, or when quitting the game)

You can add minimal saving with this script:

```
extends VoxelTerrain
func _ready():
stream = VoxelStreamSQLite.new()
stream.database_path = "path/to/save.file" # Note, the directory must exist
func _on_tree_exited():
save_modified_blocks()
```

It can get more complex as development progresses. See following sections for details.

See also this demo game, which includes one save: [https://github.com/Zylann/voxelgame/tree/master/project/blocky_game](https://github.com/Zylann/voxelgame/tree/master/project/blocky_game)

TODO: Demo handling multiple saves


Asynchronous saving
---------------------
Expand Down

0 comments on commit bea140e

Please sign in to comment.