It looks like this was intended in the past to solve the problem of "require these files if they are available", but fell out of use in favor of the is_demo flag, and then was unnoticed when `package` was stripped. It now throws a scripterror when it attempts to use `package.searchers or package.loaders`, which happens for anything not already loaded.
I currently solve this problem with cross-mod requires using `pcall(require,"__modname__/filename.lua")`, but if this function worked I could simply test first and get rid of the pcall.
[0.17.79] util.ismoduleavailable throws when the argument is not already loaded
-
- Filter Inserter
- Posts: 300
- Joined: Fri Mar 18, 2016 4:34 pm
- Contact:
Re: [0.17.79] util.ismoduleavailable throws when the argument is not already loaded
Thanks for report. I deleted the function since it's no longer valid anyway. You can check if a mod exists by checking "if mods[name]" before doing the require. If you don't know if the file exists even if the mod exists I question why anyone would want to write that code.
If you want to get ahold of me I'm almost always on Discord.
-
- Filter Inserter
- Posts: 300
- Joined: Fri Mar 18, 2016 4:34 pm
- Contact:
Re: [0.17.79] util.ismoduleavailable throws when the argument is not already loaded
The `mods` table isn't available in control stage. game.active_mods doesn't become available until after require stops working.Rseding91 wrote: ↑Tue Nov 26, 2019 12:38 amThanks for report. I deleted the function since it's no longer valid anyway. You can check if a mod exists by checking "if mods[name]" before doing the require. If you don't know if the file exists even if the mod exists I question why anyone would want to write that code.
I suppose moving active_mods from game to script would also meet my needs.