Data Replacement of Core Template

/*
RUN IT: https://www.w3schools.com/code/tryit.asp?filename=GQ5I94C0LY8C
<!DOCTYPE html>
<html>
<body>

<p>Emulate the data array to Core</p>

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

<textarea id="ta">  Name: "^N"
  Transform {
    Location {
      X: ^X
      Y: ^Y
      Z: ^Z</textarea>

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

<script>
*/
// in the .pbt file with Notepad++: search and replace @@X: ^X


var res = "";

var _find = `  Name: "^N"
  Transform {
    Location {
      X: ^X
      Y: ^Y
      Z: ^Z`;

var _replace = new Array([-125.11,-3.80,2.19,"Priest of Discord"],
[-149.72,150.01,2.19,"Silna Songsmith"],
[-148.83,161.70,5.19,"Deputy Percin"],
[-201.84,246.75,2.19,"Deputy Banto"],
[-342.93,317.11,2.19,"Deputy Finlip"],
[-445.59,402.79,-0.54,"Deputy Kapop"],
[-633.02,247.78,2.19,"a sage apprentice"],
[-601.72,277.81,2.19,"a sage apprentice"],
[-425.41,19.68,-5.81,"Fiddy Bobick"],
[-328.77,5.62,-3.81,"Wibble Bramblebush"],
[-47.20,-9.03,2.19,"Deputy Higrin"],
[-52.14,45.60,2.19,"Deputy Goltin"],
[-161.09,57.74,-1.82,"Deputy Antana"],
[-148.92,58.25,-1.81,"Deputy Sertlin"],
[-172.69,86.41,4.19,"Donlo Goobler"],
[-139.81,85.29,4.19,"Rantho Goobler"],
[-147.42,129.30,4.19,"Deputy Lowmot"],
[-146.89,105.19,4.19,"Deputy Cheel"],
[-205.27,125.47,4.19,"Marshal Ghobber"],
[-173.85,89.35,38.19,"Marshal Lanena"],
[-173.12,84.67,40.47,"Deputy Regno"],
[-136.64,98.49,38.19,"Marshal Anrey"],
[-135.73,90.23,38.19,"Deputy Niepo"],
[-161.77,95.32,46.16,"Mayor Gubbin"],
[-153.13,92.05,46.16,"Sheriff Roglio"],
[-139.62,85.56,4.19,"Rantho Goobler"],
[-173.03,86.06,4.19,"Donlo Goobler"],
[-210.06,-115.89,2.19,"Twippie Diggs"],
[-243.26,-17.93,2.19,"Meeka Diggs"],
[-181.36,-29.12,2.19,"Bouncer Bogglebin"],
[-204.01,-86.98,2.19,"Rueppy Kutpurse"],
[-188.14,-64.29,2.19,"Mac Deeppockets"],
[-206.43,-49.35,2.19,"Flyndia Deeppockets"],
[-177.68,-48.96,2.19,"Blinza Toepopal"],
[-200.81,-92.07,14.19,"Hebber Druneny"],
[-181.70,-78.05,14.19,"Bouncer Bigboot"],
[-165.12,-66.25,14.19,"a tavern patron"],
[-173.76,-36.71,14.19,"Burtle Barrelbelly"],
[-198.28,-27.62,14.19,"Toelia Snuckery"],
[-177.06,-45.76,14.19,"a tavern patron"],
[-191.10,-59.92,14.19,"Ace Slighthand"],
[-161.33,-56.72,14.19,"Shayde Higginsbot"],
[-211.85,-60.32,24.19,"Shutter Silentstep"],
[-177.88,-52.67,40.19,"Gaffin Deeppockets"],
[-189.12,-51.32,40.19,"Lendel Deeppockets"],
[-90.20,-159.33,-9.81,"Marta Claytoe"],
[-150.91,-181.86,-9.81,"Uma Sweetcookie"],
[-329.62,-235.61,-13.81,"Deputy Dopkin"],
[-330.74,-218.93,-13.81,"Jano Jinglebelly"],
[-332.98,-251.17,-9.81,"Thekela Meepup"],
[-343.17,-275.66,-9.81,"Deputy Pittin"],
[-329.81,-210.20,-9.81,"Reebo Leafsway"],
[-350.65,-246.10,-13.81,"Pipple Purpleroot"],
[-359.95,-245.82,-13.81,"Altha Shadowjumper"],
[-349.61,-207.87,-13.81,"Gilth Harvester"],
[-360.08,-208.85,-13.81,"Frappy Slimfinger"],
[-379.98,-224.37,-17.81,"Misty Valefriend"],
[-380.64,-230.87,-17.81,"Hendi Mrubble"],
[-387.22,-229.87,-13.81,"Slim Waterman"],
[-387.19,-224.13,-13.81,"Beek Guinders"],
[-422.26,-238.29,-13.81,"Gapeers Johhanis"],
[-421.27,-229.54,-13.81,"Alice Sweetoven"],
[-422.94,-211.10,-13.81,"a halfling acolyte"],
[-416.30,-206.61,-13.81,"Blippo Stumbletoe"],
[-341.80,-139.34,-9.81,"a shady halfling"],
[-357.52,-142.27,-9.81,"Bartle Barnick"],
[-393.73,-124.98,-9.81,"Uner Gnarltrunk"],
[-409.82,-139.54,-8.78,"Shakey Scarecrow"],
[-449.70,-95.65,-5.81,"Hobb Tagglefoot"],
[-370.47,-79.81,-9.81,"Bodbin Gimble"],
[-343.43,-86.47,-9.81,"Daleen Leafsway"],
[-408.61,-75.02,-11.81,"Bumpy Quickfinger"],
[-408.54,-61.45,-11.81,"Staria Longhair"],
[-424.52,-37.23,-11.81,"Hibbs Rootenpaw"],
[-418.73,-29.02,-11.81,"Ilscent Tagglefoot"],
[-384.06,-29.55,-11.81,"Torth Largefoot"],
[-381.05,-68.73,-11.81,"Crista Tagglefoot"],
[-384.04,-29.60,-11.81,"Torth Largefoot"]);



/*
  Name: "^N"
  Transform {
    Location {
      X: ^X
      Y: ^Y
      Z: ^Z
*/




// string.replaceArray()
String.prototype.replaceFromArray = function(find, replace) {
  var replaceString = this;
  var _temp;

  for (var i = 0; i < replace.length; i++) {
    _temp = `  Name: "`+replace[i][3]+`"`;
    _temp += `
  Transform {
    Location {
      `;
    _temp += `X: `;
    _temp += (replace[i][0]*.3048)*60;//ft->m
    _temp += `
      Y: `;
    _temp += (replace[i][1]*.3048)*60;
    _temp += `
      Z: `;
    _temp += (replace[i][2]*.3048)*60;
    replaceString = replaceString.replace(find, _temp);
  }
  return replaceString;
};


function myFunction() {
    var textarea = document.getElementById("ta").value;
    res = textarea.replaceFromArray(_find, _replace);
    document.getElementById("demo").innerHTML = res;


}//end fn

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

Latest Posts