Skip to content

Instantly share code, notes, and snippets.

@elcool0r
Created April 1, 2020 07:05
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 elcool0r/bbce6bb1918d69724b29cef75e1c8976 to your computer and use it in GitHub Desktop.
Save elcool0r/bbce6bb1918d69724b29cef75e1c8976 to your computer and use it in GitHub Desktop.
Wild Magic Notify
on('chat:message', function (msg) {
if (msg.playerid.toLowerCase() != "api" && msg.rolltemplate) {
message = msg.content
if (message.includes("level")) {
var level_pattern = /level( )?=.*[0-9]/i;
var spellbase = msg.content.match(level_pattern)[0];
var spelllevel = parseInt(spellbase.split("}")[0].substr(-1));
if (spelllevel > 0) {
var cnamebase = msg.content.split("charname=")[1];
var cname = cnamebase ? cnamebase.replace(/ {{.*}} /, '').trim() : (msg.content.split("{{name=")[1] || '').split("{{")[0].trim();
var character = cname ? findObjs({
name: cname,
_type: "character"
})[0] : undefined;
var wildmagic = findObjs({
characterid: character.get('_id'),
name: "subclass",
current: "Wild Magic"
});
if (wildmagic.length) {
sendChat(msg.who, "<div class='sheet-rolltemplate-simple' style='margin-top:-7px;'><div class='sheet-container'><div class='sheet-label' style='margin-top:5px;'><span>Wild Magic!<br>Roll your Destiny!<br></span></div></div></div>");
}
}
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment