Skip to content

Instantly share code, notes, and snippets.

@shdwjk
Last active August 29, 2015 14:13
Show Gist options
  • Save shdwjk/25923c1cc948f272d8bd to your computer and use it in GitHub Desktop.
Save shdwjk/25923c1cc948f272d8bd to your computer and use it in GitHub Desktop.
Roll20 API: SotSA -- DEBUG: outputs the state object to chat in a human readable format. (State of the State Address. =D )
// GIST: https://gist.github.com/shdwjk/25923c1cc948f272d8bd
var SotSA = SotSA || (function() {
'use strict';
var version = 0.1,
schemaVersion = 0.1,
showObj = function(obj) {
var s = JSON.stringify(obj,undefined,". "),
ch = function (c) {
var entities = {
'<' : 'lt',
'>' : 'gt',
"'" : '#39',
'@' : '#64',
'{' : '#123',
'|' : '#124',
'}' : '#125',
'[' : '#91',
']' : '#93',
'"' : 'quot',
' ' : 'nbsp'
};
if(_.has(entities,c) ){
return ('&'+entities[c]+';');
}
return c;
};
s=_.map(s.split(''),ch).join('').replace(/\n/g,'<br>');
sendChat('','/direct '
+'<div style="border: 1px solid blue; font-size:80%;"><pre>'
+s
+"</pre></div>");
},
checkState = function() {
showObj(state);
};
return {
CheckState: checkState
};
}());
on('ready',function() {
'use strict';
SotSA.CheckState();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment