eadorin / about-face

FoundryVTT Module to rotate tokens on move
6 stars 17 forks source link

Broken indicators #45

Closed Z-Machine closed 3 years ago

Z-Machine commented 3 years ago

https://github.com/eadorin/about-face/blob/595cf27cb076108675e368ca6e2e14ee35c77eba/src/scripts/TokenIndicator.js#L121 user[0] can be null and causes the module to stop drawing indicators once a null user is hit.

This seems to be happening when LootSheet5eNPC tokens that are on the map. image

As a bandage I added a null check.

async generateDefaultIndicator() {

    let indicator_color = colorStringToHex("FF0000");
    if (this.token.actor) {
        if (this.token.actor.hasPlayerOwner) {
            let user = await Helpers.getTokenOwner(this.token);
            if (user.length > 0) {
                if (user[0] != null && user[0].data.color != null) { //Bandage
                    indicator_color = colorStringToHex(user[0].data.color);
                }
            }
        }
    }

    let triangle = this.generateTriangleIndicator("normal", indicator_color, 0x000000);
    return triangle;
}

https://github.com/eadorin/about-face/blob/595cf27cb076108675e368ca6e2e14ee35c77eba/src/about-face.js#L133 This happens when I lock the rotation of a token image

Flintwyrm commented 3 years ago

I had the same Issue

Screenshot_580 Screenshot_581

edzillion commented 3 years ago

Thanks for the report. This should be fixed in latest.

Thanks for the patch @Z-Machine - I don't fully understand what's happening in that getTokenOwner() function so this will work for now. Do you have any good info on getting the owned user? This seems terribly convoluted:

let owners = getKeyByValue(token.actor.data.permission,3);

edzillion commented 3 years ago

I am going to close as this has been patched I believe.