Created
December 17, 2018 03:00
-
-
Save Bastlifa/a103b97c956eed4422eaa34eb208ebf3 to your computer and use it in GitHub Desktop.
Roll20 Table Maker via Blank Character Sheet
This file contains hidden or 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
//TableMaker | |
//Make a character with no sheet. | |
//All attributes are table entries, all current values are weights. | |
//Drag token (can be default) to canvas. Select it. Type !TableMaker <table name> into chat and hit enter | |
//Table name must use dashes for spaces (probably) | |
//Transmog your table over to whatever game you need it for. | |
//This probably sucks, don't use it. | |
on("ready", function() { | |
on("chat:message", function (msg) { | |
if (msg.type === "api" && msg.content.split(' ')[0] === "!TableMaker") { | |
MakeTable(msg); | |
} | |
}); | |
}); | |
function MakeTable(msg) | |
{ | |
let reps = getObj(msg.selected[0]._type,msg.selected[0]._id).get('represents'); | |
let attributeFields = findObjs({_type: "attribute", characterid: reps}); | |
let aTableItems = []; | |
let aTableWeights = []; | |
for (let i=0; i<attributeFields.length; i++) | |
{ | |
aTableItems.push(attributeFields[i].get("name")); | |
aTableWeights.push(attributeFields[i].get("current")); | |
} | |
let tableName = msg.content.split(' ')[1]; | |
if (aTableItems.length != aTableWeights.length) {sendChat("", "Table Items != Table Weights"); return;} | |
let tableToMake = createObj('rollabletable', { | |
name: tableName | |
}); | |
let tableID = tableToMake.id; | |
for (let i=0; i<aTableItems.length; i++) | |
{ | |
createObj('tableitem', { | |
name: aTableItems[i], | |
weight: aTableWeights[i], | |
_rollabletableid: tableID | |
}); | |
} | |
sendChat("", "Table " + tableName + " created with " + String(aTableItems.length) + " entries."); | |
return; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment