Extract Game Data for Usable Import Array

<!DOCTYPE html>
<html>
<body>

<p>Click the button to extract the data.</p>

<button onclick="myFunction()">Try it</button>


<textarea id="ta">INPUT</textarea>


<textarea id="demo">OUTPUT</textarea>

<script>



var res = "new Array(";
function myFunction() {
    // get single line
    var lines = document.getElementById("ta").value.split('\n');
    document.getElementById("demo").innerHTML = "";
    let _read = new Array();
    let _together = "";
    let _toggle = 0;
    let _myName = "";
    let _myX = "";
    let _myY = "";
    let _myZ = "";
    let _xyzdata = "";
    var myLine = "";
    var myLine2 = "";
    var ni = false;
   for(var i = 0;i < lines.length;i++){
      //code here using lines[i] which will give you each line

      ni = lines[i].includes("You say, '");
      if(ni){
        myLine = lines[i].substring(
        lines[i].lastIndexOf("You say, '") + 10,
        lines[i].lastIndexOf("'"));
        _myName = myLine;// record Name
        // now get xyz values
        myLine2 = lines[i+1].replace("Location is ","Location is,");
        _myX = myLine2.split(',')[2].replace(" ","");//no spaces
        _myY = myLine2.split(',')[1].replace(" ","");
        _myZ = myLine2.split(',')[3].replace(" ","");
        res += `[`+(_myX/3.281*-100).toFixed(2)+`,`+(_myY/3.281*-100).toFixed(2)+`,`+(_myZ/3.281*100).toFixed(2)+`,"`+_myName+`"],\n`;        
      }
    }
    res += ");";    
    document.getElementById("demo").innerHTML = res;
}//end fn


</script>
</body>
</html>

Latest Posts