8 Commits
dev ... plotter

Author SHA1 Message Date
jomo
b5fbab06b4 /plotter must be run by player 2015-08-13 00:03:05 +02:00
jomo
f09a0ae083 restructure plotter, use Plot class 2015-08-12 23:48:16 +02:00
jomo
50e4e947c8 detect if standing on pathway 2015-08-12 23:05:02 +02:00
jomo
5a80c74b9a turn plotter.py into actual plugin, not cli tool 2015-08-12 22:00:03 +02:00
NEMESIS13cz
c521b8fa86 Removed plotgen.py, added plotter.py to module list 2015-08-11 21:18:03 +02:00
NEMESIS13cz
d3d6257496 Removed 2015-08-11 21:17:44 +02:00
NEMESIS13cz
c6ffa5de64 Added getDefaultGenerator 2015-08-11 21:05:58 +02:00
NEMESIS13cz
e45e3e3e44 Created the plot-generator 2015-08-11 21:05:38 +02:00
2 changed files with 48 additions and 24 deletions

View File

@@ -15,8 +15,6 @@ except:
print("[RedstonerUtils] ERROR: Failed to import helpers:")
print(print_traceback())
@hook.enable
def on_enable():
info("RedstonerUtils enabled!")
@@ -79,7 +77,9 @@ shared["load_modules"] = [
# Replacement for LoginSecurity
"loginsecurity",
# Centralized Player class
"playermanager"
"playermanager",
# Plots
"plotter"
]
shared["modules"] = {}
for module in shared["load_modules"]:

View File

@@ -5,26 +5,50 @@
on hold because the PlotMe developer continued to develop PlotMe
"""
import sys
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)]
from helpers import *
from basecommands import simplecommand
x = int(sys.argv[1])
z = int(sys.argv[2])
print "id: %s" % plot_id(x, z)
print "base: %s" % base_coords(x, z)
print "bounds: %s" % bounds(x, z)
@simplecommand("plotter",
aliases = ["pt"],
senderLimit = 0,
description = "Plot commands")
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)