summaryrefslogtreecommitdiff
path: root/misc.py
diff options
context:
space:
mode:
authorDico200 <dico.karssiens@gmail.com>2015-10-11 23:25:12 +0200
committerDico200 <dico.karssiens@gmail.com>2015-10-11 23:25:12 +0200
commit05a74b416b40d3f4e8ebf040e392d293a4ce7170 (patch)
tree05b52a116688b607ee59510340d8f860b2d3cb3f /misc.py
parent920738bd658fbea9c4065791ad2d1510198c5f21 (diff)
/signalstrength progress
Diffstat (limited to 'misc.py')
-rw-r--r--misc.py76
1 files changed, 76 insertions, 0 deletions
diff --git a/misc.py b/misc.py
index dc3475e..5ac4e54 100644
--- a/misc.py
+++ b/misc.py
@@ -142,6 +142,82 @@ def on_sudo_command(sender, command, label, args):
return "&cPlayer %s not found!" % target
+container_levels = dict(
+ FURNACE = [],
+ HOPPER = [],
+ CHEST = [],
+)
+
+
+"""
+Suggestion by Armadillo28, see thread: http://redstoner.com/forums/threads/2213-putting-the-correct-amount-of-items-in-a-container?page=1#reply-14507
+"""
+"""
+@simplecommand("signalstrength",
+ usage = "<signal strength> [item] [data]",
+ aliases = ["ss", "level"],
+ description = "Fills the targeted container with the correct amount of items to achieve the desired signal strength.",
+ amin = 1,
+ amax = 3,
+ helpNoargs = True,
+ helpSubcmd = True,
+ senderLimit = 0)
+def on_signalstrength_command(sender, command, label, args):
+ values = []
+ try:
+ for i in range(len(args)):
+ values[i] = int(args[i])
+ except ValueError:
+ return "&cYou have to enter a number for the signal strength"
+
+
+ target_block = sender.getTargetBlock(None, 5)
+ Validate.notNone(target_block)
+ target_type = str(target_block.getType())
+ Validate.isTrue(target_type in container_levels)
+
+ levels = container_levels[target_type]
+
+ item_value = 1
+ item_type = Material.REDSTONE
+ item_data = 0
+ if len(values) > 1:
+ item_type = Material.getMaterial(values[1])
+ if item_type == None:
+ return "&cThat is not an item ID"
+ if len(values) == 3:
+ item_data = values[2]
+ if not (0 <= item_data <= 15):
+ return "&cThe data must be a number from 0 to a maximum of 15"
+ if values[1] in (items that stack up to 16):
+ item_value = 4
+ elif values[1] in (items that stack up to 1):
+ item_value = 64
+
+ target_strength = values[0]
+
+ item_count = levels[target_strength] / item_value
+
+ if int(item_count) * item_value < levels[target_strength] and (int(item_count) + 1) * item_value >= levels[target_strength + 1]: #if target_strength = 15, first check will always be false, so no IndexError
+ return "&cThe desired signal strength could not be achieved with the requested item type"
+
+ item_count = int(item_count)
+ if item_count % 1 != 0:
+ item_count += 1
+
+ def stack(count):
+ return ItemStack(values[1])
+
+ full_stacks = int(item_count / item_value)
+ for i in range(0, full_stacks) #amount of full stacks
+ target_block.setItem(i, ItemStack())
+"""
+
+
+
+
+
+
@simplecommand("me",
usage = "[message..]",