#how to detect if a mod is installed

25 messages · Page 1 of 1 (latest)

snow canopy
#

I've already seen a post with the answer but im unsure how to use it in a if statement, it either returns an error or skips all my recipes even though the mod is installed.

rancid heronBOT
#

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

icy depot
#
if (Platform.isLoaded('mod')) {
  // the rest of the owl
}
gusty pilot
#

Wait what do you mean 'where'

#

Mods can only be in the mods folder

#

Or bundled in other mods

snow canopy
#

i mean detect if a mod is installed

gusty pilot
#

Ah

snow canopy
#

how to detect if a mod is installed

icy depot
#

with 1.19 you can also do it in the header of the file
if you start your js file with

//requires: mod

it'll only run that whole file if the mod is installed

#

lexxie that might be a good slash command? This post by chief

vivid condorBOT
#

[Quote ➤](#archived-example-scripts message) In 1.19.2 you can use various comments at the top of a script to change its load conditions.
For example: ```js
//ignored: true
console.log("I am never printed")

```js
//packmode: default
console.log('I will only print when packmode in kubejs/config/common.properties is set to default')
//requires: minecraft
//requires: create
console.log('I will only print when mods with ids of minecraft AND create are loaded')

You can stack these too, like so

//priority: 10
//packmode: hard
//requires: create
//requires: tconstruct
console.log('I am complicated!')
gusty pilot
#

Will do soon, not at the pc

snow canopy
#

for the if statement i get this error Error occurred while handling event 'ServerEvents.recipes': Java class "dev.latvian.mods.kubejs.script.PlatformWrapper" has no public instance field or method named "isloaded".

gusty pilot
#

Capital L

icy depot
#

looks like a lowercase L in your error

#

case is very important

snow canopy
#

now it seems to have affected my variable inside the if statement and i get this error (i suck at coding)
Error occurred while handling event 'ServerEvents.recipes': TypeError: redeclaration of var compacting.

gusty pilot
#

now im here

icy depot
#

just show your code?

gusty pilot
#

link the post i mean

icy depot
#

that's your domain 😄

snow canopy
#

    if (Platform.isLoaded('thermal')) {

        const compacting = (modname, name, isIngot) => {
            if (isIngot) {
                event.recipes.createCompacting(`thermal:${name}_gear`, [
                    `${modname}:${name}_ingot`,
                    `${modname}:${name}_ingot`,
                    `${modname}:${name}_ingot`,
                    `${modname}:${name}_ingot`
                ])
            }
            else {
                event.recipes.createCompacting(`thermal:${name}_gear`, [
                    `${modname}:${name}`,
                    `${modname}:${name}`,
                    `${modname}:${name}`,
                    `${modname}:${name}`
                ])
            }
        }
        event.recipes.createCompacting(`thermal:lapis_gear`, [
            'minecraft:lapis_lazuli',
            'minecraft:lapis_lazuli',
            'minecraft:lapis_lazuli',
            'minecraft:lapis_lazuli'
        ])

        compacting('minecraft', 'iron', true)
        compacting('minecraft', 'gold', true)
        compacting('minecraft', 'copper', true)
        compacting('minecraft', 'netherite', true)
        compacting('minecraft', 'diamond', false)
        compacting('minecraft', 'emerald', false)
        compacting('minecraft', 'quartz', false)
        compacting('thermal', 'signalum', true)
        compacting('thermal', 'lumium', true)
        compacting('thermal', 'enderium', true)
        compacting('thermal', 'tin', true)
        compacting('thermal', 'nickel', true)
        compacting('thermal', 'lead', true)
        compacting('thermal', 'silver', true)
        compacting('thermal', 'bronze', true)
        compacting('thermal', 'electrum', true)
        compacting('thermal', 'invar', true)
        compacting('thermal', 'constantan', true)

    }
})```
gusty pilot
#

/headers FA_MewPeek