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

Script Freezing APIs Without Error

1602968380
Finds
API Scripter
I'm running into a strange issue with a very simple script, when I launch it runs fine for a bit but then all APIs stop working but with no error. It's almost like it's got itself in a loop and grinds everything to a halt. I notice even restarting the API Sandbox takes a bit afterword. All this script does is watch for a token on the objects layer that has a max_hp set. If it changes it calculates the % of hp remaining and tags the token with a status marker of a color that represents the health of the token. Any help is appreciated /** * healthstate.js * * * Copyright 2020: Ben F. * Licensed under the GPL Version 3 license. * <a href="http://www.gnu.org/licenses/gpl.html" rel="nofollow">http://www.gnu.org/licenses/gpl.html</a> * * This script is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This script is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * To use type !hs to enable/disable the script, when enabled... * - A token on the object layer with a health and max health * will be flagged with a color status indicating health state, * using green,yellow,brown,red and finally X (dead). * - Tokens with visibility for health bar to players will not * trigger this effect. * */ var healthstat = healthstat || (function(){ 'use strict'; var handleInput = function(msg) { if ( "api" !== msg.type ) { return; } // Disable/Enable the script activity with !hs if(msg.content.indexOf("!hs") !== -1 ) { if(state.healthstat.run_state) { state.healthstat.run_state = false; log("&gt;&gt; Health Status: OFF"); sendChat('HS','/w gm OFF'); } else { state.healthstat.run_state = true; log("&gt;&gt; Health Status: ON"); sendChat('HS','/w gm ON'); } } }, handleToken = function(obj) { // Process token changes if it's a token on the objects layer with a max hp set if( 'graphic' == obj.get('type') &amp;&amp; 'token' == obj.get('subtype') &amp;&amp; 'objects' == obj.get('layer') &amp;&amp; '' != obj.get('bar1_max') ) { // To move forward the token the state 'run_state' must be true and // the show player health for token must be disabled if(state.healthstat.run_state &amp;&amp; !(obj.get('showplayers_bar1'))) { var token_name = obj.get('name') || ''; var token_hp = (obj.get('bar1_value')) || 0; var token_hp_max = (obj.get('bar1_max')) || 0; // Exit if one of the variables is missing if(!(token_hp) || !(token_hp_max)) { return; } // Calculate the % of health remaining var token_hp_percent = ((token_hp/token_hp_max)*100); log("&gt;&gt; Health Status: "+token_name+" - at "+token_hp_percent+"%"); // Clear all token status resetStatus(obj); if(token_hp_percent &gt;= 75) { obj.set("status_green",true); } else if (token_hp_percent &gt;= 50 &amp;&amp; token_hp_percent &lt;= 74) { obj.set("status_yellow",true); } else if (token_hp_percent &gt;= 25 &amp;&amp; token_hp_percent &lt;= 49) { obj.set("status_brown",true); } else if (token_hp_percent &gt;= 1 &amp;&amp; token_hp_percent &lt;= 24) { obj.set("status_red",true); } else if (token_hp_percent &lt;= 0 ) { obj.set("status_dead",true); } } else { resetStatus(obj); } } }, resetStatus = function(obj) { obj.set("status_dead",false); obj.set("status_red",false); obj.set("status_brown",false); obj.set("status_yellow",false); obj.set("status_green",false); }, checkInstall = function() { var script_version = "0.4.0"; if( ! state.healthstat ) { state.healthstat = { version: script_version, run_state: true, }; } if (state.healthstat.version != script_version) state.healthstat.version = script_version; log("-=&gt; Health State Script v"+state.healthstat.version+" Initialized &lt;=-") }, registerEventHandlers = function() { on('chat:message', handleInput); on('change:graphic', handleToken); }; return { CheckInstall: checkInstall, RegisterEventHandlers: registerEventHandlers }; }()); on("ready", function() { 'use strict'; healthstat.CheckInstall(); healthstat.RegisterEventHandlers(); });
1602971277
David M.
Pro
API Scripter
Don't think it is related to this script. I and others have been experiencing a lot of lag with api commands &amp; sandbox restarts today
1602971423
Finds
API Scripter
Oh you may be right I just had the same thing happen with it disabled; thanks
1602973791
Kurt J.
Pro
API Scripter
Yep... About 40-50 percent of the time when I try to start/restart the sandbox it just goes off into lala-land. It also doesn't seem to be displaying error messages on crashes or when starting a sandbox with code typos either. It just stops doing anything. I started using Aaron's API Heart Beat specifically to know if I was going crazy or not trying to troubleshoot problems. While I can't rule out me going crazy ( :) ) , the API sandbox is definitely crashing silently.
Hey Finds, and others, FWIW, Keith Curtis is trying to get folks to report issues on this topic on the Bugs and Technical Issues board: <a href="https://app.roll20.net/forum/post/9288603/api-inconsistently-responsive" rel="nofollow">https://app.roll20.net/forum/post/9288603/api-inconsistently-responsive</a>