OASIS-learn-study / minecraft-storeys-maker

Minecraft extension to make your own stories in, with and for Minecraft - it's like being a movie director!
https://www.learn.study
GNU Affero General Public License v3.0
15 stars 10 forks source link

ReferenceError: "m" is not defined #386

Closed vorburger closed 2 years ago

vorburger commented 2 years ago

I was playing around with #385 and made a first demo, then closed the browser, then /make again and then hit this:

[22:05:49 INFO] [ch.vorburger.minecraft.storeys.web.StaticWebServerVerticle]: Uploaded file /tmp/upload8219027916786767395/14823804-55d5-4931-ba22-6995efdaab66 (size 61)
[22:05:49 INFO] [ch.vorburger.minecraft.storeys.ScriptsLoader]: (Re-)loaded /data/config/storeys-web/new-scripts/5153e34b-c326-3040-ab45-048f8f35eb13
[22:06:13 INFO] [ch.vorburger.minecraft.storeys.web.StaticWebServerVerticle]: Uploaded file /tmp/upload8219027916786767395/55972904-b136-4f1b-a56b-18527dd8291a (size 59)
[22:06:13 INFO] [ch.vorburger.minecraft.storeys.ScriptsLoader]: (Re-)loaded /data/config/storeys-web/new-scripts/5153e34b-c326-3040-ab45-048f8f35eb13
[22:06:22 INFO]: michaelpapa7 lost connection: Disconnected
[22:06:22 INFO]: michaelpapa7 left the game
[22:09:29 INFO]: michaelpapa7 [/10.0.2.100:54144] logged in with entity id [609] in world (minecraft:overworld/0) at (232.15222591732606, 63.0, 216.50003928975812).
[22:09:29 INFO]: michaelpapa7 joined the game
[22:10:29 INFO] [ch.vorburger.minecraft.storeys.web.StaticWebServerVerticle]: Uploaded file /tmp/upload8219027916786767395/f6636201-b1da-4166-8a85-171a1ac652e7 (size 31)
[22:10:29 WARN] [ch.vorburger.minecraft.storeys.ScriptsLoader]: Failed to register /data/config/storeys-web/new-scripts/5153e34b-c326-3040-ab45-048f8f35eb13
jdk.nashorn.internal.runtime.ECMAException: ReferenceError: "m" is not defined
        at jdk.nashorn.internal.runtime.ECMAErrors.error(ECMAErrors.java:57) ~[nashorn.jar:?]
        at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:319) ~[nashorn.jar:?]
        at jdk.nashorn.internal.runtime.ECMAErrors.referenceError(ECMAErrors.java:291) ~[nashorn.jar:?]
        at jdk.nashorn.internal.objects.Global.__noSuchProperty__(Global.java:1442) ~[nashorn.jar:?]
        at jdk.nashorn.internal.scripts.Script$Recompilation$9$981A$\^eval\_.init(<eval>:24) ~[?:?]
        at ch.vorburger.minecraft.storeys.japi.Script$$NashornJavaAdapter.init(Unknown Source) ~[?:?]
        at ch.vorburger.minecraft.storeys.japi.impl.Scripts.register(Scripts.java:44) ~[Scripts.class:?]
        at ch.vorburger.minecraft.storeys.ScriptsLoader.lambda$new$0(ScriptsLoader.java:64) ~[ScriptsLoader.class:?]
        at ch.vorburger.fswatch.QuietPeriodListener.lambda$onChange$0(QuietPeriodListener.java:60) ~[QuietPeriodListener.class:?]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_312]

@edewit FYI

edewit commented 2 years ago

This happens when you put an action into the workspace without a start the generated code will look like:

m.cmd('/say hello');

where m is undefined because it will be passed in by the event:

e.whenCommand("help", function(m) {
  m.cmd('/say hello');
});
edewit commented 2 years ago

btw we should maybe have better names then e and m?

vorburger commented 2 years ago

418 will avoid printing the full stack trace to the log, which makes this look less scary.

@edewit should we leave this at that, and close this? I'm not sure we really can (easily) do much better.

edewit commented 2 years ago

right, nothing we can do it's always possible to create something that doesn't work so it's file like this