Skip to content

Conversation

@Andrettin
Copy link
Contributor

When checking which unpacked mods are present, DevilutionX checks to see if an init.lua file is present within that mod's folder. However, when actually loading the unpacked mod, the code instead tries to load init.lua from [mod folder]/lua/mods/[mod name]/init.lua, which then fails.

This PR fixes that, by allowing the init.lua file to be loaded if it is present directly in the mod folder as well.

@AJenbo
Copy link
Member

AJenbo commented Aug 12, 2025

[mod folder]/lua/mods/[mod name]/init.lua should be the right path, I don't think it should be checking both paths (it should be possible to pack or unpack a mod without needing to change anything, and there should only be one correct path)

@Andrettin
Copy link
Contributor Author

Andrettin commented Aug 12, 2025

[mod folder]/lua/mods/[mod name]/init.lua should be the right path, I don't think it should be checking both paths (it should be possible to pack or unpack a mod without needing to change anything, and there should only be one correct path)

Does repeating the mod name provide any benefit? Right now we need to have the init.lua file in something like:
"AppData/roaming/diasurgical/devilution/mods/Middle-Earth/lua/mods/Middle Earth/init.lua".

If this is really what is desired, I guess it would be better if I changed the check for the init.lua file for mods in options.cpp instead? Since it checks for e.g. "AppData/roaming/diasurgical/devilution/mods/Middle-Earth/init.lua" ATM:

			std::string modScriptPath = modsPath + DIRECTORY_SEPARATOR_STR + modFolder + DIRECTORY_SEPARATOR_STR + "init.lua";

@Andrettin
Copy link
Contributor Author

Ah, I think I understand. Without repeating the mod's name, you wouldn't be able to have a packed mod with the same folder structure and at the same time also load every mod's init.lua. I'll rework the PR to change the unpacked-mod-finding code to take that into account, so that we don't need a dummy init.lua directly in the mod's folder.

@Andrettin Andrettin force-pushed the Unpacked-Mod-init.lua-Loading-Fix branch from 8d84e5b to cb8f359 Compare August 12, 2025 19:07
@Andrettin
Copy link
Contributor Author

@AJenbo PR rework done :)

The clang-tidy-check workflow failed, but this seems to be completely unrelated to the PR, since it mentions API rate limits being exceeded:

ERROR:CPP Linter:response returned 403 from GET https://api.github.com/repos/diasurgical/DevilutionX/pulls/8108 with message: {"message":"API rate limit exceeded for 52.173.178.210. (But here's the good news: Authenticated requests get a higher rate limit. Check out the documentation for more details.)","documentation_url":"https://docs.github.com/rest/overview/resources-in-the-rest-api#rate-limiting"}

@AJenbo AJenbo merged commit 07c89a0 into diasurgical:master Aug 12, 2025
23 of 24 checks passed
@AJenbo
Copy link
Member

AJenbo commented Aug 12, 2025

I have a pr for fixing some of the Clan tidy issues if you want to try your hand at reviewing 🙂

@Andrettin
Copy link
Contributor Author

I have a pr for fixing some of the Clan tidy issues if you want to try your hand at reviewing 🙂

Yes, I would be happy to :)

@Andrettin Andrettin deleted the Unpacked-Mod-init.lua-Loading-Fix branch August 13, 2025 07:24
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.

2 participants