#How to detect whether a mod exists in the mod loader before continuing with a script

17 messages · Page 1 of 1 (latest)

thorn finch
#

Basically, I have some recipe changes and events that run with the contents of a mod. However, I'm planning on removing said mod from my modpack, but don't want the code to go to waste in the case that a player decides to add the mod to the modpack. Is there a method that detects whether a mod exists in the mod loader, and if so, continues with the script code?

vestal stoneBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

lyric parrot
#

Platform.isLoaded('mod')

thorn finch
#

ah thank you! I'll have to give this a test tomorrow

#

mod would be the mod's namespace, correct?

twilit forge
#

Should be iirc

lyric parrot
#

And then you Just Put that inside an If statement

#

You can also use comments at the top of the File to only make the File load If that Mod is pressnt
It's
// mod: mod_namespace iirc, but could be wrong

thorn finch
#
// mod: iceandfire

console.log('Ice and Fire: Dragons is loaded')
#
console.log('Neapolitan loaded: ' + Platform.isLoaded('neapolitan')) // Should log true
console.log('Ice and Fire: Dragons loaded: ' + Platform.isLoaded('iceandfire')) // Should log false
#

the method works fine in my favor though

#

thank you!

lyric parrot
thorn finch
#

oh cool it worked!

#

thank you!