#Using event signals in Preview scripting API?

15 messages · Page 1 of 1 (latest)

lilac belfry
#

Hello – my scripts have been not working since I've updated to 1.19.50 (Preview version). I've ironed out a few issues but am stuck on event signals.
Whenever I try to subscribe to world events, I get this content error:

[Scripting][error]-Plugin [Chikorita Lover's Behavior Pack BP - 1.0.0] - [main.js] ran with error: [TypeError: cannot read property 'entityHurt' of undefined    at <anonymous> (damage_indicators.js:3)
]

Also, here is the JS file for damage_indicators.js:

Edit: The issue persists regardless of whether World is lowercase or not (i.e. using world instead of World still does not work)

#

(Also, please mention me if you have a response)

signal aurora
#

u must use lower case

#

also this code is not same as where this error comes from

#

@lilac belfry

lilac belfry
scarlet epoch
lilac belfry
#

Yes, main.js is importing my damage_indicators.js file

scarlet epoch
#

myTest = new MyTest();

#

world = new World();

#

When you read docs,
only static properties are in class itself.
others are all in instance

lilac belfry
#

I think I understand what you're saying, I'll try that

#


I've tried to do what you said, but I got the following error:

[Scripting][error]-Plugin [Chikorita Lover's Behavior Pack BP - 1.0.0] - [main.js] ran with error: [ReferenceError: No constructor for native class 'World'.    at World (native)
    at <anonymous> (damage_indicators.js:3)
]

damage_indicators.js:

lilac belfry
#

I'm not sure if this makes a difference, but I'm using version 1.0.0 of the @minecraft/server module (not version 1.1.0-beta or 0.1.0)