Farrk

PIM_InventoryStore/Restore

Dec 24th, 2013
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. ArmorHotbar="west"
  2. Inventory="east"
  3.  
  4.  
  5. transferToChests=0
  6. function transferInventory()
  7. --print("entering function")
  8.  
  9. local pim=peripheral.wrap("top")
  10. while pim.getInventoryName() ~= "container.inventory" do
  11. sleep(0)
  12. end
  13. --print(pim.getInventoryName())
  14. if pim.getInventoryName() == "container.inventory" then
  15. for w=1,40 do
  16. --print("checking slot "..w)
  17. sleep(0)
  18. if pim.getStackInSlot(w) ~= nil then
  19. transferToChests=1
  20. break
  21. end
  22. end
  23. if transferToChests==0 then
  24. --print("transferToChests equals 0")
  25. local ender1=peripheral.wrap("left")
  26. local ender2=peripheral.wrap("right")
  27. for w=1,27 do
  28. sleep(0)
  29. pim.pullItemIntoSlot(Inventory,w,64,w+9)
  30. end
  31. for w=1,13 do
  32. sleep(0)
  33. if w<=9 then
  34. pim.pullItemIntoSlot(ArmorHotbar,w,64,w)
  35. else
  36. pim.pullItemIntoSlot(ArmorHotbar,w,64,w+27)
  37. end
  38. end
  39. else
  40. --print("transferToChests equals 1")
  41. --transfer items into chests
  42. for x=10,36 do
  43. sleep(0)
  44. pim.pushItemIntoSlot(Inventory,x,64,x-9)
  45. end
  46. for x=1,9 do
  47. sleep(0)
  48. pim.pushItemIntoSlot(ArmorHotbar,x,64,x)
  49. end
  50. for x=37,40 do
  51. sleep(0)
  52. pim.pushItemIntoSlot(ArmorHotbar,x,64,x-27)
  53. end
  54. end
  55. else
  56. sleep(0)
  57. end
  58. end
  59.  
  60.  
  61. while 1 do
  62. os.pullEvent("redstone")
  63. os.pullEvent("redstone")
  64. transferToChests=0
  65. transferInventory()
  66. os.pullEvent("redstone")
  67. end
Advertisement
Add Comment
Please, Sign In to add comment