Keith, I'm trying to use this scriptlet in a new game and it doesn't seem to be working. I had saved the code that you posted a year ago to a text file. I copied that into a new script for my new game, restarted the sandbox, and added the " **" to the end of a PC token's name, but no icon shows up when I move the token into different light levels. I did try both the Default and Experimental sandboxes. Does this scriptlet not work with the new VTT? I found the old forum post and tried going to the github link you provided, checking if you had posted an updated version but that link gets me a "404 Not found" error. Here is the script that I saved: on("change:graphic", function(obj, prev) {
let tokenID = obj.get("id");
let page = getObj("page", Campaign().get("playerpageid"));
if (typeof checkLightLevel !== "undefined" && page.get("dynamic_lighting_enabled")) {
if (prev.left !== obj.get("left") || prev.top !== obj.get("top")) {
function containsIllumination(illumination, obj) {
return illumination.some(item => obj.name.includes(item));
}
function updateIllumination(obj, lightLevel, dimLight, darkness) {
let newName;
if (lightLevel <= darkness) {
newName = obj.name.slice(0, -3) + " 🌑";
} else if (lightLevel > darkness && lightLevel <= dimLight) {
newName = obj.name.slice(0, -3) + " 🌗";
} else {
newName = obj.name.slice(0, -3) + " 🌕";
}
return newName;
}
let dimLight = 50;
let darkness = 20;
let lightLevel = (checkLightLevel.isLitBy(obj.get("id")).total * 100).toFixed();
let illumination = [" **", " 🌑", " 🌗", " 🌕"];
if (containsIllumination(illumination, prev)) {
let newName = updateIllumination(prev, lightLevel, dimLight, darkness);
obj.set("name", newName);
}
}
}
});