[go: up one dir, main page]

Skip to content

Nested saving and loading plugin for Godot 3.5 is a small library (only 131 lines of code) which implements saving and loading with the possibility of saving nested Nodes, which each have their own distinct state.

License

Notifications You must be signed in to change notification settings

steffen-schumacher/godot-nested-saving-loading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


Logo

Nested saving and loading plugin for Godot 3.5


Explore the docs »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

Nested saving and loading plugin for Godot 3.5 is a small library (only 131 lines of code) which implements saving and loading with the possibility of saving nested Nodes, which each have their own distinct state.

(back to top)

Built With

The addon is made 100% in GDScript.

(back to top)

Getting Started

The plugin is made for Godot 3.4.x and 3.5.x

Installation

  1. Clone the repo
    git clone https://github.com/steffen-schumacher/godot-nested-saving-loading
  2. Copy the 'addons' folder into your project root
  3. In the Godot Editor go to Project -> Project Settings -> Plugins and check the 'Enable' button

(back to top)

Usage

This plugin adds an autoload singleton called Persistence. Save a scene by calling save_scene with the tree of the scene and a path. Load the saved state back into the scene by calling load_scene with the same parameters.

Property Type Description Default value
default_properties Array Default properties to save []
save_position bool Should the position be saved true
save_rotation bool Should the rotation be saved true

Example call that saves the current scene:

   Persistence.save_scene(get_tree(), "user://savegame.save")

Example call that loads the state into the current scene:

   Persistence.load_scene(get_tree(), "user://savegame.save") 

To make Nodes in the scene persistent, add them to the group Persist. By default, the position and the rotation of Spatial and Node2D extending Nodes will be saved and loaded. If the Node does not extend one of these classes, only additional values will be saved. You can add a function called _save() to your persistent Node, to save additional values. These will get assigned each to the property with a matching key when loading the scene.

Example function that saves the visibility of the persistent Spatial or Node2D:

   func _save():
      return {
      "visible": visible
   }

Another way of saving additional values is adding the names of the properties, you want to save, to Persistence.default_properties. You can set these via GDScript or in the inspector by modifying the addons/nested-saving/Persistence.tscn.

Example configuration that saves the visibility of all persistent Nodes:

   Persistence.default_properties = ['visible']

If you want to save nested Nodes, you have to make every Node between the root persistent Node and the child persistent, so the loading system can process the path to the parent Nodes correctly.

Right:

Wrong:

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Steffen Schumacher - steffenschumacher7@gmail.com

Project Link: https://github.com/steffen-schumacher/godot-nested-saving-loading

(back to top)

About

Nested saving and loading plugin for Godot 3.5 is a small library (only 131 lines of code) which implements saving and loading with the possibility of saving nested Nodes, which each have their own distinct state.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published