Skip to content

Instantly share code, notes, and snippets.

@BaldarSilveraxe
Created November 30, 2013 16:56
Show Gist options
  • Save BaldarSilveraxe/7721452 to your computer and use it in GitHub Desktop.
Save BaldarSilveraxe/7721452 to your computer and use it in GitHub Desktop.
Roll20 API
var roll20API = roll20API || {};
//NOTES:
//
//***Display Names***
//Display Names should be one word, nospaces or special characters and distinct.
//
//***roll20API.Owner = "135636"***
//Campaign Owner. You can find your own personal user id by visiting the wiki and clicking on your name in the
//left-hand sidebar. On your wiki page you will see "Home » User:#" below your name on your userpage, where #
//is your user id.
//
//GM Roster
//Create a handout named "GM_Roster" and in the "Can Be Edited By" field place all the names of the GMs for the
//campaign. Keep current as required.
//campaign Owner
roll20API.Owner = "135636";
//API Command variables
roll20API.apiCommands = [
//Player commands, common
{Description: "Blind roll to GM.", Type: "Player", Long: "broll", Short: "br", Family: "Common"},
{Description: "API help menu.", Type: "Player", Long: "help", Short: "h", Family: "Common"},
{Description: "Core rules.", Type: "Player", Long: "rules", Short: "r", Family: "Common"},
{Description: "Monsters.", Type: "Player", Long: "monsters", Short: "m", Family: "Common"},
{Description: "Wizard spells.", Type: "Player", Long: "wizard", Short: "w", Family: "Common"},
{Description: "Priest spells.", Type: "Player", Long: "priest", Short: "p", Family: "Common"},
{Description: "Wizard schools.", Type: "Player", Long: "school", Short: "sc", Family: "Common"},
{Description: "Priest spheres.", Type: "Player", Long: "sphere", Short: "sp", Family: "Common"},
{Description: "Equipment Lists.", Type: "Player", Long: "equipment", Short: "eq", Family: "Common"},
//Family commands, language
{Description: "Speak in kender.", Type: "Player", Long: "kender", Short: "k", Family: "Language"},
{Description: "Speak in dwarven.", Type: "Player", Long: "dwarven", Short: "d", Family: "Language"},
{Description: "Speak in elven.", Type: "Player", Long: "elven", Short: "e", Family: "Language"},
{Description: "Speak in orcish.", Type: "Player", Long: "orish", Short: "o", Family: "Language"},
//GM commands, common
{Description: "Fully heal all targets or all.", Type: "GM", Long: "heal", Short: "hl", Family: "Common"},
{Description: "Start a new round.", Type: "GM", Long: "new", Short: "n", Family: "Common"},
{Description: "Pickpocketing success.", Type: "GM", Long: "pickpocket", Short: "pp", Family: "Common"},
{Description: "Critical Hits and Fumbles.", Type: "GM", Long: "critical", Short: "crt", Family: "Common"},
//Owner commands, common
{Description: "See player ids.", Type: "Owner", Long: "ids", Short: "ids", Family: "Common"}
];
//API:Events****************************************************************************************
on("ready", function() {
//API:Events:Add Character**********************************************************************
on("add:character", function(addedChar) {
roll20API.processAttribs(addedChar);
roll20API.processAbilities(addedChar);
addedChar.set({ "bio": roll20API.bioText});
});
//API:Events:ChatMessage************************************************************************
on("chat:message", function(msg) {
//API commands
if(msg.type == "api"){
roll20API.processMessage(msg);
roll20API.processAPIswitch();
};
//rollresutls
if (msg.type == "gmrollresult" || msg.type == "rollresult" || msg.inlinerolls !== undefined) {
if (msg.type == "gmrollresult" || msg.type == "rollresult") {
if (msg.type == "gmrollresult"){
roll20API.gmrollresult = true;
}else{
roll20API.gmrollresult = false;
};
roll20API.rollPlayerid = msg.playerid
roll20API.rollJson = JSON.parse(msg.content);
//sendChat("API", "~~~~");
//sendChat("API", "roll20API.gmrollresult = " + roll20API.rollPlayerid);
//sendChat("API", "roll20API.gmrollresult = " + roll20API.gmrollresult);
//sendChat("API", "roll20API.rollJson.total = " + roll20API.rollJson.total);
};
if (msg.inlinerolls !== undefined) {
roll20API.inlinerolls = msg.inlinerolls;
roll20API.rollJson = JSON.parse(roll20API.inlinerolls);
log(roll20API.inlinerolls);
};
};
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment