Untitled
function ELAexportWardrobe(textToWrite) { if(textToWrite === "") {return ChatRoomSendLocal("No content to output, exiting export function.");} //textToWrite = textToWrite.replaceAll('"',""); var textFileAsBlob = new Blob([textToWrite], {type:'text/txt'}); const datenow = new Date(Date.now()); var fileNameToSaveAs = "BC Wardrobe " + JSON.stringify(Player.Name) + " - " + datenow.toLocaleDateString() + " - " + datenow.toLocaleTimeString(); if (!window.webkitURL != null) { fileNameToSaveAs = fileNameToSaveAs + ".txt"; } var downloadLink = document.createElement("a"); downloadLink.download = fileNameToSaveAs; downloadLink.innerHTML = "Download File"; ChatRoomSendLocal("Sending wardrobe file."); if (window.webkitURL != null) { downloadLink.href = window.webkitURL.createObjectURL(textFileAsBlob); } else { downloadLink.href = window.URL.createObjectURL(textFileAsBlob); downloadLink.onclick = destroyClickedElement; downloadLink.style.display = "none"; document.body.appendChild(downloadLink); } downloadLink.click(); } function ELAformatWardrobe() { let craftsString = "" for (craft of Player.Wardrobe) { if (craft == null) {continue} let compressedCraft = LZString.compressToBase64(JSON.stringify(craft)) craftsString = craftsString + compressedCraft + "\n\n\n" } return craftsString } CommandCombine([{ Tag: 'exportwardrobe', Description: ": Exports all wardrobe to a text file.", Action: () => { ELAexportWardrobe(ELAformatWardrobe()) } }])
Leave a Comment