Skip to content

[FEATURE] Add the ability to merge scripts using _merge #364

Open
KoloInDaCrib wants to merge 1 commit intoFunkinCrew:experimentalfrom
KoloInDaCrib:script-merging-but-not-unc-status
Open

[FEATURE] Add the ability to merge scripts using _merge #364
KoloInDaCrib wants to merge 1 commit intoFunkinCrew:experimentalfrom
KoloInDaCrib:script-merging-but-not-unc-status

Conversation

@KoloInDaCrib
Copy link

Basically just a rework of #236 but with features that were included with the recent polymod updates and without a potential for a horrible merge conflict :obese_cat:

This time I've summed up the system in a coolbool article that I'm planning to push to the repo when this gets merged.

@TechnikTil
Copy link

we are so back

@TechnikTil
Copy link

you know you couldve just force pushed the rewrite right

@KoloInDaCrib
Copy link
Author

you know you couldve just force pushed the rewrite right

:Perhaps:

@EliteMasterEric
Copy link
Member

I'm curious how this is different/better than the existing PolyMixin library, which seems to provide more precise injection while also not even requiring changes to Polymod: https://starexify.github.io/BadDocs/src/polymixin.html#injection-params

@Starexify
Copy link

Starexify commented Mar 3, 2026

I'm curious how this is different/better than the existing PolyMixin library, which seems to provide more precise injection while also not even requiring changes to Polymod: https://starexify.github.io/BadDocs/src/polymixin.html#injection-params

Well while working on PolyMixin I encountered some challenges, one is that it only works because of V-Slice (the base game) since it caches the AST of scripts into the ModuleHandler and other Registry classes like NoteKindsRegistry and such. Now this COULD potentially be done better if access to all parsed AST scripted classes/enums etc is given by the game or polymod itself (not yet sure if polymod caches all of them somewhere in form of AST or not, I didn't dive that deep).

Now on this PR, it does provide some way of doing mixins similarly to my library in form of merging which is what PolyMixin lacks because of what I stated above about limitations with cache. And for me it looks like it has potential to be expanded in the future with more features like PolyMixin if needed. It might also be better for modders to use the builtin polymod mixin capabilities provided by this PR rather than downloading a library like PolyMixin which indeed provides more functionality (at the moment) for mixins but isn't perfected and again has limitations.

So personally I would either expand on this PR after being merged with more functionality similar to PolyMixins, or if not, then polymod (or the game) could provide some kind of postParse event to allow any mod to inject into the parsed AST directly before all scripts are loaded, which would make it easier and better to mixin via mods. Because PolyMixin is limited to and by V-Slice as of now.

On a personal note, I would change the meta naming, so instead of @:merge_insert(index) to use @Inject(ordinal = i) but that is because I prefer the SpongePowered/Java style. But this can be discussed later best.

If there are any other questions about this, I'll be glad to answer.

@KoloInDaCrib KoloInDaCrib force-pushed the script-merging-but-not-unc-status branch from e4ea28c to e646510 Compare March 4, 2026 04:51
@AbnormalPoof AbnormalPoof force-pushed the script-merging-but-not-unc-status branch from e646510 to 73c5fd8 Compare March 8, 2026 04:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants