Comments (10)
I successfully tested this with Brotato-Explosion-Mute, by allowing file replacement.
The complexity to achieve the desired result is greatly reduced.
from godot-mod-loader.
From my reply on Discord:
What about a separate folder? Eg
mods-overrides
. That way it'd give them a standardised structure and would make it clear when a mod is overriding something in vanilla
Then we could justrun _load_mod_zips
twice, with the second call being passed an arg that says to use the "overrides" folder and usetrue
forload_resource_pack
from godot-mod-loader.
Darkly77 - Another use case for replacements: You could do stuff like make a balance pack for Brotato. Eg people often say Plank is weak, so someone could release a mod that improves its scaling by replacing the vanilla file.
from godot-mod-loader.
From my reply on Discord:
What about a separate folder? Eg
mods-overrides
. That way it'd give them a standardised structure and would make it clear when a mod is overriding something in vanilla
Then we could justrun _load_mod_zips
twice, with the second call being passed an arg that says to use the "overrides" folder and usetrue
forload_resource_pack
Now that I'm working on it - we can't do a separate folder because the only way to overwrite is to mirror the file paths inside the mod zip.
yourmod.zip
├───.import
└───mods-unpacked
└───Author-ModName
├───mod_main.gd
└───manifest.json
└───projectiles
└───rocket
└───explosion.png
There is also no point in adding something like "is_overwrite": true
to the manifest.json That is loaded after we need to set the replace flag for ProjectSettings.load_resource_pack()
So the only way to send data in this stage to the mod loader is the name of the zip file?
That would mean we can't use arbitrary zip names any more.
from godot-mod-loader.
(my input from Discord:)
Hey, I've been looking into this too! I realised that allowing full overrides would mean we're loading stuff from mod ZIPs before we get a chance to read their meta data.
That means a mod could be published that doesn't even have a manifest.
So my approach is to simply replace resources from within mod_main. That ensures mods stay within our current standards
EDIT: Loading directly from the ZIP would also mean wouldn't be able to do validation stuff, like check dependencies etc, as we'd be loading in modded content before the manifest was ready.
from godot-mod-loader.
Example mod with my approach. Changes the color of the logo. Has 3 different colors, the last one mentioned in the code is the one that gets used.
mod_main.gd:
extends Node
func _init(modLoader = ModLoader):
var new_logo = preload("res://mods-unpacked/Darkly77-LogoReplacement/overrides/ui/menus/title_screen/ui_logo__blue.png")
new_logo.take_over_path("res://ui/menus/title_screen/ui_logo.png")
Download:
- Darkly77-LogoReplacement--ML-3.1.0.zip -- (compatible with ML v3.1.0)
Screenshot:
from godot-mod-loader.
🇦 ) Mod Loader Handling - Restart game once ( if a overwrite mod is added / removed )
Details
- Creating an
overwrites.gd
inside the mod loader can work - By checking for an
overwrites
folder at the root of each mod folder - If detected it gets all files inside the
overwrites
and appends the required code to theoverwrites.gd
file
var overwrite_index = preload("res://mods-unpacked/ModAuthor-ModName/overrides/path/to/overwrite/resource")
overwrite_index.take_over_path("res://path/to/original/resource")
-
That
overwrites.gd
script gets initialized at the end of the mod loaders_init()
function -
Problem with this solution, is that the
overwrites.gd
file is created on the first run of the game.
To Allow the replacement resources to be preloaded the file needs to exist before the start.
That's why a game restart is required. -
Currently a game can only be closed via script not restarted, this will most likely change in Godot 3.6:
godotengine/godot#66168
🇧 ) Let mod authors create the overwrites.gd
at the root of the mod folder
Details
- My current proposed solution on how to handle the overwrites
- Mod authors create the
overwrites.gd
script andoverwrites
folder in there mod folder:
- We provide tooling to make the creation of the
overwrites.gd
script a one click thing - People ho don't want to use extra tooling can just write the
overwrites.gd
them self
Example Mod with this setup:
KANA-OverwritesTest.zip
Testing Godot Project
ModdingTest.zip
🇨 ) use --script run.gd
Details
- Using the
--script
cmd arg to run a script before the game starts - Not tested, because with that setup we will need to unzip the mods in the
run.gd
- And we want to get rid of it anyway
from godot-mod-loader.
Just to reference it here as well:
There is also the possibility to reload a scene with a new PackedScene
.
-
For that I used
get_tree().change_scene_to(PackedScene)
in a script extension of the scene that is the owner of the overwritten resource. -
That allows to use just
load()
to load the replacement resource -
load()
can take variable resource paths -
That potentially allows to add a util function to the mod loader for mod authors to use
-
I didn't explorer this further because the
preload()
solution currently seems way cleaner and doesn't require to reload / replace in a scenes_ready()
function.
Example Brotato Mod of this solution:
Darkly77-LogoReplacementSceneReloading.zip
from godot-mod-loader.
closed by #74
from godot-mod-loader.
Darkly77 - Another use case for replacements: You could do stuff like make a balance pack for Brotato [...]
I've found that replacing files can be a bad idea because it can mess up extended scripts.
I was trying a few things with the file character_selection.tscn, and after replacing it I found that the extended scripts for character_selection.gd (which is referenced in character_selection.tscn) no longer worked. Replacing .tres files likely has the same negative effect, where any .gd scripts that are referenced in that .tres file will ignore their extensions.
This needs further testing though.
from godot-mod-loader.
Related Issues (20)
- 🚀 Contributors - Getting Started 🚀
- [4.x] Duplicating a global named script class (i.e. in `script_extension.gd`) causes an error. HOT 7
- autoload position check only uses `current_options`
- Possible memory leak with script extensions HOT 1
- `load_before` should allow setting the same mod as `optional_dependency` or `dependency`
- add a nice way for mods to check if another mod is in use (loaded and active)
- latest build kinda doesen't work with self-setup guide HOT 4
- Add a ziped version of the loader to releases that can be used for self-setup. HOT 1
- Update Example Mods HOT 1
- User Profiles - mod dependency handling HOT 1
- Self setup missing classes crash HOT 1
- Extending scripts attached to a preloaded scene HOT 1
- Load extensions and overwrites from directory HOT 2
- edit / extend custom resource
- Delete `steam_workshop_enabled` from options
- automatically refresh scenes if their script is extended HOT 2
- remove unused `unpacked_dir` from `InheritanceSorting`
- Add `steam_workshop_id` to mod manifest HOT 1
- Add the possibility to include a default/preset profile HOT 1
- Enable the extending of existing extensions existing in a dependency HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from godot-mod-loader.