Skip to content

Overwriting Game Resources

KANAjetzt edited this page Mar 23, 2023 · 5 revisions

overwrites.gd

The overwrites.gd file is used to define resource overwrites in a separate file. In general, any file in a project can be overwritten, but we highly recommend that you only use this feature for images and audio.

We recommend the following directory structure for your overwrites:

res://
└───mods-unpacked
    └───Author-ModName
        ├───mod_main.gd
        ├───manifest.json
        ├───overwrites.gd
        └───overwrites
            └───original_dir_name
                └───original_file_name.png
        

The following steps are required to create an overwrite:

  1. Open the file you want to replace by right-clicking and selecting Open in File Manager.
  2. Create a replacement file that matches the metadata of the original file 1:1.
    For example, for images, make sure that the resolution is the same.
  3. Add the replacement file to the overwrites directory.
    Ideally, structure your overwrites as shown above.
  4. Add the required code to overwrites.gd.

Example

extends Node

func _init():
	var overwrite_0 = preload("res://mods-unpacked/Author-ModName/overwrites/assets/images/GodotModded.png")
	overwrite_0.take_over_path("res://assets/images/GodotModded.png")

Mod Tool

You can use Godot Mod Tool to make overwriting assets easier. If you have the plugin activated:

  • right-click -> ModTool: Create Asset Overwrite on the asset you want to replace