Advertisement
Guest User

Untitled

a guest
May 26th, 2020
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. local component = require("component")
  2. API = require("button")
  3. local event = require("event")
  4. local gpu = component.gpu
  5. local dialer = component.rftools_dialing_device
  6.  
  7. local receivers = dialer.getReceivers()
  8. local locations = {}
  9. local positions = {}
  10. local dimensions = {}
  11. local transmitter = dialer.getTransmitters()
  12. local homePos = 0
  13. local numLocations = 0
  14. local dialMode = true --dial once if true
  15.  
  16.  
  17. local colors = { blue = 0x4286F4, purple = 0xB673d6, red = 0xC14141, green = 0xDA841,
  18. black = 0x000000, white = 0xFFFFFF, grey = 0x47494C, lightGrey = 0xBBBBBB}
  19. -- set size of the screen for lvl 3
  20. gpu.setResolution(132, 38)
  21. gpu.setBackground(colors.black)
  22. gpu.fill(1, 1, 132, 38, " ")
  23.  
  24. function clearScreen()
  25. local oldColor = gpu.getBackground( false )
  26. local w,h = gpu.getResolution()
  27. gpu.setBackground( colors.black, false )
  28. gpu.fill(1, 1, 132, 38, " ")
  29. gpu.setBackground( oldColor, false )
  30. end
  31.  
  32. function getNumLocations()
  33. for k,v in pairs(receivers) do
  34. numLocations = numLocations + 1
  35. end
  36. end
  37.  
  38. getNumLocations()
  39.  
  40. for i=1, numLocations-1 do
  41. table.insert(locations, receivers[i].name)
  42. table.insert(positions, receivers[i].position)
  43. table.insert(dimensions, receivers[i].dimension)
  44.  
  45. if receivers[i].name == "Home" then
  46. homePos = i
  47. end
  48. end
  49.  
  50. function setButtons()
  51. y = 0
  52. for i=1, numLocations-1 do
  53. API.setTable(locations[i], tele(i), 10, 2+y, 30, 3+y,locations[i], {on = colors.green, off = colors.red})
  54. y = y + 3
  55. end
  56. end
  57.  
  58. function tele(i)
  59. dialer.dial(transmitter[1].position, receivers[i].position, receivers[i].dimension, dialMode)
  60. end
  61.  
  62. event.listen("touch", API.checkxy)
  63.  
  64. --clearScreen()
  65. setButtons()
  66. API.screen()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement