Created
April 1, 2020 07:05
-
-
Save elcool0r/bbce6bb1918d69724b29cef75e1c8976 to your computer and use it in GitHub Desktop.
Wild Magic Notify
This file contains 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
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