Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b5fbab06b4 | ||
|
|
f09a0ae083 | ||
|
|
50e4e947c8 | ||
|
|
5a80c74b9a | ||
|
|
c521b8fa86 | ||
|
|
d3d6257496 | ||
|
|
c6ffa5de64 | ||
|
|
e45e3e3e44 |
6
main.py
6
main.py
@@ -15,8 +15,6 @@ except:
|
|||||||
print("[RedstonerUtils] ERROR: Failed to import helpers:")
|
print("[RedstonerUtils] ERROR: Failed to import helpers:")
|
||||||
print(print_traceback())
|
print(print_traceback())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@hook.enable
|
@hook.enable
|
||||||
def on_enable():
|
def on_enable():
|
||||||
info("RedstonerUtils enabled!")
|
info("RedstonerUtils enabled!")
|
||||||
@@ -79,7 +77,9 @@ shared["load_modules"] = [
|
|||||||
# Replacement for LoginSecurity
|
# Replacement for LoginSecurity
|
||||||
"loginsecurity",
|
"loginsecurity",
|
||||||
# Centralized Player class
|
# Centralized Player class
|
||||||
"playermanager"
|
"playermanager",
|
||||||
|
# Plots
|
||||||
|
"plotter"
|
||||||
]
|
]
|
||||||
shared["modules"] = {}
|
shared["modules"] = {}
|
||||||
for module in shared["load_modules"]:
|
for module in shared["load_modules"]:
|
||||||
|
|||||||
66
plotter.py
66
plotter.py
@@ -5,26 +5,50 @@
|
|||||||
on hold because the PlotMe developer continued to develop PlotMe
|
on hold because the PlotMe developer continued to develop PlotMe
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import sys
|
from helpers import *
|
||||||
|
from basecommands import simplecommand
|
||||||
x_plot_size = 3
|
|
||||||
z_plot_size = 3
|
|
||||||
padding = 1
|
|
||||||
|
|
||||||
def base_coords(x, z):
|
|
||||||
pid = plot_id(x, z)
|
|
||||||
return [pid[0] * (x_plot_size + padding), pid[1] * (z_plot_size + padding)]
|
|
||||||
|
|
||||||
def bounds(x, z):
|
|
||||||
base = base_coords(x, z)
|
|
||||||
return [base, [base[0] + x_plot_size, base[1] + z_plot_size]]
|
|
||||||
|
|
||||||
def plot_id(x, z):
|
|
||||||
return [x // (x_plot_size + padding), z // (z_plot_size + padding)]
|
|
||||||
|
|
||||||
|
|
||||||
x = int(sys.argv[1])
|
@simplecommand("plotter",
|
||||||
z = int(sys.argv[2])
|
aliases = ["pt"],
|
||||||
print "id: %s" % plot_id(x, z)
|
senderLimit = 0,
|
||||||
print "base: %s" % base_coords(x, z)
|
description = "Plot commands")
|
||||||
print "bounds: %s" % bounds(x, z)
|
def plotter_command(sender, command, label, args):
|
||||||
|
loc = sender.getLocation()
|
||||||
|
x = loc.getX()
|
||||||
|
z = loc.getZ()
|
||||||
|
plot = Plot.get(x, z)
|
||||||
|
|
||||||
|
if plot:
|
||||||
|
msg(sender, "id: %s" % [plot.idx, plot.idz])
|
||||||
|
msg(sender, "bottom: %s" % [plot.bottomx, plot.bottomz])
|
||||||
|
msg(sender, "top: %s" % [plot.topx, plot.topz])
|
||||||
|
else:
|
||||||
|
msg(sender, "&cThis is not a plot.")
|
||||||
|
|
||||||
|
class Plot:
|
||||||
|
plot_size = 20
|
||||||
|
padding = 3
|
||||||
|
padded_size = plot_size + padding
|
||||||
|
|
||||||
|
def __init__(self, x, z):
|
||||||
|
x = int(x)
|
||||||
|
z = int(z)
|
||||||
|
self.idx = x
|
||||||
|
self.idz = z
|
||||||
|
self.bottomx = x * self.padded_size
|
||||||
|
self.bottomz = z * self.padded_size
|
||||||
|
self.topx = self.bottomx + self.plot_size
|
||||||
|
self.topz = self.bottomz + self.plot_size
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def is_border(x, z):
|
||||||
|
xborder = Plot.plot_size < x % Plot.padded_size < Plot.padded_size
|
||||||
|
zborder = Plot.plot_size < z % Plot.padded_size < Plot.padded_size
|
||||||
|
return xborder or zborder
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def get(x, z):
|
||||||
|
idx = x // Plot.padded_size
|
||||||
|
idz = z // Plot.padded_size
|
||||||
|
return None if Plot.is_border(x, z) else Plot(idx, idz)
|
||||||
|
|||||||
Reference in New Issue
Block a user