#My scripts fail to load

1 messages · Page 1 of 1 (latest)

iron adder
#

I'm new to scripting and I don't know why no script works if I have placed the main.js location correctly.


[Scripting][warning]-Debugger connection closed.

[Scripting][warning]-Debugger auto-attach connect retry in 2s...

[Scripting][warning]-Debugger connection closed.

[Scripting][warning]-Debugger auto-attach connect retry in 2s...

[Scripting][warning]-Debugger connection closed.

[Scripting][warning]-Debugger auto-attach connect retry in 2s...

[Scripting][warning]-Debugger connection closed.

[Scripting][warning]-Debugger auto-attach connect retry in 2s...

[Scripting][warning]-Debugger connection closed.

[Scripting][warning]-Debugger auto-attach connect retry in 2s...

[Scripting][warning]-Debugger connection closed.

[Scripting][error]-Debugger auto-attach failed to connect.

[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'worldInitialize' of undefined

[Scripting][error]-Unhandled promise rejection: TypeError: cannot read property 'worldInitialize' of undefined

[Scripting][error]-Plugin [Addon capibara - 1.0.0] - [main.js] ran with error: [TypeError: cannot read property 'worldInitialize' of undefined    at <anonymous> (components/check_logs.js:4)
]

[Scripting][warning]-Component 'example:orangeLeaffrutaDecay' was not registered in script but used on a block

[Scripting][warning]-Component 'example:orangeFruitState' was not registered in script but used on a block

[Scripting][warning]-Component 'custom:árbol_crecer' was not registered in script but used on a block

[Scripting][warning]-Component 'example:orangeLeafDecay' was not registered in script but used on a block


[Scripting][warning]-[Watchdog] Spike from 'Addon capibara' (162ms)```
#

This is another main.js I made for my components folder

gloomy solar
gloomy solar
#

dont forget (event => { also

iron adder
gloomy solar
#

You are using the outdated world.events variant

iron adder
gloomy solar
iron adder
#

Manifest, or components?

gloomy solar
iron adder
iron adder
gloomy solar
#

fixed script

#

@iron adder

iron adder
#

ok

#

I'm going to see

iron adder
gloomy solar
#

it does

iron adder
#

It tells me that the text editor cannot read it

#

There is also an extra folder that says __MACOSX

iron adder
#

ok

gloomy solar
#

well if its not opening for you just downloaded a old zip that you sent and change

world.events.worldInitialize.subscribe
to:
world.afterEvents.worldInitialize.subscribe

and this:
world.events.blockBreak.subscribe to world.afterEvents.playerBreakBlock.subscribe

#

@iron adder

#
import { system } from "@minecraft/server";

system.afterEvents.scriptTick.subscribe((event) => {
    
});```

Use this for system
iron adder
#

mmm ok

#

console.log can I leave it?

iron adder
# gloomy solar ```js import { system } from "@minecraft/server"; system.afterEvents.scriptTick...
console.log("El sapling_crecer se ha cargado correctamente.");

system.afterEvents.scriptTick.subscribe((event) => {
// Registro del componente custom "custom:árbol_crecer"

    const componentRegistry = event.propertyRegistry;
    componentRegistry.registerComponent(
        "custom:árbol_crecer",
        {
            description: "Hacer que el sapling crezca.",
        }
    );
});

// Función para cargar una estructura de árbol desde un archivo .mcstructure
function cargarEstructuraArbol(dimension, location) {
    const estructuraNombre = "arbol_naranjo";  // Nombre del archivo .mcstructure (sin la extensión)

    try {
        dimension.runCommand(`structure load ${estructuraNombre} ${location.x} ${location.y} ${location.z}`);
        console.log(`Estructura ${estructuraNombre} cargada correctamente en ${location.x}, ${location.y}, ${location.z}`);
    } catch (error) {
        console.error(`Error al cargar la estructura: ${estructuraNombre}`, error);
    }
}

// Evento que detecta cuando el jugador usa polvo de hueso en el sapling
world.afterEvents.itemUseOn.subscribe(event => {
    const item = event.item;
    const block = event.block;
    const dimension = event.source.dimension;
    const location = block.location;

    // Verificamos si el bloque es un brote personalizado y el ítem es polvo de hueso
    if (block.typeId === "bloque:sapling_naranja" && item.typeId === "minecraft:bone_meal") {
        console.log("Usando polvo de hueso en el sapling naranja.");
        // Reemplazamos el brote por un árbol cargando la estructura
        cargarEstructuraArbol(dimension, location);
    }
});```
gloomy solar
#

?

iron adder
gloomy solar
#

console.warn(“a”)

iron adder
#

and I didn't modify main.js?

#

change the world.initialize to system.afterEvents.scriptTick.subscribe((event) => {?

gloomy solar
#

World.initialize to

world.afterEvents.worldInitialize.subscribe

#

import world and system also

iron adder
#

import "./components/main.js";

// Función principal para inicializar el mundo
system.afterEvents.worldInitialize.subscribe((event) => {
console.warn("El main.js se ha cargado correctamente.");
});

#

so?

gloomy solar
#
import { world } from “@minecraft/server”;
import "./components/main.js";

// Función principal para inicializar el mundo
world.afterEvents.worldInitialize.subscribe((event) => {
    console.warn("El main.js se ha cargado correctamente.");
});```
iron adder
#

ohh

gloomy solar
#

which

iron adder
#

It's in main.js, right?

#

Well I get an error

#

The word @minecraft appears in red

gloomy solar
#

show me an ss

iron adder
gloomy solar
iron adder
gloomy solar
#

bro😭

#

thats not a error

#

it will work even with red line

iron adder
gloomy solar
iron adder
#

man

#

so that's all? (I'll try it tomorrow anyway)

gloomy solar
#

yes it should work

iron adder
#

[Recipes][error]-recipes/mesa_crafteo.json | Missing version tag


[Scripting][warning]-Debugger auto-attach mode connect...

[Scripting][warning]-Debugger connection closed.

[Scripting][warning]-Debugger auto-attach connect retry in 2s...

[Scripting][warning]-Debugger connection closed.

[Scripting][warning]-Debugger auto-attach connect retry in 2s...

[Scripting][warning]-Debugger connection closed.

[Scripting][warning]-Debugger auto-attach connect retry in 2s...

[Scripting][warning]-Debugger connection closed.

[Scripting][warning]-Debugger auto-attach connect retry in 2s...

[Scripting][warning]-Debugger connection closed.

[Scripting][warning]-Debugger auto-attach connect retry in 2s...

[Scripting][warning]-Debugger connection closed.

[Scripting][error]-Debugger auto-attach failed to connect.

[Scripting][error]-Plugin [Addon capibara - 1.0.0] - [main.js] ran with error: [SyntaxError: unexpected character    at main.js:1
]

[Scripting][warning]-Component 'example:orangeLeaffrutaDecay' was not registered in script but used on a block

[Scripting][warning]-Component 'example:orangeFruitState' was not registered in script but used on a block

[Scripting][warning]-Component 'custom:árbol_crecer' was not registered in script but used on a block

[Scripting][warning]-Component 'kai:on_tick' was not registered in script but used on a block

[Scripting][warning]-Component 'example:orangeLeafDecay' was not registered in script but used on a block

[Scripting][warning]-Component 'kai:on_place' was not registered in script but used on a block

[Scripting][warning]-Component 'kai:on_player_destroy' was not registered in script but used on a block

[Scripting][warning]-Component 'kai:on_interact' was not registered in script but used on a block```
#

(kai interaction, destroyed player, on place and on tick don't pay attention to them, they are scripts that are like custom components but that don't have a file and that I plan to delete in the future)

gloomy solar
#

and turn off the debugger setting

#

cuz its useless

#

Your custom item recipe also wrong

iron adder
iron adder
iron adder
gloomy solar
#

Two manifests???

#

what is first line of main.js

iron adder
#

So one is from the script folder and the other is from the components folder

iron adder
# gloomy solar what is first line of main.js
import "./components/main.js";

// Función principal para inicializar el mundo
world.afterEvents.worldInitialize.subscribe((event) => {
    console.warn("El main.js se ha cargado correctamente.");
});```