Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. modemSide = "top"
  2.  
  3. coordsPos = {400, 5}
  4.  
  5. local function checkPeripheral(side, peripheralType)
  6. if peripheral.getType(side) ~= peripheralType then
  7. error(peripheralType .. " not found, please check the config at the beginning of the file")
  8. end
  9. end
  10.  
  11. local function showPos()
  12. canvas.clear()
  13. local coordsGroup = canvas.addGroup(coordsPos)
  14. local rect = coordsGroup.addRectangle(0, 0, 100, 10, 0x44444488)
  15. local text = coordsGroup.addText({0, 0}, "lol")
  16. while true do
  17. local event, timer = os.pullEvent("timer")
  18. if timer == coordsTimer then
  19. local x, y, z = gps.locate(1)
  20. text.setText(x)
  21. coordsTimer = os.startTimer(1)
  22. end
  23. end
  24. end
  25.  
  26. local function keyPressHandler()
  27. while true do
  28. local event, key = os.pullEvent("key")
  29. if key == keys.q then
  30. print("Exiting...")
  31. break
  32. end
  33. end
  34. end
  35.  
  36. -- First we check for the peripherals, then we print the info about the program
  37. checkPeripheral(modemSide, "modem")
  38.  
  39. rednet.open(modemSide)
  40. interface = peripheral.wrap("back")
  41. canvas = interface.canvas()
  42. coordsTimer = os.startTimer(1)
  43.  
  44.  
  45. parallel.waitForAny(keyPressHandler, showPos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement