Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate Mod Scripts Causing Errors #15

Open
valkyrienyanko opened this issue Jun 27, 2024 · 0 comments
Open

Duplicate Mod Scripts Causing Errors #15

valkyrienyanko opened this issue Jun 27, 2024 · 0 comments
Labels
bug Something isn't working topic: mod loader

Comments

@valkyrienyanko
Copy link
Contributor

valkyrienyanko commented Jun 27, 2024

Description

When creating duplicate mods with identical script names, errors occur during runtime. This issue affects both C# and GDScript mods.

Steps to Reproduce

  1. Duplicate the res://Mods/Example Mod directory to res://Mods/Example Mod 2.
  2. Modify the id in the mod.json of the new mod from example_mod to example_mod_2.
  3. Run the game.

Expected Behavior

Both mods should load and execute without errors, printing unique greetings.

Actual Behavior

C# Mods

  • First Kind of Error:

    An item with the same key has already been added. Key: res://valkyrienyanko/example_mod/Mod.cs
    
  • Second Kind of Error:

    Assembly with same name is already loaded
    

GDScript Mods

  • Console Output:
    Loading C:/Users/VALK-DESKTOP/Documents/_Godot Projects/Template/GodotProject/Mods/Example Mod/mod.pck for example_mod
    Loading C:/Users/VALK-DESKTOP/Documents/_Godot Projects/Template/GodotProject/Mods/example_mod_2/mod.pck for example_mod_2
    Hello from Mod 1
    Hello from Mod 1
    
    • Expected: Hello from Mod 1 and Hello from Mod 2
    • Actual: Hello from Mod 1 printed twice

Observations

  • C# scripts with the same name in different mods cause errors.
  • GDScript mods with the same script names also exhibit unexpected behavior.

Proposed Solutions

  1. Switch to GDScript for Mods:

    • If GDScript does not have the same naming conflict issues, consider using GDScript for modding.
  2. Refactor C# Mod Loading:

    • Modify the mod loading logic to search for the first DLL file in the mod folder and load it. This might resolve DLL naming conflicts.

Additional Notes

Conclusion

The current mod loading mechanism needs to be revised to handle duplicate script names across different mods effectively. Switching to GDScript or refactoring the C# mod loading process are potential solutions to address this issue.

@valkyrienyanko valkyrienyanko changed the title [Mod Loader] System.ArgumentException: An item with the same key has already been added. Key: res://Mod.cs Mod Loader can't handle two mods with two scripts in the same location Jun 27, 2024
@valkyrienyanko valkyrienyanko changed the title Mod Loader can't handle two mods with two scripts in the same location [Mod Loader] Can't handle two mods with two scripts in the same location Aug 4, 2024
@valkyrienyanko valkyrienyanko added bug Something isn't working poorly documented and removed help wanted labels Aug 6, 2024
@valkyrienyanko valkyrienyanko changed the title [Mod Loader] Can't handle two mods with two scripts in the same location [Mod Loader] Can't handle two mods with two scripts with the same script name Aug 6, 2024
@valkyrienyanko valkyrienyanko changed the title [Mod Loader] Can't handle two mods with two scripts with the same script name [Mod Loader] Two mods each having a script with the same name causes errors Aug 7, 2024
@valkyrienyanko valkyrienyanko changed the title [Mod Loader] Two mods each having a script with the same name causes errors Two mods each having a script with the same name causes errors Aug 22, 2024
@valkyrienyanko valkyrienyanko changed the title Two mods each having a script with the same name causes errors Duplicate Mod Scripts Causing Errors Sep 2, 2024
@valkyrienyanko valkyrienyanko changed the title Duplicate Mod Scripts Causing Errors [Mod Loader] Duplicate Mod Scripts Causing Errors Sep 11, 2024
@valkyrienyanko valkyrienyanko changed the title [Mod Loader] Duplicate Mod Scripts Causing Errors Duplicate Mod Scripts Causing Errors Sep 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working topic: mod loader
Projects
None yet
Development

No branches or pull requests

1 participant