Skip to content

Instantly share code, notes, and snippets.

@BaldarSilveraxe
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BaldarSilveraxe/4895daa05b43cc6559e1 to your computer and use it in GitHub Desktop.
Save BaldarSilveraxe/4895daa05b43cc6559e1 to your computer and use it in GitHub Desktop.
Roll20 Script
on("ready", function() {
on("chat:message", function(msg) {if(msg.type == "api"){processMessage(msg)};});
});
processMessage = function(msg) {
if(msg.type !== "api"){return};
if(msg.content == "!gettable"){gettable();}
};
gettable = function(msg) {
var tableName = "GeomorphicTiles";
var geomorphicTilesCheck = [
{tileName: "Geo_Type_A_0001"},
{tileName: "Geo_Type_A_0002"},
{tileName: "Geo_Type_A_0003"},
{tileName: "Geo_Type_A_0004"},
{tileName: "Geo_Type_A_0005"},
{tileName: "Geo_Type_A_0006"},
{tileName: "Geo_Type_A_0007"},
{tileName: "Geo_Type_A_0008"},
{tileName: "Geo_Type_A_0009"},
{tileName: "Geo_Type_A_0010"},
{tileName: "Geo_Type_A_0011"},
{tileName: "Geo_Type_A_0012"},
{tileName: "Geo_Type_A_0013"},
{tileName: "Geo_Type_A_0014"},
{tileName: "Geo_Type_A_0015"},
{tileName: "Geo_Type_A_0016"},
{tileName: "Geo_Type_A_0017"},
{tileName: "Geo_Type_A_0018"},
{tileName: "Geo_Type_A_0019"},
{tileName: "Geo_Type_A_0020"},
{tileName: "Geo_Type_A_0021"},
{tileName: "Geo_Type_A_0022"},
{tileName: "Geo_Type_A_0023"},
{tileName: "Geo_Type_A_0024"},
{tileName: "Geo_Type_A_0025"},
{tileName: "Geo_Type_A_0026"},
{tileName: "Geo_Type_A_0027"},
{tileName: "Geo_Type_A_0028"},
{tileName: "Geo_Type_A_0029"},
{tileName: "Geo_Type_A_0030"},
{tileName: "Geo_Type_A_0031"},
{tileName: "Geo_Type_A_0032"},
{tileName: "Geo_Type_A_0033"},
{tileName: "Geo_Type_A_0034"},
{tileName: "Geo_Type_A_0035"},
{tileName: "Geo_Type_A_0036"},
{tileName: "Geo_Type_A_0037"},
{tileName: "Geo_Type_A_0038"},
{tileName: "Geo_Type_A_0039"},
{tileName: "Geo_Type_A_0040"},
{tileName: "Geo_Type_A_0041"},
{tileName: "Geo_Type_A_0042"},
{tileName: "Geo_Type_A_0043"},
{tileName: "Geo_Type_A_0044"},
{tileName: "Geo_Type_A_0045"}
];
sendChat("Geo-API", "Checking Table...");
var geoTable = findObjs({type: "rollabletable", name: tableName});
if(geoTable.length) {
sendChat("Geo-API", "Table named 'GeomorphicTiles' found OK");
} else {
sendChat("Geo-API", "Table named 'GeomorphicTiles' is missing (be sure to check for white spaces.)");
return;
}
if(geoTable[0].get("id")) {
sendChat("Geo-API", "Table iD found OK");
} else {
sendChat("Geo-API", "Table named 'GeomorphicTiles' is missing (be sure to check for white spaces.)");
return;
}
var geoTableItems = findObjs({type: "tableitem", rollabletableid: geoTable[0].get("id")});
if(geoTableItems.length) {
sendChat("Geo-API", "Table named 'GeomorphicTiles' has items. Check OK.");
} else {
sendChat("Geo-API", "Table named 'GeomorphicTiles' has no items");
return;
}
if(geoTableItems.length === 45) {
sendChat("Geo-API", "Table named 'GeomorphicTiles' has proper number of items. (45)");
} else {
sendChat("Geo-API", "Table named 'GeomorphicTiles' has incorrect number of items. Should be 45 but has " + geoTableItems.length);
return;
}
_.each(geomorphicTilesCheck, function(obj) {
for (i = 0; i < geoTableItems.length; i++) {
if(geoTableItems[i].get("name") === obj.tileName ) {
sendChat("Geo-API", obj.tileName + " Found OK.")
sendChat("Geo-API", geoTableItems[i].get("avatar") + " Found OK. Should not contain the word market in it.")
}
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment