Overwriting Resources - DomeKeeperMods/Docs GitHub Wiki
Table of Contents
Overwriting Resources
In Godot, any resource can be overwritten using the take_over_path function, which is documented in the official docs. This function is incredibly useful when creating mods.
An effective method for managing this function involves creating a file named overwrites.gd in the top-level folder of your mod. The Mod Loader will then execute the _init() function of this file upon startup.
Consider the following example:
func _init():
var overwrite = preload("res://mods-unpacked/Raffa-HydraLauncher/overwrites/content/icons/hydralauncher.png")
overwrite.take_over_path("res://content/icons/hydralauncher.png")
In this example, hydralauncher.png is virtually copied to res://content/icons, which enables Dome Keeper to automatically find the icon for this mod's tech tree.
Additional information on this topic can be found in the Mod Loader's documentation about overwrites. You can also refer to the Hydra Launcher mod's overwrites.gd.
Potential Pitfalls
⚠ Caution:
Overwriting the resource paths of existing game resources can cause complications for other mods. If your mod overwrites essential scripts such as StageManager.gd or LevelStage.gd, it could potentially disrupt other mods.
Please bear this in mind and adhere to the best practice of extending before overwriting.
Ideal Use Cases
There are scenarios where taking over paths can be incredibly beneficial, such as with icons.
Dome Keeper may presume files with a certain naming convention are in a specific folder (like, for example, icons). In such situations, using overwrites.gd serves as an excellent solution.