Created
September 5, 2022 20:19
-
-
Save keithcurtis1/7a36198ee56124838f05b1dc7269fb50 to your computer and use it in GitHub Desktop.
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("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