Roll20 uses cookies to improve your experience on our site. Cookies enable you to enjoy certain features, social sharing functionality, and tailor message and display ads to your interests on our site and others. They also help us understand how our site is being used. By continuing to use our site, you consent to our use of cookies. Update your cookie preferences .
×
Create a free account

API dependencies

1591119644

Edited 1591138982
Angelo
API Scripter
Hi, i am new to the roll20 API/javascript world, i am creating some scripts and i wrote a bunch of utils in classes that i would like to keep in a separate "utils" file for cleanliness but when i try to refer to those classes i get an error about them not being ready, i guess it's an initialization order problem, is there any way to specify a dependency? For instance: "A_script.js" has something like class A_Utils{  testChat() { sendChat("test", "test chat"); }  } "B_script.js" has something like: class B_Utils extends A_Utils { ... } or: var myTest = new A_Utils() myTest.testChat() I did a quick search and only found a thread that is 4 yrs old.
1591153753
The Aaron
Roll20 Production Team
API Scripter
All api scripts for a game are concatenated together. As long as your base classes are in script files before the derived classes, you should be fine. Alternatively, you could use something like Webpack to build a composite script to install while keeping your files separate locally. 
1591205084
Angelo
API Scripter
perfect, it was just a problem on the order of the files, thank you so much!