#How to modify recipes to use the cleanroom?

41 messages · Page 1 of 1 (latest)

narrow nacelle
#

I have a list of recipe ids, where i'd like them to use the cleanroom.
Unfortunately i cant seem to figure it out. Have been trying to make something akin to this example, but nothing seems to be working.

ServerEvents.recipes(event => {

    var recipesd = [
    'gtceu:circuit_assembler/integrated_circuit_hv',
    'gtceu:circuit_assembler/integrated_circuit_hv_soldering_alloy',
    'gtceu:circuit_assembler/integrated_circuit_lv',
    'gtceu:circuit_assembler/integrated_circuit_lv_soldering_alloy',
    'gtceu:circuit_assembler/microprocessor_lv',
    'gtceu:circuit_assembler/microprocessor_lv_soldering_alloy',
    'gtceu:circuit_assembler/nand_chip_ulv_good_board',
    'gtceu:circuit_assembler/nand_chip_ulv_good_board_soldering_alloy',
    'gtceu:circuit_assembler/nand_chip_ulv_plastic_board',
    'gtceu:circuit_assembler/nand_chip_ulv_plastic_board_soldering_alloy',
    'gtceu:circuit_assembler/processor_assembly_hv',
    'gtceu:circuit_assembler/processor_assembly_hv_soldering_alloy',
    'gtceu:circuit_assembler/processor_mv',
    'gtceu:circuit_assembler/processor_mv_soldering_alloy'
    ];
    event.forEachRecipe({ type: 'gtceu:circuit_assembler' }, recipe => {
            console.log(toString(recipe.get('recipeConditions'))); // just prints [Object object] and cant use deepToString cause its undefined for some reason :?
    });
});```
loud ruin
#

hmm

#

you can make a function that copies the recipe over

#

im trying to see how to get a specific recipe

#

lemmec

#
e.forEachRecipe({ type: "gtceu:mixer" }, recipe => {
        let r = JSON.parse(recipe.json)
        if (r.inputs.fluid) { return }

        let EUt = (r.tickInputs && r.tickInputs.eu) ? r.tickInputs.eu[0].content : null
        if (!(EUt <= 8)) { //Reject recipes that cost more than 8 eu/t, check is done like this to filter out null
            return
        }

        let outputs = r.outputs.item

        let toInput = []

        r.inputs.item.forEach(items => {
            if (items.content.type == "gtceu:circuit") { return }

            let curCount = items.content.count
            let curItem = Ingredient.of(items.content.ingredient)

            toInput.push(Item.of(curItem, curCount))
        })

        let toOutput = Item.of(Ingredient.of(outputs[0].content.ingredient), outputs[0].content.count)

        e.recipes.gtceu.steam_mixer_recipes(`kubejs:gtceu/steam_mixer/${recipe.getId().split(':')[1]}`)
            .itemInputs(toInput)
            .itemOutputs(toOutput)
            .outputFluids()
            .duration(r.duration)
            .EUt(EUt)
    })```


```js
ServerEvents.recipes(event => {
    event.forEachRecipe({ mod: 'gtceu' }, recipe => { // 
        try { // 
            var newDuration = recipe.get("duration") // 
            recipe.set("duration", newDuration/10) // 
        } catch (err) { // 
            console.log(recipe.id + " has no duration field, skipped.")
        }
    })
})```
#

both of these do similar things looping through and changing something

#

Oo idea

#

ok bad news its more difficult than I thought

#

the cleanroom data isnt stored in the json

#

im unsure how to even get the current recipes conditions youd just have to overwrite it

#

workin on it

loud ruin
#

progress ish

#

ok I have it nearly entirely working, only problem is it isnt copying tags over

#

working now

#

here it is

#

nvm im messing w it more

#

alr im done optimizing ICANT

#

@narrow nacelle

#

nvm I fucked it up

#

oh ik how

#
ServerEvents.recipes(e => {
    var recipesToCleanroom = [
        { id: /gtceu:circuit_assembler\/integrated_circuit_hv.*/ },
        { id: /gtceu:circuit_assembler\/integrated_circuit_lv.*/ },
        { id: /gtceu:circuit_assembler\/microprocessor_lv.*/ },
        { id: /gtceu:circuit_assembler\/nand_chip_ulv_good_board.*/ },
        { id: /gtceu:circuit_assembler\/nand_chip_ulv_plastic_board.*/ },
        { id: /gtceu:circuit_assembler\/processor_assembly_hv.*/ },
        { id: /gtceu:circuit_assembler\/processor_mv.*/ },
    ]

    recipesToCleanroom.forEach((recipeToClean) => {
        e.forEachRecipe(recipeToClean, cleaningRecipe => {
            let r = JSON.parse(cleaningRecipe.json)
            let EUt = (r.tickInputs && r.tickInputs.eu) ? r.tickInputs.eu[0].content : null
            let outputs = r.outputs.item

            let toInput = []
            r.inputs.item.forEach(items => {
                let curCount = items.content.count
                let curItem = Ingredient.of(items.content.ingredient)

                toInput.push(Ingredient.of(curItem, curCount))
            })
            let toOutput = Item.of(Ingredient.of(outputs[0].content.ingredient), outputs[0].content.count)

            e.remove(recipeToClean)
            e.recipes.gtceu.circuit_assembler(`kubejs:${cleaningRecipe.id.toString().split('/')[1]}`)
                .itemInputs(toInput)
                .itemOutputs(toOutput)
                .inputFluids()
                .duration(r.duration)
                .EUt(EUt)
                .cleanroom(CleanroomType.CLEANROOM)
        })
    })
})```
#

final script...

#

it can be modified to check for recipes that dont have items or dont have fluids or have more than one for each thing

#

ugh this would be a hell of a lot easier of gt just FUCKING supported data properly

#

I could just copy it over and edit but nooo

#

I decided to try its pain

#

ok I got decently far until I realized id have to make a builder for every single different recipe type in a switch statement I think

#

unless I can put a variable here ICANT

narrow nacelle
#

Damn. Yeah I thought this was going to be some higher level coding.
Thanks a lot for this !

#

I'll try it out asoon as I have access to the pack

narrow nacelle
#

currrently trying to implement this code for also engraving silicon, where the recipes are gtceu:laser_engraver/engrave_(type)_silicon

#

now that i look at it i think i need to make another script holdon

#

nvm yeah having { id: /gtceu:laser_engraver\/engrave.*_silicon/ } results in only the ram wafer recipe being made

narrow nacelle
#

Actually tweaking atm.
{ id: /gtceu:laser_engraver\/engrave_(?<=_)[a-z]*(?=_)_silicon/ }
Should work to match any recipe that uses normal silicon, yet KubeJS throws this error:
[15:57:01] [ERROR] ! SyntaxError: Invalid quantifier ?
What standard does KubeJS use for Regex?

loud ruin
narrow nacelle
#

An update on this. Feeling incredibly stupid.
I didn't notice that the code actually doesn't consider unconsumables

#

Fixed it with this