Skip to content

Instantly share code, notes, and snippets.

@walkeralencar
Created February 5, 2021 06:03
Show Gist options
  • Save walkeralencar/448dd46f589eaf7288757687dc6494f9 to your computer and use it in GitHub Desktop.
Save walkeralencar/448dd46f589eaf7288757687dc6494f9 to your computer and use it in GitHub Desktop.
Extract and Transform albiondata-client debug file.
// Extract and Transform data from Albiondata-client debug file.
// HOW TO USE: Load txt debug file, open console(Ctrl+Shift+I), and use the code.
// Author: Walker de Alencar <[email protected]>
function decodeParams(params) {
var prex = new RegExp(/([0-9]{1,}):(-?\d+|.+?(?=\s[0-9]{1,}:))/,"gi");
var r = [];
Array.from(params.matchAll(prex)).forEach(function(param){
if ( param[1] < 252) {
r[param[1]] = param[2];
}
});
return r;
}
var rex = new RegExp(/level=debug msg=\"(.*): \[(.*)\](.*) - map\[(.*)\]\"/,"gi");
var lines = document.body.firstElementChild.innerHTML;
var aodata = [];
var matches = Array.from(lines.matchAll(rex)).forEach(function(data){
if (data[1] == "EventDataType") {
data[1] = "Event";
}
aodata.push({ "type": data[1], "id": parseInt(data[2]), "name": data[3], "values": decodeParams(data[4])});
});
console.log(aodata);
document.body.firstElementChild.innerHTML = JSON.stringify(aodata);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment