Forked from Atlante45/reload-failing-server-scripts.js
Created
January 31, 2019 00:12
-
-
Save MiladNazeri/f763d29ffcabb2f5852f909cc6db1561 to your computer and use it in GitHub Desktop.
Tracks down and reloads failing entity server scripts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var entitiesWithServerScripts = 0 | |
function callbackClosure(i, callback) { | |
return function() { | |
return callback(i); | |
} | |
} | |
var interval = Script.setInterval(function() { | |
console.log("Checks pending:", entitiesWithServerScripts) | |
var entities = Entities.findEntities(Vec3.ZERO, 100000); | |
for (var i in entities) { | |
var entity = entities[i]; | |
var props = Entities.getEntityProperties(entity, ["serverScripts"]); | |
if (props.serverScripts != "") { | |
Entities.getServerScriptStatus(entity, (function() { | |
var entityID = entity; | |
var serverScripts = props.serverScripts; | |
return function(success, isRunning, status, errorInfo) { | |
if (!success || !isRunning) { | |
console.log("Script not running:", entityID, success, isRunning, status, errorInfo, JSON.stringify(serverScripts)); | |
Entities.reloadServerScripts(entityID); | |
} | |
entitiesWithServerScripts-- | |
} | |
})()); | |
entitiesWithServerScripts++ | |
} | |
} | |
console.log("Num entities to check:", entitiesWithServerScripts) | |
}, 5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment