Created
April 15, 2021 16:55
-
-
Save 0x6273/9df620d7006e1c0336f9020834f7fbd1 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
// this is a hacky workaround to make cards display their name when you hover | |
// over them. it requires setting the texture override url fragment to the | |
// card name. | |
import { Card, GameObject, world } from "@tabletop-playground/api"; | |
export function get_name(obj: Card): string { | |
if (obj.getStackSize() !== 1) { | |
return ""; | |
} | |
let url = obj.getCardDetails().textureOverrideURL; | |
return url.substring(url.search("#") + 1); | |
} | |
export function fix_names() { | |
for (let obj of world.getAllObjects()) { | |
// replace this with your card's template id | |
if (obj.getTemplateId() !== "EF0BC6BE48D0FE8C791D37908868CA62") { | |
continue; | |
} | |
if ((<Card>obj).getStackSize() !== 1 || is_face_down(obj)) { | |
// we don't want a stack of multiple cards, or cards | |
// that are face-down, to have a name. | |
obj.setName(""); | |
} else { | |
obj.setName(get_name(<Card>obj)); | |
} | |
} | |
} | |
function is_face_down(obj: GameObject): boolean { | |
let roll = obj.getRotation().roll; | |
return -90 < roll && roll < 90; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment