#How do I make this work?

151 messages · Page 1 of 1 (latest)

cerulean hull
#

I didnt think this would work and I was right 😐

let Ftypes = [MC('lily_of_the_valley'), MC('azure_bluet'), MC('oxeye_daisy'), MC('white_tulip'), MC('poppy'), MC('red_tulip'), MC('orange_tulip'), MC('dandelion'), MC('blue_orchid'), MC('cornflower'), MC('allium'), MC('pink_tulip')]

event.recipes.createMixing([Ftypes], [Ftypes, 'bone_meal'])

16:55:50] [ERR ] server_scripts:mcm_recipes.js:41: Failed to create recipe for type 'create:mixing': [minecraft:lily_of_the_valley,minecraft:azure_bluet,minecraft:oxeye_daisy,minecraft:white_tulip,minecraft:poppy,minecraft:red_tulip,minecraft:orange_tulip,minecraft:dandelion,minecraft:blue_orchid,minecraft:cornflower,minecraft:allium,minecraft:pink_tulip] is not a valid result!

sinful girderBOT
#

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

lyric bridge
#

yeah that doesnt really make sense

#
let Ftypes = [MC('lily_of_the_valley'), MC('azure_bluet'), MC('oxeye_daisy'), MC('white_tulip'), MC('poppy'), MC('red_tulip'), MC('orange_tulip'), MC('dandelion'), MC('blue_orchid'), MC('cornflower'), MC('allium'), MC('pink_tulip')]

event.recipes.createMixing(Ftypes, Ftypes.append('bone_meal'))
cerulean hull
#

Im pretty bad at js lol

candid wharf
#

you would need to do something like this

let Ftypes = [MC('lily_of_the_valley'), MC('azure_bluet'), MC('oxeye_daisy'), MC('white_tulip'), MC('poppy'), MC('red_tulip'), MC('orange_tulip'), MC('dandelion'), MC('blue_orchid'), MC('cornflower'), MC('allium'), MC('pink_tulip')]

Ftypes.forEach(flower => {
  event.recipes.createMixing([`2x ${flower}`], [flower, 'bone_meal'])
})
cerulean hull
#

I forgot to put 2x as well

#

for the output

#

thanks

candid wharf
#

you can technically also remove the MC() around you items in the list

cerulean hull
#

If I wanted to have a .withChance would It look like this?

Ftypes.forEach(flower => {
  event.recipes.createMixing([(`2x ${flower}`).withChance(0.50)], [flower, 'bone_meal'])
}```
cerulean hull
candid wharf
#

you'd need to add an Item.of. So ```js
Item.of(2x ${flower}).withChance(0.50)

cerulean hull
#

oh yeah

#

I sort of know what im doing

candid wharf
cerulean hull
#

oh

candid wharf
#

that's why you can just write bone_meal in the recipe

cerulean hull
#

I thought you needed it for a string

lyric bridge
#

you could also just

Item.of(flower, 2).withChance(0.50)
cerulean hull
#

Now I have errors :/

candid wharf
#

what does your script look like?

cerulean hull
bright timberBOT
#

Paste version of mcm_script.js from @cerulean hull

cerulean hull
#

woops wrong version

bright timberBOT
#

Paste version of mcm_recipes.js from @cerulean hull

lyric bridge
#

if you think mathematically about your 1 to 2 recipe with 50% output, it turns into bonemeal + 1 flower = 1 flower

cerulean hull
#

where?

candid wharf
#

you forgot to add the item.of. that's you're error

cerulean hull
#

I have 11 errors with my file in editing it I havent run the game yet

candid wharf
#

i forgot a closing bracket at the end after the foreach

cerulean hull
#

oh ye

#

now I have a squiggly line below the '=>'

#

says it wants a ';'

lyric bridge
candid wharf
#

if you also want to give it an id you could do: .id("mycreate:" + flower.slice(flower.indexOf(":") + 1) + "_2x"

candid wharf
lyric bridge
#

no it doesnt

#

Ftypes.forEach(flower => {

candid wharf
#

yeah

#

i just didn't see the code

lyric bridge
# cerulean hull ?

idk why you replied to my message with this, it has nothing to do with what i said thinking_hmmm_lex

cerulean hull
#

oh

lyric bridge
#

50% of 2 is 1

#

1x bone meal + 1x flower = 1x flower

#

on average

cerulean hull
#

thats why im gonna try to use a .withChance

#

and if I use that I get the 11 errors again

Ftypes.forEach(flower => {
lyric bridge
#

wha-

candid wharf
#

but 50% doesn't work

#

use something like 75%

lyric bridge
#

i dont think you understand how chance works very_sad_kitty_lex

cerulean hull
#

I've confused myself now

candid wharf
#

It gives the entire two items a 50% chance to drop. So you have a 50% chance to get nothing and a 50% chance to get 2 flowers. This adds up to 1 flower on average

cerulean hull
#

I thought is drops the two items and has a 50% chance to drop an extra 1

lyric bridge
#

no

#

you wrote 50% to drop 2 and 50% to drop nothing

#

if you want that, either change it to 75% or

[flower, Item.of(flower).withChance(0.5)]
cerulean hull
#

ohh

candid wharf
#

this will give you 1.5 multiplyer

cerulean hull
#

what will?

cerulean hull
#

oh

magic birch
#

damn math got hands?

cerulean hull
#

Is this right?

#
event.recipes.createMixing([('2x poppy'), Item.of('poppy', 1).withChance(0.50)], ['poppy', 'bone_meal'])
candid wharf
#

seems good

cerulean hull
#

yayy

lyric bridge
#

you can remove the 1

event.recipes.createMixing([('2x poppy'), Item.of('poppy').withChance(0.50)], ['poppy', 'bone_meal'])
candid wharf
#

and the brackets for the 2x poppy```js
event.recipes.createMixing(['2x poppy', Item.of('poppy').withChance(0.50)], ['poppy', 'bone_meal'])

cerulean hull
#

I still get the squiggly lines for some reason

lyric bridge
#

show me the full script

#

youre missing something

sharp mist
#

??sendcode

bright timberBOT
# sharp mist ??sendcode

Send your code here instead of a screenshot

It makes it easier to diagnose your code and help you fix it or make the required changes/additions.

sharp mist
candid wharf
#

you're still missing a closing bracket after the closing curly bracket after the forEach:

Ftypes.forEach(flower => {
  event.recipes.createMixing([`2x ${flower}`], [flower, 'bone_meal'])
})
cerulean hull
bright timberBOT
#

Paste version of mcm_recipes.js from @cerulean hull

lyric bridge
#

line 43

cerulean hull
magic birch
#

what ('2x poppy')

#

is it valid?

cerulean hull
#

ohh

lyric bridge
#

o.o

candid wharf
cerulean hull
#

I question my intelligents sometimes

sharp mist
#

intelligence* 🤓 heh

magic birch
cerulean hull
#

._.

cerulean hull
#

I now get an error for

lyric bridge
cerulean hull
#
Ftypes.forEach(flower => {
        event.recipes.createMixing([(flower, 2), Item.of(flower).withChance(0.70)], [flower, 'bone_meal'])
    })

    Ftypes2x.forEach(flower => {
        event.recipes.createMixing([(flower, 3), Item.of(flower).withChance(0.80)], [flower, 'bone_meal'])
    })
#

i ment to use shift+enter

lyric bridge
#
Ftypes.forEach(flower => {
  event.recipes.createMixing([Item.of(flower, 2), Item.of(flower).withChance(0.70)], [flower, 'bone_meal'])
})

Ftypes2x.forEach(flower => {
  event.recipes.createMixing([Item.of(flower, 3), Item.of(flower).withChance(0.80)], [flower, 'bone_meal'])
})
#

you forgot the Item.of

cerulean hull
#

I thought that you dont need that and its only for the .withChance

lyric bridge
#

theres 2 ways of having more than 1 of an item:

`10x cobblestone`
// OR
Item.of('cobblestone', 10)
cerulean hull
#

oh

lyric bridge
#

well technically theres more, but those arent used 99% of the time

cerulean hull
#

are the 10x and Item.of the easiest one too

#

ones*

lyric bridge
#

yeah those are the most common ones

cerulean hull
#

Hello again

#

I've got another problem

#

yaaayyy

#
// Flower 2x mixing recipes
    Ftypes.forEach(flower => {
        event.recipes.createMixing([Item.of(flower, 2), Item.of(flower).withChance(0.70)], [flower, 'bone_meal'])
    }).id('mycreate:flower2-3x')

    Ftypes2x.forEach(flower => {
        event.recipes.createMixing([Item.of(flower, 3), Item.of(flower).withChance(0.80)], [flower, 'bone_meal'])
    }).id('mycreate:flower3-4x')

Says iv'e got an id error on line 43 (.id('mycreate:flower2-3x)
log:
[20:15:34] [ERR ] Error occurred while handling event 'recipes': TypeError: Cannot call method "id" of undefined (server_scripts:mcm_recipes.js#43)

#

but not one on line 47

#

ive reloaded it 3 times

magic birch
#

you got some wild } bro are you using VScode?

#

oh you put id at the wrong place lmao

#

it is after the ) of the bonemeal

#

@cerulean hull

bright timberBOT
#

If you're working with KubeJS scripts, configuration files, or similar things, we generally recommend using an actual IDE rather than just Notepad and its various siblings. In a lot of cases, it can help you with finding errors in your code faster and also gives you neat features like syntax highlighting, automatic formatting, et cetera! We recommend Visual Studio Code, since it's lightweight(-ish) and works very well with JavaScript files out-of-the-box.

sharp mist
#

??basics

bright timberBOT
# sharp mist ??basics

To create KubeJS scripts, you'll need:

  • a proper code editor,
  • some programming (more specifically, javascript) knowledge,
  • common sense.
sharp mist
cerulean hull
cerulean hull
bright timberBOT
humble heath
# cerulean hull Thanks

Also iirc, u need unique IDs per recipe... So using the same one for all isn't going to work either

mighty slate
#

Me with

.forEach(.id(`modid:custom_${insert}_recipe`))
#
let AUT = [
    'maple_log',
    'maple_wood'
]
// let ATMO = ['atmospheric:stripped']
onEvent('recipes', event => {
    AUT.forEach(insert => {
        event.recipes.createItemApplication('create:andesite_casing', [`autumnity:stripped_${insert}`, 'create:andesite_alloy']).id(`finality:andesite_casing_${insert}_autumnity`)
        event.recipes.createItemApplication('create:copper_casing', [`autumnity:stripped_${insert}`, 'minecraft:copper_ingot']).id(`finality:copper_casing_${insert}_autumnity`)
        event.recipes.createItemApplication('create:brass_casing', [`autumnity:stripped_${insert}`, 'create:brass_ingot']).id(`finality:brass_casing_${insert}_autumnity`)
    })
})

Just as an example because TeamAbnormals didn't tag their logs correctly and I don't want to bother with tags at the moment

#

I didn't see this was tagged with 1.18, so I changed the above script from my modpack accordingly

mighty slate
#

Lemme just write the recipe for him facepalm

#

I should really read previous message history

#
let Ftypes = {
    white_dye: 'lily_of_the_valley',
    light_gray_dye: 'azure_bluet',
    light_gray_dye: 'oxeye_daisy',
    light_gray_dye: 'white_tulip',
    red_dye: 'poppy',
    red_dye: 'red_tulip',
    orange_dye: 'orange_tulip',
    yellow_dye: 'dandelion',
    light_blue_dye: 'blue_orchid',
    blue_dye: 'cornflower',
    magenta_dye: 'allium',
    pink_dye: 'pink_tulip'
}
// Recipes
onEvent('recipes', event => {
    event.remove({id:'create:filling/redstone'})
    Object.keys(Ftypes).forEach(flower => {
        event.recipes.createCompacting([
            `minecraft:${flower}`
        ], [
            `minecraft:${Ftypes[flower]}`
        ]).id(`mycreate:${Ftypes[flower]}_dye_processing`)
    })
})

Hopefully I didn't make the same mistake I made the other time I used this method

#

That's basically the whole chunk of your createCompacting recipes compressed into a single line

As for the recipes that output 2x of a dye... (still writing it)

#

Also going to put the heated recipes in

#

Another thing, sea pickles actually output Lime Dye in base Create, with a 10% chance of giving green dye

#

Buut here's your very compact recipe setup:

let Ftypes = {
    white_dye: 'lily_of_the_valley',
    light_gray_dye: 'azure_bluet',
    light_gray_dye: 'oxeye_daisy',
    light_gray_dye: 'white_tulip',
    red_dye: 'poppy',
    red_dye: 'red_tulip',
    orange_dye: 'orange_tulip',
    yellow_dye: 'dandelion',
    light_blue_dye: 'blue_orchid',
    blue_dye: 'cornflower',
    magenta_dye: 'allium',
    pink_dye: 'pink_tulip'
}
let Ftypes2x = {
    red_dye: 'rose_bush',
    yellow_dye: 'sunflower',
    magenta_dye: 'lilac',
    pink_dye: 'peony'
}
let FtypesHTD = {
    green_dye:'cactus',
}
// Recipes
// Separating the blocks from each other so it's easier to differentiate
onEvent('recipes', event => {
    event.remove({id:'create:filling/redstone'})

    Object.keys(Ftypes).forEach(flower => {
        event.recipes.createCompacting([
            `minecraft:${flower}`
        ], [
            `minecraft:${Ftypes[flower]}`
        ]).id(`mycreate:${Ftypes[flower]}_dye_processing`)
    })

    Object.keys(Ftypes2x).forEach(doubleFlower => {
        event.recipes.createCompacting([
            `2x minecraft:${doubleFlower}`
        ], [
            `minecraft:${Ftypes2x[doubleFlower]}`
        ]).id(`mycreate:${Ftypes2x[doubleFlower]}_dye_processing`)
    })

    Object.keys(FtypesHTD).forEach(heated => {
        event.recipes.createCompacting([
            `minecraft:${heated}`
        ], [
            `minecraft:${FtypesHTD[heated]}`
        ]).id(`mycreate:${FtypesHTD[heated]}_dye_processing`)
    })

    event.recipes.createCompacting([
        'minecraft:lime_dye',
        Item.of('minecraft:green_dye').withChance(0.10)
    ], [
        'minecraft:sea_pickle'
    ]).heated().id('mycreate:sea_pickle_dye_processing')
})

Hopefully I didn't miss any typos I made
Although I do notice you have other recipes that use the same list and use createMixing with different outputs, so you're free to use another list name or rename the ones I set

mighty slate
#

It's become a bit too large to keep in a single Discord message, but there's a lot less repeating and automatic recipeID generation

And please tell me if it errors in-game, I probably missed something somewhere

bright timberBOT
#

Paste version of LazerGamer90_Script.js from @mighty slate

cerulean hull
#

Hello, sorry I can't reply as I'm on holiday finally. But I have looked at the file and I'll test it with my modpack as soon as I can