Discord
Login
Community
DARK THEME

How do I make a global function ?

I want to make a function located in one script and then call it from another.

All functions are global by default in microStudio. All files in the project are linked together (in a undefined order), so writing code in splitted sections is just a matter of programmer taste. Same for variables.

wait so why does it say: "Warning: x1_Function(speed) is not a function, in file "a_primary" at line 5, column 22" probably 75% of the time when I start the game ? (The host script is located in a folder above the calling script)

also idk why some of my functions are acting funky, like randomly stop being called and then throw an error after it worked multiple times

It is easiest to analyze a program when you can look at the source code.

You can make the source code public until you solve the problem.

Are you trying to execute it before the init() function? Files are loaded in an unpredictable order, and init() is called after they are all ready.

oh, I didn't know that, now it works. Thank you

frien you had to call your function in one of the 3 vanila functions() init() update() draw it depends on the function type :)

Post a reply

Progress

Status

Preview
Cancel
Post
Validate your e-mail address to participate in the community