Advertisement
Nikitos228

РОБОТ

Aug 26th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. local component = require("component")
  2. local sides = require("sides")
  3. local gsm = require("gsm")
  4. local robot = require("robot")
  5. local term = require("term")
  6. local inventory = component.inventory_controller
  7. local redstone = component.redstone
  8.  
  9. term.clear()
  10.  
  11. print("Сервер-контроллер запущен.")
  12.  
  13. local CONTROLLER_PORT = 988
  14. local ATM_ADDRESS = "ТУТ НОМЕР БЕСПРОВОДНОЙ КАРТЫ У БАНКОМАТА"
  15.  
  16. while true do
  17. local request = gsm.listen(CONTROLLER_PORT)
  18. if request[3] == ATM_ADDRESS then
  19. if request[5] == "deposit" then
  20. print("Запрос на депозит.")
  21. local amount = 0
  22. for i = 1, 27 do
  23. local status = inventory.suckFromSlot(sides.front, i)
  24. if status == true then
  25. local stack = inventory.getStackInInternalSlot()
  26. if stack.name == "СЮДА ТО ЧТО БУДЕТ МОНЕТАМИ" then
  27. amount = amount + stack.size
  28. end
  29. robot.turnLeft()
  30. inventory.dropIntoSlot(sides.front, 1)
  31. for j = 1, stack.size do
  32. redstone.setOutput(sides.front, 1)
  33. redstone.setOutput(sides.front, 0)
  34. end
  35. robot.turnRight()
  36. end
  37. end
  38. gsm.send(request[3], request[4], tostring(amount))
  39. end
  40. end
  41. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement