Global Scripts Issues with Version Control

I can write one for you using your screenshots.

@tool
extends EditorPlugin

const AUTOLOAD_GLOBAL = "Global"


func _enable_plugin() -> void:
	add_autoload_singleton(AUTOLOAD_GLOBAL, "res://scenes/globals/global.tscn")


func _disable_plugin() -> void:
	remove_autoload_singleton(AUTOLOAD_GLOBAL)

You can just add the other scripts yourself. So for MoneyManager:

@tool
extends EditorPlugin

const AUTOLOAD_GLOBAL = "Global"
const AUTOLOAD_MONEY_MANAGER = "MoneyManager"


func _enable_plugin() -> void:
	add_autoload_singleton(AUTOLOAD_GLOBAL, "res://scenes/globals/global.tscn")
	add_autoload_singleton(AUTOLOAD_MONEY_MANAGER, "res://scenes/globals/money_manager.tscn")


func _disable_plugin() -> void:
	remove_autoload_singleton(AUTOLOAD_GLOBAL)
	remove_autoload_singleton(AUTOLOAD_MONEY_MANAGER)

Do that for the rest. Then.

  1. Save this file in res://addons/autoloads/plugin.gd
  2. Create a file res://addons/autoloads/plugin.cfg and put this in it:
[plugin]

name="Autoloads"
description="Our game's autoloads."
author="Catlin"
version="1.0"
script="plugin.gd"
  1. Go to Project → Project Settings → Plugins
  2. Enable your new Autoloads plugin.
  3. Disable the plugin to uninstall everything.
  4. Click on the Globals tab.
  5. Delete any autoloads that were not uninstalled. (We are doing a clean sweep.) Note any that didn’t get deleted automatically in case you forgot to add them to the plugin script.
  6. Click Close.
  7. Save the entire project (Ctrl+S).
  8. Go to Project → Reload Current Project
  9. Wait for the project to reload. (You should get a bunch of errors about missing things - that’s good.)
  10. Go to Project → Project Settings → Plugins
  11. Enable your new Autoloads plugin.
  12. Click Close.
  13. Save the entire project (Ctrl+S).
  14. Go to Project → Reload Current Project
  15. Wait for the project to reload.

All the errors should go away.

Commit it to a branch and have someone else check it out, and their problems with the autoloads should go away.

1 Like