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

What Can I Add to My Scripts So That after Restarting Sanbox They Appear in The API Output Console

(I'm using the term "Compile" for what the Restart API Sandbox does, please correct me if that's incorrect terminology.) So, folks who have incorporated scripts from the Roll20 API Script Library into their game are familiar with the following result on the API Output Console when they click on the Restart API Sandbox button or when they save one of their own scripts: Restarting sandbox due to script changes... Previous shutdown complete, starting up... Spinning up new sandbox... "-=> TokenMod v0.8.61 <=- [Tue Aug 11 2020 20:54:05 GMT+0000 (Coordinated Universal Time)]" "-- True Page Copy v1.0 -- [Mon Apr 03 2017 18:32:50 GMT+0000 (Coordinated Universal Time)]" "-=> WeaponArcs v0.1.3 <=- [Tue Aug 04 2020 13:16:25 GMT+0000 (Coordinated Universal Time)]" A quick check copying one of my scripts into a test game with no library scripts.   Nothing happens to indicate compilation is complete: Is there anything I can add to my scripts to indicate when the restart/compilation is complete? Thanks in advance, -- Tim
1603076680

Edited 1603077143
DXWarlock
Sheet Author
API Scripter
If you want something simple this works: on('ready', function () { var currentTime = new Date(); var timestamp = (new Date(currentTime)); var cmsg = "<b>API STARTED</b>"+"<br>"+timestamp; sendChat('API', "/w GM " + cmsg); }); Throw it in literally anywhere in a script as its own scope and it will work. It will spit out plan text like this on API finishing and ready, or you can make it fancier with whatever roll template your sheet uses like the second one in the picture. (What I have but its Pathfinder Community specific, so I stripped it down to just text so anyone can drop it in as in and use it..for formatting you would need to use whatever roll template your game sheet uses).
1603094977
GiGs
Pro
Sheet Author
API Scripter
If you specifically want it to appear in the sandbox log and not campaign chat, use the log command instead of sendChat, like on('ready', function () { log('=== SCRIPT NAME HERE ====');     // the rest of your code here }); The important thing is to make sure you have an on(ready) event, which is run whenever the sandbox is reloaded.
1603122977
The Aaron
Roll20 Production Team
API Scripter
The proper terms would probably  be "interprets" (when the Javascript engine reads the text and assembles it into instructions) and "executes" (when those instructions are run). Javascript is an interpreted language, meaning the source text is read each time, as opposed to a compiled language where the text is read once and converted to a machine language which is retained and executed from that point on as needed. All that said, just saying "executed" or  "run" are probably plenty sufficient.  If you look at any of my scripts in the repo at the checkInstall() function, you'll find the code I use for that output, along with my state management code. GroupInitiative is probably the most thorough and interesting of that ilk. All of them feature a lastUpdate variable which contains a Unix time stamp (which my editor automatically sets on save) that is then used for the date and time. 
1603127509

Edited 1603128721
DXWarlock    GiGs     The Aaron Fantastic, folks, I thought it might be something to do with On Ready.  Much appreciated. Thanks, Aaron for the primer on interpreted versus complied languages. "-- Tim's Movement -- API Started Mon Oct 19 2020 17:26:14 GMT+0000 (Coordinated Universal Time)" Restarting sandbox due to script changes... Previous shutdown complete, starting up... Spinning up new sandbox... "-=> TokenMod v0.8.61 <=- [Tue Aug 11 2020 20:54:05 GMT+0000 (Coordinated Universal Time)]" "-- True Page Copy v1.0 -- [Mon Apr 03 2017 18:32:50 GMT+0000 (Coordinated Universal Time)]" "-=> WeaponArcs v0.1.3 <=- [Tue Aug 04 2020 13:16:25 GMT+0000 (Coordinated Universal Time)]" "-- Tim's CF_Roll -- API Started Mon Oct 19 2020 17:29:49 GMT+0000 (Coordinated Universal Time)" "-- Tim's Map_Grid -- API Started Mon Oct 19 2020 17:29:49 GMT+0000 (Coordinated Universal Time)" "-- Tim's Mark_Enemy_Units -- API Started Mon Oct 19 2020 17:29:49 GMT+0000 (Coordinated Universal Time)" "-- Tim's Unit_Status -- API Started Mon Oct 19 2020 17:29:49 GMT+0000 (Coordinated Universal Time)" "-- Tim's Zone_of_Control -- API Started Mon Oct 19 2020 17:29:49 GMT+0000 (Coordinated Universal Time)" "-- Tim's Administrative -- API Started Mon Oct 19 2020 17:29:49 GMT+0000 (Coordinated Universal Time)" "-- Tim's Movement -- API Ready: Mon Oct 19 2020 17:29:49 GMT+0000 (Coordinated Universal Time)" All the best, everyone, -- Tim
1603130606
The Aaron
Roll20 Production Team
API Scripter
Looking good!