Added inventory cycle function

This commit is contained in:
shillingp
2014-06-23 22:52:04 +00:00
parent 32eae1b248
commit af302f2ca9

19
misc.py
View File

@@ -92,6 +92,25 @@ def onPlayerInteractEntity(event):
sender.playSound(entity.getLocation(), "mob.cow.say", 1, 1)
#
# Cycling around the item bar will switch between rows of the inventory
#
@hook.event("inventory.PlayerItemHeldEvent", "normal")
def onHeldEvent(event):
player = event.getPlayer()
prev_slot = event.getPreviousSlot()
new_slot = event.getNewSlot()
if (prev_slot == 0 and new_slot == 8):
doCycle(player, 27)
elif (prev_slot == 8 and new_slot == 0):
doCycle(player, 9)
def doCycle(player, e):
inv = player.getContents()
for x in range (0, 9):
inv[x], inv[x+e] = inv[x+e], inv[x]
#
# Various text commands
#