Rolcam

Computercraft PIM Peripheral Test Program 1

Dec 11th, 2021 (edited)
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.12 KB | None | 0 0
  1. -- This is a test program for the Player Inventory Module (or PIM for short)
  2. term.clear()
  3. term.setCursorPos(1,1)
  4. -- Change the "" to whatever the label of the PIM is (e.g. touching the left side of the computer is "left", if it's labeled pim_1, use "pim_1")
  5. pim = peripheral.wrap("pim_2")
  6. -- A chest touching the East side of the PIM
  7. chest = "south"
  8. print("PIM Test 1")
  9. print("Pulling inventory from a player to a chest")
  10. print("Press \"enter\" to begin the test program")
  11. -- This makes it so the program pauses until you press enter
  12. read()
  13. -- size is the inventory size of whatever is on top of the PIM
  14. size = pim.getInventorySize()
  15. while size == 0 do
  16.     term.clear()
  17.     term.setCursorPos(1,1)
  18.     print("No inventory detected!")
  19.     print("Please stand on top of the PIM")
  20.     size = pim.getInventorySize()
  21.     sleep(1)
  22. end
  23. term.clear()
  24. term.setCursorPos(1,1)
  25. print("Detected Inventory Size: " .. size .. " slots")
  26. print("Pulling from player inventory into the chest")
  27. for i = size, 1, -1 do
  28.     print("Pulling from player slot " .. i)
  29.     pim.pushItem(chest, i)
  30. end
  31. print("Inventory pulled. Test Program Done.")
  32.    
Add Comment
Please, Sign In to add comment