thatparadox

RFtools Tele sender

Jul 22nd, 2021 (edited)
820
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. for k,v in pairs(rs.getSides()) do
  2.   if peripheral.getType(v) == "monitor" then
  3.     mon = peripheral.wrap(v)
  4.   end
  5. end
  6. for k,v in pairs(rs.getSides()) do
  7.   if peripheral.getType(v) == "modem" then
  8.    rednet.open(v)
  9.   end
  10. end
  11.  
  12. function drawMon()
  13.   mon.setBackgroundColor(colors.black)
  14.   mon.clear()
  15.   x,y = mon.getSize()
  16.   buttonNo = 0
  17.   for yc = y,1,-1 do
  18.     buttonNo = buttonNo + 1
  19.     if yc%2 == 1 then
  20.       mon.setBackgroundColor(colors.purple)
  21.       mon.setTextColor(colors.yellow)
  22.     else
  23.       mon.setBackgroundColor(colors.yellow)
  24.       mon.setTextColor(colors.purple)
  25.     end
  26.     for xc = 1,x do
  27.       mon.setCursorPos(xc, yc)
  28.       mon.write(" ")
  29.     end
  30.   mon.setCursorPos(x/2+1,yc)
  31.   mon.write(tostring(buttonNo))
  32.   end
  33. end
  34.  
  35. if fs.exists("floor") then
  36.   file = fs.open("floor", "r")
  37.   floor = file.readAll()
  38.   file.close()
  39. else
  40.   term.clear()
  41.   term.setCursorPos(1,1)
  42.   print("Which number will this be on the monitor?")
  43.   write("> ")
  44.   floor = read()
  45.   file = fs.open("floor", "w")
  46.   file.write(floor)
  47.   file.close()
  48.   term.clear()
  49.   term.setCursorPos(1,1)
  50.   print("Thank you.")
  51.   sleep(1)
  52.   term.clear()
  53.   term.setCursorPos(1,1)
  54. end
  55.  
  56. while true do
  57.   drawMon()
  58.   event, side, xTouch, yTouch =os.pullEvent("monitor_touch")
  59.   buttonNo = y - yTouch + 1
  60.   touchData = {
  61.     sender = floor,
  62.     destination = tostring(buttonNo)
  63.   }
  64.   rednet.broadcast(textutils.serialize(touchData), "teleport")
  65. end
RAW Paste Data