Skip to content

Instantly share code, notes, and snippets.

@JackNoordhuis
Created August 5, 2017 13:55
Show Gist options
  • Save JackNoordhuis/43ee156f727451896eda65f3b39b8e84 to your computer and use it in GitHub Desktop.
Save JackNoordhuis/43ee156f727451896eda65f3b39b8e84 to your computer and use it in GitHub Desktop.
<?php
/*
* Data in the form of: x y z\nx y z
*/
$data =
'384 1 -71
383 1 -26
384 1 25
383 1 70
480 1 -71
481 1 -26
480 1 25
481 1 70
575 1 -71
576 1 -26
575 1 25
576 1 70
671 1 -71
672 1 -26
671 1 25
672 1 70
767 1 -71
768 1 -26
767 1 25
768 1 70
863 1 -71
864 1 -26
863 1 25
864 1 70
959 1 -71
960 1 -26
959 1 25
960 1 70
1055 1 -71
1056 1 -26
1055 1 25
1056 1 70
1151 1 -71
1152 1 -26
1151 1 25
1152 1 70
-65 1 361
-64 1 406
47 1 361
48 1 406
-65 1 457
-64 1 502
47 1 457
48 1 406
-65 1 553
-64 1 598
47 1 553
48 1 598
-65 1 649
-64 1 695
47 1 649
48 1 695
-65 1 745
-64 1 790
47 1 745
48 1 790
-65 1 841
-64 1 886
47 1 841
48 1 886
-65 1 937
-64 1 982
47 1 937
48 1 982
-65 1 1033
-64 1 1078
47 1 1033
48 1 1078
-65 1 1129
-64 1 1173
47 1 1129
48 1 1173
-401 1 -71
-400 1 -26
-401 1 25
-400 1 70
-497 1 -71
-496 1 -26
-497 1 25
-496 1 70
-593 1 -71
-592 1 -26
-593 1 25
-592 1 70
-689 1 -71
-688 1 -26
-689 1 25
-688 1 70
-785 1 -71
-784 1 -26
-785 1 25
-784 1 70
-881 1 -71
-880 1 -26
-881 1 25
-880 1 70
-977 1 -71
-976 1 -26
-977 1 25
-976 1 70
-1073 1 -71
-1072 1 -26
-1073 1 25
-1072 1 70
-1169 1 -71
-1168 1 -26
-1169 1 25
-1168 1 70
-64 1 -362
-65 1 -407
48 1 -362
49 1 -407
-64 1 -458
-65 1 -503
48 1 -458
49 1 -503
-64 1 -554
-65 1 -599
48 1 -554
49 1 -599
-64 1 -650
-65 1 -695
48 1 -650
49 1 -695
-64 1 -746
-65 1 -791
48 1 -746
49 1 -191
-64 1 -842
-65 1 -886
48 1 -842
49 1 -886
-64 1 -938
-65 1 -98
348 1 -938
49 1 -983
-64 1 -1034
-65 1 -1079
48 1 -1034
49 1 -1079
-64 1 -1130
-65 1 -1175
48 1 -1130
49 1 -1175';
$data = preg_replace("/[\r\n]+/", "\n", $data); // make sure any combination of \n and/or \r is replaced with a single \n
$coords = explode("\n", $data); // seperate coords into individual array elements
$maps = [];
for($i = 0; $i < count($coords); $i += 2) { // two spawns per arena so increment by twos
$maps[] = ["spawn-positions" => [make_pretty_xyz($coords[$i]), make_pretty_xyz($coords[$i + 1])]]; // assign a map it's two arena spwn points
}
/*
* Simple function to make xyz coords look pretty
*/
function make_pretty_xyz($string) {
list($x, $y, $z) = explode(" ", $string);
return "{$x}, {$y}, {$z}";
}
echo json_encode($maps); // dump the json data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment