
Alright, so here's the down and dirty of it. I find myself time and time again using this at the top of every API script I write. var Master = Master || {};
on("chat:message", function (msg) {
if (msg.type != "api"){return};
log(msg.content);
//If msg has inline rolls, convert them to integers.
if(_.has(msg,'inlinerolls')){
msg.content = _.chain(msg.inlinerolls)
.reduce(function(m,v,k){
m['$[['+k+']]']=v.results.total || 0;
return m;
},{})
.reduce(function(m,v,k){
return m.replace(k,v);
},msg.content)
.value();
};
//Convert msg.content into callable tags via Master.[Tag] (Ex. Master.target_id)
var command = msg.content.split(" ", 1);
var n = msg.content.split(" --");
var a = 1;
var chatObj = {};
var Tags = "";
var Content = "";
while(n[a]) {
Tag = n[a].substring(0,n[a].indexOf("|"));
Content = n[a].substring(n[a].indexOf("|") + 1);
chatObj[Tag] = Content;
a++;
};
//log(chatObj);
}); Is there any way to make this into a function or to just flat out pull info from it from another API? You know, via var thisApiMaster = MasterAPI.Master; Or something along those lines? I'm a pretty big rookie at this stuff, knowing pretty much just how to bash out an API that makes something I want to happen, happen. Stuff like player-targeted heal spells that won't go over max HP of the target and other simple things. While I have your attention, a question along the same lines. Is there a way to pull a value out of the Powercard script and strong-arm it into one of my scripts? That way we get the nice pretty look of Powercard (which is so nice) but I could still do things like my healing script using those same values? Right now we get around it by rolling the Powercard heal for looks, then a separate macro to literally just inject HP into the selected token. And as we all know, cutting down on the 800 macros most people already have would be a pleasure. Either way, thanks in andvance! EDIT: changed local variable "Master" to "chatObj"