From 83417e2a4d6b2e67c6e91511195dcd2d080b1632 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 9 Dec 2016 23:48:31 +1100 Subject: [PATCH] Updated Printing the furthest plot (markdown) --- Printing-the-furthest-plot.md | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/Printing-the-furthest-plot.md b/Printing-the-furthest-plot.md index 6639190..adbab8b 100644 --- a/Printing-the-furthest-plot.md +++ b/Printing-the-furthest-plot.md @@ -1,5 +1,3 @@ -Download: https://www.dropbox.com/s/h544xf6susqlonf/furthest.js?dl=0 - ``` javascript /* * Script to find the furthest plot from origin in a world: @@ -7,29 +5,17 @@ Download: https://www.dropbox.com/s/h544xf6susqlonf/furthest.js?dl=0 */ if (PS.isPlotWorld("%s0")) { - var plots = PS.getAllPlotsRaw().get("%s0").values().toArray(); - var max = 0; - var maxplot; - for (var i in plots) { - var plot = plots[i]; - if (plot.x > max) { - max = plot.x; - maxplot = plot; + plots=PS.getPlotAreaByString("l").getPlots(); + iter=plots.iterator(); + max=0; + while(iter.hasNext()){ + plot=iter.next(); + if(t=Math.max(Math.abs(plot.id.x),Math.abs(plot.id.y))>max){ + max=t; + maxPlot=plot } - if (plot.y > max) { - max = plot.y; - maxplot = plot; - } - if (-plot.x > max) { - max = -plot.x; - maxplot = plot; - } - if (-plot.y > max) { - max = -plot.y; - maxplot = plot; - } - } - PS.class.static.log(plot + " &r| " + plot.id); + }; + PS.class.static.log(maxPlot); } else { PlotPlayer.sendMessage("Usage: /plot debugexec runasync furthest.js ");