[0.17.79] util.ismoduleavailable throws when the argument is not already loaded

This subforum contains all the issues which we already resolved.
Post Reply
justarandomgeek
Filter Inserter
Filter Inserter
Posts: 300
Joined: Fri Mar 18, 2016 4:34 pm
Contact:

[0.17.79] util.ismoduleavailable throws when the argument is not already loaded

Post by justarandomgeek »

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.

Rseding91
Factorio Staff
Factorio Staff
Posts: 13175
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [0.17.79] util.ismoduleavailable throws when the argument is not already loaded

Post by Rseding91 »

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.

justarandomgeek
Filter Inserter
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

Post by justarandomgeek »

Rseding91 wrote:
Tue Nov 26, 2019 12:38 am
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.
The `mods` table isn't available in control stage. game.active_mods doesn't become available until after require stops working.

I suppose moving active_mods from game to script would also meet my needs.

Post Reply

Return to “Resolved Problems and Bugs”