You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to load a resource pack from a zip file using ProjectSettings.load_resource_pack() with the replace_files boolean set to false, but regardless the script file in the zip, which has the same name as an identical script in the main project, is being replaced.
Steps to reproduce
Open and run the sample project. It prints the following lines to the output window:
plugin loaded
hello from the plugin
That last line means it executed the hello() function from the res://Plugin.gd script in the plugin.zip. I would expect it to use the function from the same script that is already present in the main project.
Minimal reproduction project (MRP)
This is the project to reproduce the issue. It contains a plugin.zip which is exported from a second project which is listed here as the second file. You don't need it to reproduce the issue, but it's included in case you want to re-generate plugin.zip yourself. godot-host.zip godot-plugin.zip
The text was updated successfully, but these errors were encountered:
The problem seems to be that res://Plugin.gd was never loaded from the main project, so as far as the current code is concerned there is no replacement going on. The following works the way you expect:
While I do understand it, it seems quite unintuitive to me, so either the replace_files option needs to be documented a lot better, or the behavior needs to be fixed.
Thanks for the example. I would argue it's a little more than "unintuitive" as the documentation implies that if replace_files is false that whatever files are in the main project would never be replaced. Furthermore, if I take your modified example above and make it:
func _ready():
load("res://Plugin.gd")
if ProjectSettings.load_resource_pack("res://plugin.zip", true):
print("plugin loaded")
var script := load("res://Plugin.gd")
var instance = script.new()
instance.hello()
Note that I've changed replace_files to true. In this case it still invokes the script from the main project. That being the case, what does that replace_files parameter actually do?
Hi, I think I know what causes this. Because the resource folder is treated differently from packs when running the game from the editor, replace_files can only affect files from previously loaded packs. In exported projects the resource folder is in a pack, so the problem shouldn't arise there.
I'm also working on a PR that seems to solve this problem in the editor as well according to my testing.
Tested versions
Reproducible in 4.2.1-stable.
System information
Godot v4.1.2.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1050 (NVIDIA; 31.0.15.2879) - Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz (8 Threads)
Issue description
I'm trying to load a resource pack from a zip file using
ProjectSettings.load_resource_pack()
with thereplace_files
boolean set tofalse
, but regardless the script file in the zip, which has the same name as an identical script in the main project, is being replaced.Steps to reproduce
Open and run the sample project. It prints the following lines to the output window:
That last line means it executed the
hello()
function from theres://Plugin.gd
script in the plugin.zip. I would expect it to use the function from the same script that is already present in the main project.Minimal reproduction project (MRP)
This is the project to reproduce the issue. It contains a plugin.zip which is exported from a second project which is listed here as the second file. You don't need it to reproduce the issue, but it's included in case you want to re-generate plugin.zip yourself.
godot-host.zip
godot-plugin.zip
The text was updated successfully, but these errors were encountered: