I'm trying to implement a mod manager in the game and I'm in a bit of trouble...
I am loading a zip folder with a ProjectSettings.loadresourcepack() command. once the mod is loaded, I am trying to replace the previous file with the new one. For example:
var scene = preload("res://ship/myship.tscn")
var modifiedScene = scene.instance()
var new node = # a new created node
ModLoader.appendNodeInScene(modifiedScene, new node)
This code is working well, and I don't have any problem with it. But in another case, I'm trying to only replace a script. and in this case the same method doesn't seem to work:
func takeOverScript(newScriptPath:String, OldScriptPath:String):
var savedScript = load(newScriptPath)
Once I'm calling this function, the OldScriptPath does have the code of the new script. Yay ! However, when I'm using a scene ( let call it myShypyard.tscn) with an external reference to my OldScriptPath:
[ext_resource path="res:///old/Script/Path.gd" type="Script" id=1]
The OLD script is called (I checked with some print, and the scene return the print of the old script and not the new one).
I even tried to use the same method as previously by loading an already modified copy of myShypyard.tscn, pointing to a new path, where I store the new script at first (res:///overwride/old/Script/Path.gd), but it's STILL the initial copy of the scene who is loaded, and not the new one.
I think godot is preloading my scene, and I can't find a way to reload it in the cache, or with my new scene, or with my new script...
Does somebody have an idea of how to make the script replace the old one at runtime ?
Or does anybody have a way to add a patch package BEFORE the game compilation ?