I am currently on a dashboard which is open as an external window. I got the avatar name and can display this on the external site. Now I would like to show an image of the avatar.
Is there an easy way to get a single “image” of the avatar from the outfitString. Or a function that “compiles” the outfitString to HTML or whatever?
Thanks 4 Infos or ideas
1 Like
Hi @informatics , have you find a way to do this? May you share your approach? Thanks.
Hey @bentinata ,
this was the code used, to create from a user object an avatar Url.
module.exports = {
makeAvatarUrl: (outfitString) => {
let url = 'https://dynamic-assets.gather.town/sprite/avatar';
const order = ['skin', 'bottom', 'shoes', 'top', 'glasses', 'facial_hair', 'hair', 'hat', 'other'];
const outfit = JSON.parse(outfitString);
// Try Costume
try {
return url + '-' + outfit['costume'].parts[0].spritesheetId + ".png";
} catch (e) {}
/* https://dynamic-assets.gather.town/sprite/avatar-
dQCYs4n7O99ksXuBIe33 skin
IeTiKgFytOsyQWBrQgAc bottom
bjYIM3RJKVm2mwEI3BrQ shoes
6313mtew3Zh1QX05N717 top
PkaSuuEBwsEMkU6YXYzz glasses
vCfMTJtUtaoRVjFBejU0 facial_hair
f9h9IZO2XdpOVkvb8Jc7 hair
This file has been truncated. show original
I basically reversenginieerg, what I found in the web version … but the commit is 2 years old
Cheers Info
2 Likes
@bentinata This typescript function will give you a gather.town URL with the avatar image.
I’ve been using it without any issues so far.
export const getPlayerAvatar = (player: Partial<Player>) => {
if (!player) return "";
const outfit: DBOutfit = player.currentlyEquippedWearables!;
const profileImageParts = Object.values(outfit)
.filter((outfitLayer) => outfitLayer)
.join(".");
return `https://dynamic-assets.gather.town/v2/sprite-profile/avatar-${profileImageParts}.png?d=.`;
};
3 Likes