#'event' is not defined

126 messages · Page 1 of 1 (latest)

hollow palm
#

[085054] [INIT] KubeJS 2001.6.5-build.16; MC 2001 forge
[085054] [INIT] Loaded plugins:
[085054] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgePlugin
[085054] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgeClientPlugin
[085054] [INIT] - com.probejs.ProbeJSPlugin
[085054] [ERROR] ! example.js#5: ReferenceError: "event" is not defined.
[085054] [INFO] Loaded 0/1 KubeJS server scripts in 0.094 s with 1 errors and 0 warnings
[085054] [INFO] Scripts loaded
[08:51:04] [INFO] Server resource reload complete!

cobalt forumBOT
#

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

hollow palm
#

this is my code

#

ServerEvents.recipes(event => {
event.remove({output: 'projecte:red_matter'})
event.remove({output: 'projecte:dark_matter'})

})

vague lynx
#

Do you have this in the server scripts folder?

#

Well actually you do...

hollow palm
#

yep

#

ive been at this for a fucking hour

#

just trying to remove 2 things

#

im using probejs

vague lynx
#

When you hover over ServerEvents does it give you any information showing that it's correct? Same with the event variable?

hollow palm
#

like this?

#

or this?

vague lynx
#

Both of those basically say that it should be working.

How about adding this to the top of the file:
//priority: 0
//@ts-check

The ts check will make vscode respond to inaccuracies between your script and the type script generated by probeJS. so with that, it might give us some hints of a problem even if it has a lot of false positives.

The other header is the priority one, it lets you decide which scripts to be run in what order so by setting it to zero it's a hope that this will fix a script running before it is supposed to and ending up with undefined varibles.

hollow palm
#

like this?

vague lynx
#

Yeah that should help. Now can you try /reload to see if it works?

From the looks of things not even ts check is showing problems.

hollow palm
#

imt rying now

#

nope

#

still fucking wrong

#

insanity

vague lynx
#

What do the errors say..?

hollow palm
#

all the same thing, event not defined

#

its always the same

vague lynx
#

What if you change the event variable to something else?

#

Like "e"

hollow palm
#

ill try?

#

like this?

#

ServerEvents.recipes(e => {
e.remove({output: 'projecte:red_matter'})
e.remove({output: 'projecte:dark_matter'})

})

vague lynx
#

Yeah, and at this point it's not something I've encountered and it should be working. The answer might be really difficult now but if you find the answer you'll likely not have this issue in the future.

hollow palm
#

still broken! kill me!

vague lynx
#

I don't mean to make you run around a cage, and I know it can be fustrating to feel like nothing is working but what you are doing is finding all the ways that don't work so that you can find the way that does.

#

That just takes time.

hollow palm
#

better than the 40 minutes of me ramming my head into the desk

#

ill send the most recent log

#

[09:15:03] [INIT] KubeJS 2001.6.5-build.16; MC 2001 forge
[09:15:03] [INIT] Loaded plugins:
[09:15:03] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgePlugin
[09:15:03] [INIT] - dev.latvian.mods.kubejs.forge.BuiltinKubeJSForgeClientPlugin
[09:15:03] [INIT] - com.probejs.ProbeJSPlugin
[09:15:03] [ERROR] ! example.js#5: ReferenceError: "event" is not defined.
[09:15:03] [INFO] Loaded 0/1 KubeJS server scripts in 0.007 s with 1 errors and 0 warnings
[09:15:03] [INFO] Scripts loaded
[09:15:09] [INFO] Server resource reload complete!

vague lynx
#

Heh, sure is! Now the next try is maybe setting a null check like this:

if(!e) return;

That should make it so the script is only going to run when event is defined.

This is likely going to do two things however. It's either going to make the recipe not show up, or it's only going to work when the recipe is actually ready to be called.

ServerEvents.recipes(e => {

if(!e) return;
        e.remove({output: 'projecte:red_matter'})
        e.remove({output: 'projecte:dark_matter'})

   })```
#

So if it doesn't cause a error you should still check for recipes that make dark_matter

hollow palm
vague lynx
#

Aye if it works it works

hollow palm
#

ServerEvents.recipes(e => {
e.remove({output: 'projecte:red_matter'})
e.remove({output: 'projecte:dark_matter'})

})

vague lynx
hollow palm
#

just saving that there

vague lynx
#

Good idea

hollow palm
#

your not gonna believe this...

#

its another fucking error!!!

vague lynx
#

What's this one this time?

hollow palm
#

guess what

#

still that fucking event undefined

vague lynx
#

If have to ask, are you using the most updated version of KubeJS? Even if it shouldn't be the cause of this issue.

hollow palm
#

most updated for 1.20.1

glass pawn
#

did you save the file

vague lynx
#

I assumed he did...

glass pawn
#

your last pic that shows the script tab shows its unsaved

hollow palm
#

i might be the slightest bit stupid

glass pawn
#

white dot = unsaved

hollow palm
#

im new to vcs im sorry

vague lynx
#

i am not mad at you and there's no reason to apologize...

#

I mean if it works it works. Is it working?

hollow palm
#

wait but

#

where do i same

vague lynx
hollow palm
#

yeah yeah bully the coding noob

vague lynx
#

Okay, I assumed you knew more about this but since I now know how much you might not know I'm going to tell you this in what might seem like a condescending manner.

When you save and reload there is almost this copy of the file stored in the game's memory. it's different from the file you edit, and it's helpful to have this barrier between what the computer has and what we are actively editing.

So, when we are finished and want to give the game the new script, we can sometimes just save the file (usually ctrl+s, but you can also right click on the tab of the open file where it's name is to see a menu for this) and we tell our computer this is the new file. Since we saved it.

Now, when you /reload the game gets all the new things like our script we just saved, and loads it up to run. So if you don't save it, nothing changes, and it can start producing the same error multiple times even if you edit the unsaved file.

Am I making sense? Save the file to submit it to the game so it can run it. It cannot run a unsaved file.

vague lynx
#

It's why it's favorited

hollow palm
#

you should have just said control s, but yes, i get it

vague lynx
#

You're doing better than some, I had a friend who was 20 years older than me who didn't know how to open a folder.

#

daoraStare seriously. it took two people and 30 plus mins to explain fundamentals about directories and why you had to place a folder in a specific spot for a game to access and name it correctly.

vague lynx
#

we got it done

#

and in the end, we didn't even play

#

All right so how's that script working?

hollow palm
#

i uhh

#

set off 2000 tnt

vague lynx
#

.

hollow palm
#

and need to wait for minecraft to stop being a slideshow

#

lmao

vague lynx
hollow palm
#

but ill do it now

vague lynx
#

All right

hollow palm
#

HH

#

NO ERRORS?

#

HOLY SHIT

vague lynx
#

Check the recipes.

hollow palm
#

all i had to do was press control s fmll

vague lynx
#

i leave you in the result of your trials and effort. go on young master.

hollow palm
#

danke

vague lynx
#

@glass pawn clutch

indigo apex
#

what is going on here

hollow palm
#

me being an idiot

#

and not saving script

indigo apex
#

oh

hollow palm
#

and banging my head on desk because of it

#

for an hour

indigo apex
#

oh

hollow palm
#

mood fr

indigo apex
#

I feel that

#

when I started working with kjs I had a very similar issue

#

I was just editing a different file

#

🔥

#

anyways

hollow palm
#

real

vague lynx
rotund eagleBOT
#

Please close your ticket (with </ticket close:1054771505520717835> or the button atop this thread) once you resolved your issue!
This also helps others that would like to help out, as they don't have to look into this thread to check if it has been resolved by now.

Do you have any other questions regarding your issue? Feel free to ask!
Note: You should create a new post for unrelated issues.

hollow palm
#

bye bye

cobalt forumBOT
#

Ticket closed!

hollow palm
#

thank you