Advertisement
fingercomp

ROBOT/scan.lua

Oct 25th, 2015
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local PORT = 666
  2. local COMP = "586ce2fa-dd5f-4b3f-b2a7-235f6fb921e3"
  3. ---
  4. local com = require("component")
  5. local inv = com.inventory_controller
  6. local modem = com.modem
  7. local ser = require("serialization")
  8. ---
  9.  
  10. print("Программа сканирования рецептов")
  11. print("Убедитесь, что принимающий компьютер готов")
  12. os.sleep(1)
  13. io.write("\nСканирование...")
  14. local recipe = {}
  15. for i = 1, 9, 1 do
  16.   local slot = i + (math.floor(i - 1) / 3)
  17.   local stack = inv.getStackInInternalSlot(slot)
  18.   if stack == nil then stack = "" end
  19.   table.insert(recipe, stack)
  20. end
  21. table.insert(recipe, inv.getStackInInternalSlot(8))
  22. print(" [OK]")
  23. io.write("Передача данных...")
  24.  
  25. local toSend = ser.serialize(recipe)
  26. modem.send(COMP, PORT, toSend)
  27. print(" [OK]")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement