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
When you create a GDScript object, set the source, and then call reload it generates the following error:
ERROR: Attempt to open script '' resulted in error 'File not found'.
at: load_source_code (modules/gdscript/gdscript.cpp:1064)
Steps to reproduce
This script creates a simple GDScript from a string of source code, creates an instance and calls a method on it.
extends SceneTree
func _init():
var script_source = '' + \
"func hello_world():\n" + \
"\tprint('--- hello world ---')"
print(script_source)
var DynScript = GDScript.new()
DynScript.source_code = script_source
print('pre-reload')
DynScript.reload()
print('post-reload')
var inst = DynScript.new()
inst.hello_world()
quit()
The output shows the error occurs on the reload call.
Godot Engine v4.0.alpha15.official.432b25d36 - https://godotengine.org
Vulkan API 1.1.216 - Using Vulkan Device #0: AMD - AMD Radeon Pro 450
Registered camera FaceTime HD Camera (Built-in) with id 1 position 0 at index 0
func hello_world():
print('--- hello world ---')
pre-reload
ERROR: Attempt to open script '' resulted in error 'File not found'.
at: load_source_code (modules/gdscript/gdscript.cpp:1064)
post-reload
--- hello world ---
Minimal reproduction project
See steps to reproduce
The text was updated successfully, but these errors were encountered:
With the resource_path trick I was able to get rid of all the error messages with this workaround. It's gross, but there's no more red error messages in my output now.
var_created_script_count=0funccreate_script_from_source(source):
_created_script_count+=1varDynamicScript=GDScript.new()
DynamicScript.source_code=source# The resource_path must be unique or Godot thinks it is trying# to load something it has already loaded and generates an error like# ERROR: Another resource is loaded from path 'workaround for godot issue #65263' (possible cyclic resource inclusion).DynamicScript.resource_path=str('workaround for godot issue #65263 (', _created_script_count, ')')
varresult=DynamicScript.reload()
returnDynamicScript
I added a check in my PR to not (re)load source code if the path is empty. I needed to do this to handle empty paths with my fix for cyclic references purposes, but it should fix your issue as well.
Godot version
v4.0.alpha15.official.432b25d36
System information
OSX 10.15.7
Issue description
When you create a GDScript object, set the source, and then call
reload
it generates the following error:Steps to reproduce
This script creates a simple GDScript from a string of source code, creates an instance and calls a method on it.
The output shows the error occurs on the
reload
call.Minimal reproduction project
See steps to reproduce
The text was updated successfully, but these errors were encountered: