Skip to content

Instantly share code, notes, and snippets.

@keithcurtis1
Created September 5, 2022 20:19
Show Gist options
  • Save keithcurtis1/7a36198ee56124838f05b1dc7269fb50 to your computer and use it in GitHub Desktop.
Save keithcurtis1/7a36198ee56124838f05b1dc7269fb50 to your computer and use it in GitHub Desktop.
on("ready", function () {
const theGM = findObjs({
type: 'player'
})
.find(o => playerIsGM(o.id));
on("change:campaign:playerpageid", function () {
setTimeout(function () {
pingPlayerToken();
},
1500);
});
on("chat:message", function (msg) {
if (msg.type == "api" && msg.content.indexOf("!pingStart") == 0) {
pingPlayerToken();
}
});
on("change:graphic", function (obj, prev) {
if (obj.get("name") === "Party") {
let originalColor = theGM.get("color");
theGM.set("color",
"transparent");
pingPlayerToken();
setTimeout(function () {
theGM.set("color", originalColor);;
},
1200);
}
});
function pingPlayerToken() {
var tokens = findObjs({
_name: "Party",
_type: "graphic",
_pageid: Campaign().get("playerpageid")
});
var playerStartToken = tokens[
0
];
if (playerStartToken === undefined) {
return;
}
sendPing(playerStartToken.get("left"), playerStartToken.get("top"), playerStartToken.get("pageid"), theGM.id, true);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment