I'm still very new to JavaScript as a whole so this could be me misunderstanding stuff but I'm trying to create a function to help me make recipes for recipetypes without explicit KJS support, but I keep getting errors and I got no clue why.
//in lib/recipe_types/extended_mushrooms.js
function ExtendedMushroomsRecipes() {}
ExtendedMushroomsRecipes.prototype = {
fairy_ring: (inputs, output, time) => {
let ingredients = []
for(let i = 0; i < inputs.length; i++) {
ingredients[i] = inputs[i].toJson()
}
return {
type: 'extendedmushrooms:fairy_ring_recipe',
ingredients: ingredients,
result: output.toJson(),
recipeTime: time
}
}
}
//in recipes/hexerei.js
ServerEvents.recipes(event => {
event.custom(global.extendedmushrooms.fairy_ring(['hexerei:mandrake_flowers', 'hexerei:mandrake_root', 'hexerei:mandrake_flowers', 'hexerei:mandrake_root'], 'hexerei:mandrake_flower', 200))
})
//in constants.js
global.extendedmushrooms = ExtendedMushroomsRecipes()
errors:
[13:16:20] [ERROR] ! #294: Error loading KubeJS script: server_scripts:constants.js': ReferenceError: "ExtendedMushroomsRecipes" is not defined. (server_scripts:constants.js#294)
[13:16:32] [ERROR] ! #4: Error occurred while handling event 'ServerEvents.recipes': TypeError: Cannot call method "fairy_ring" of undefined (server_scripts:recipes/hexerei.js#4)

