fix: fix unequipping items in avatar sandbox

hopefully fixed for the last time lol keeps breaking, but i think it's finally fixed
This commit is contained in:
Index 2024-07-08 16:05:15 -05:00
parent 7a745a6232
commit c7df8cbea3

View file

@ -593,7 +593,7 @@ async function LoadItems() {
} }
ItemColumn.getElementsByClassName('p-2')[0].addEventListener('click', function(){ ItemColumn.getElementsByClassName('p-2')[0].addEventListener('click', function(){
WearAsset(item) WearAsset(item, item.id)
}) })
}) })
} }
@ -641,25 +641,24 @@ function LoadWearing() {
document.getElementById('wearing').appendChild(ItemColumn) document.getElementById('wearing').appendChild(ItemColumn)
ItemColumn.getElementsByClassName('p-2')[0].addEventListener('click', function(){ ItemColumn.getElementsByClassName('p-2')[0].addEventListener('click', function(){
WearAsset(Cached) WearAsset(Cached, id)
}) })
} }
}) })
} }
function WearAsset(details) { function WearAsset(details, id) {
const ItemID = Object.keys(ItemCache)[Object.values(ItemCache).indexOf(details)] if (Avatar[details.type] !== id && Avatar.items.indexOf(id) === -1) {
if (Avatar[details.type] !== details.id && Avatar.items.indexOf(details.id) === -1) {
// Equip // Equip
if (details.type === 'hat') { if (details.type === 'hat') {
Avatar.items.push(details.id) Avatar.items.push(id)
} else { } else {
Avatar[details.type] = details.id Avatar[details.type] = id
} }
} else { } else {
// Unequip // Unequip
if (details.type === 'hat') { if (details.type === 'hat') {
Avatar.items.splice(Avatar.items.indexOf(ItemID), 1); Avatar.items.splice(Avatar.items.indexOf(parseInt(id)), 1);
} else { } else {
Avatar[details.type] = undefined Avatar[details.type] = undefined
} }