chip003 / starground-modding

Github repository with a wiki and templates for modding Starground!
https://chip003.github.io/starground-modding/
MIT License
2 stars 1 forks source link

Making mods have their own folder in order to not accidently overwrite each other. #11

Open NightPotato opened 2 weeks ago

NightPotato commented 2 weeks ago

Is your feature request related to a problem? Please describe. Due top the nature of Godot and overwriting scripts if we have two mods ModA and ModB loaded. If they both contain a file called utils.gd then the last loaded script will be the contents of utils.gd.

Describe the solution you'd like We could make each mod structure be like the following image. This structure would allow us to have two utils.gd scripts. We would need to implement a method of overwriting base game resources but this could be able to be done by using the Resource.take_over_path() method built into Godot.

Godot_v4 3-stable_mono_win64_4QWSCxnldX

The full path within the runtime would be res://mod_name/ which means that the utils.gd script would be located at res://mod_name/scripts/utils.gd. Fixing the overwrite issue.

Additional context This structure can be used both in the mod project structure and implemented to the Mod Loader. This would also make having multiple mods within one godot project more efficient for the developers as we do not need to worry about the pathing in order to overwrite files. I will be commenting more about the Resource.take_over_path() method's usage shortly.

This may implement a similar issue of class_name conflicts but those could be handle by having mod developers use prefixes for class_name like class_name pd_utils extends Node. I will be looking into another change that could fix this issue as well.

mbgv commented 2 weeks ago

Blocking Resource.take_over_path() and adding an API endpoint would add more possibilities, like blocking some files from being overwritten and storing which ones were, so its possible to warn the user of mod collisions. Overall, I think this is the way to go about sandboxing mods.

NightPotato commented 2 weeks ago

If this was to get implemented then work to the inventory_component.tscn would have to be done in order for us to use the Display Override property as its currently limited to Scenes/Displays/ according to the wiki.