GodotModding / GodotModding/godot-mod-loader

automatically refresh scenes if their script is extended

Open
#386 2 comments 0 reactions 0 assignees View on GitHub
4.x enhancement
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.