#Color conversion recipe: syntax error

7 messages · Page 1 of 1 (latest)

idle apex
#

I have made a script that works fine in 1.19.2 forge. However, when I move it to 1.16.5 forge, it appears syntax error on the line for (const color of colors) { but neither VScode nor I can notice that error.
Error: [ERR ] SourceFile:18: Error loading KubeJS script: syntax error (server_scripts:color_tweaks.js#34)

let colors = ['white', 'orange', 'magenta', 'light_blue', 'yellow', 'lime', 'pink', 'gray', 'light_gray', 'cyan', 'purple', 'blue', 'brown', 'green', 'red', 'black']

    function extractID(str) {
        const match = str.match(/(.*?)(:)(.*?)color(.*$)/);
        if (match === null) {
            throw new Error(`Failed to extract ID from string: "${str}"`);
        }
        return [match[1], match[3], match[4]];
    }

    function buildColorConversion(str, type) {
        const colorRegex = new RegExp(colors.join('|'), 'i');
        str = str.replace(colorRegex, 'color');

        const itemID = extractID(str);
        
        for (const color of colors) { //this is line #34
            let altColorItem = colors.filter(c => c !== color).map(c => str.replace('color', c));
            let outputItem = `${itemID[0]}:${itemID[1]}${color}${itemID[2]}`;
            console.log(outputItem);

            if (type == 0) {
                e.shaped(Item.of(outputItem, 8), ['CCC', 'CDC', 'CCC'], {
                    D: `#forge:dyes/${color}`,
                    C: altColorItem
                }).id(`kubejs:${outputItem.replace(':', '/')}`);
            }
            if (type == 1) {
                e.shapeless(outputItem, [`#forge:dyes/${color}`, altColorItem]).id(`kubejs:${outputItem.replace(':', '/')}`);
            }
        }
    }

    buildColorConversion('minecraft:white_wool', 1);
    buildColorConversion('connectedglass:borderless_glass_white', 0);
    buildColorConversion('connectedglass:scratched_glass_white_pane', 0);
ruby totemBOT
#

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

idle apex
#

Color conversion recipe: syntax error

lean shard
#

try replacing it with a forEach

idle apex
lean shard
#

could just be outdated Rhino version

#

no worries :3