csmit195

PIM Test.

Sep 18th, 2018
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.99 KB | None | 0 0
  1. local pim = peripheral.wrap('front')
  2. local chest = peripheral.wrap('left')
  3.  
  4. -- Monitor Setup
  5. local monitor = peripheral.wrap('top')
  6. monitor.setTextScale(0.5)
  7.  
  8. function startCheck()
  9.     if not pim then
  10.         error('PIM not found')
  11.     end
  12.    
  13.     if not chest then
  14.         error('Chest not found')
  15.     end
  16.    
  17.     if not stacks then
  18.         error('No stacks found?')
  19.     end
  20. end
  21.  
  22. function initiate()
  23.     startCheck()
  24.     update()
  25. end
  26.  
  27. function resetMonitor()
  28.     monitor.clear()
  29.     monitor.setCursorPos(1,1)
  30. end
  31.  
  32. function newLine()
  33.     local _,cY= monitor.getCursorPos()
  34.     monitor.setCursorPos(1,cY+1)
  35. end
  36.  
  37. function update()
  38.     if ( pim.getInventorySize() > 0 ) then
  39.         resetMonitor()
  40.         local stacks = pim.getAllStacks()
  41.         print(monitor)
  42.         monitor.write('I am here')
  43.         for name,stack in pairs(stacks) do
  44.             print(stack.all().id)
  45.             newLine()
  46.             monitor.write(stack.all().id)
  47.         end
  48.         sleep(1)
  49.     else
  50.         print('Debug2');
  51.         resetMonitor()
  52.         monitor.write('No items found!')
  53.         sleep(2)
  54.     end
  55.     update()
  56. end
  57.  
  58. initiate()
Advertisement
Add Comment
Please, Sign In to add comment