#Is there any way to include let variables in e.customs?

15 messages · Page 1 of 1 (latest)

wind beacon
#

So, I have the following code:

    let anvilRecipe = (output, item, additive, amount) => {
        e.custom({
            "type": "lychee:anvil_crafting",
            "item_in": [
                {
                    "item": item
                },
                {
                    "item": additive
                }
            ],
            "item_out": {
                "item": output
            },
            "level_cost": 0,
            "material_cost": amount
        })
    }

However, it doesn't seem to work. Im assuming this is because of the variables from the let. Is they any way to use let variables inside of a e.custom?

fair charmBOT
#

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

ruby glen
#

what are you passing to the function?

wind beacon
# ruby glen what are you passing to the function?

sorry, its quite a bit. It worked when i was using smithing recipes but when i decided to switch over to anvil recipes due to a technical issue it broke

    //Smithing Bases
    let anvilRecipe = (output, item, additive, amount) => {
        e.custom({
            "type": "lychee:anvil_crafting",
            "item_in": [
                {
                    "item": item
                },
                {
                    "item": additive
                }
            ],
            "item_out": {
                "item": output
            },
            "level_cost": 0,
            "material_cost": amount
        })
    }

    let smartSmithing = (outputSuffix, item, materialAmount, tierName, tierMaterial, modName) => {
        anvilRecipe(modName + ":" + tierName + outputSuffix, item, tierMaterial, materialAmount)
    }

    let simpleSwordSmithing

    let materialTier = (tierName, tierMaterial) => {
        smartSmithing("_helmet", "minecraft:leather_helmet", 5, tierName, tierMaterial, "minecraft")
        smartSmithing("_chestplate", "minecraft:leather_chestplate", 8, tierName, tierMaterial, "minecraft")
        smartSmithing("_leggings", "minecraft:leather_leggings", 7, tierName, tierMaterial, "minecraft")
        smartSmithing("_boots", "minecraft:leather_boots", 4, tierName, tierMaterial, "minecraft")
        smartSmithing("_sword", "kubejs:handle", 2, tierName, tierMaterial, "minecraft")
        smartSmithing("_shovel", "2x kubejs:handle", 1, tierName, tierMaterial, "minecraft")
        smartSmithing("_pickaxe", "2x kubejs:handle", 3, tierName, tierMaterial, "minecraft")
        smartSmithing("_axe", "2x kubejs:handle", 3, tierName, tierMaterial, "minecraft")
        smartSmithing("_hoe", "2x kubejs:handle", 2, tierName, tierMaterial, "minecraft")
    }

    materialTier("iron", "minecraft:iron_ingot", "minecraft")
ruby glen
#

oh god thats a lot

#

have you tried saving the recipe to a variable and console logging it to see if its correct?

wind beacon
#

what

#

no

#

i dont know what your saying

ruby glen
#
    let anvilRecipe = (output, item, additive, amount) => {
        let recipe = {
            type: lychee:anvil_crafting,
            item_in: [
                { item: item },
                { item: additive }
            ],
            item_out: { item: output },
            level_cost: 0,
            material_cost: amount
        }
        
        console.log(recipe)
        e.custom(recipe)
    }
wind beacon
#

ill see

#

oh its working its just 2xing it hold on

#
[23:14:19] [INFO] smithing.js#25: {type: lychee:anvil_crafting, item_in: [{item: 2x kubejs:handle}, {item: minecraft:iron_ingot}], item_out: {item: minecraft:iron_hoe}, level_cost: 0.0, material_cost: 2.0} [dev.latvian.mods.rhino.NativeObject]
ruby glen
#

thats why you debug your code :P

wind beacon
#

yeah sorry it works now, just have to work on a solution becuase polymorph doesnt have support for anvl recipes