#Weird crosstalk between scripts

12 messages · Page 1 of 1 (latest)

night hare
#

So I have 2 scripts in one folder, both have const id_prefix declaration in them, and that never made me a trouble.. until now ^^"?
How does exactly "crosstalk" work? When I can use variables from different scripts, and when I need to declare them as globals?
Thx a lot, and Merry Christmas to everyone that reads this kibzL

upbeat pelicanBOT
#

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

glad grail
#

all script files of a type are basically merged into one file, then parsed

#

so you only need globals for cross type communication

night hare
#

So.. all recipes for x event are counted as one file? Or all files from one folder?

glad grail
#

all files in one type

#

so server_scripts, startup_scripts

#

events are seperate

#

its only files

night hare
#

Ooohh.. okay that makes sense 😅 Thx :D

glad grail
#

server_scripts/test.js

const value = 1
let foo = 'bar'
global.thingy = [1,2,3]

server_scripts/atest.js

console.log(value) //logs 'undefined'
// this is because this file is alphabetically before the other one, and so gets run before it. use //priority: 10 at the top of the other to make it load first

server_scripts/test2.js

console.log(foo) // logs 'bar'
value = 2 // errors due to reasigning constant
night hare
#

ah 👍