GodotModding / GodotModding/godot-mod-loader
automatically refresh scenes if their script is extended
- Dominant language
- GDScript
- Stars
- 675
- Forks
- 54
- Avg merge
- 2m
- Merged PRs (30d)
- 2
Description
@torcado194 found a clever solution to find the matching script to a scene - just enforce a convention.
Yes some people have different conventions or don't like them at all. In those cases they can either edit the mod loader to use that convention (like searching in a separate scripts folder), or modders will just go back to the old method of manually refreshing them.
last 3 lines are the additions to `script_extension.gd`.
```gdscript
child_script.reload()
var parent_script: Script = child_script.get_base_script()
var parent_script_path: String = parent_script.resource_path
var parent_scene: String = parent_script_path.get_basename() + ".tscn"
if ResourceLoader.exists(parent_scene):
ModLoaderMod.refresh_scene(parent_scene)
```
Since we are looking for a tscn here, FileAccess does not do the job in exported games, as noted by the docs.
Contributor guide
Assessment
This issue has not been assessed yet.