Advertisement
TIMAS_Bro

TurtlePapa

Jun 12th, 2023 (edited)
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. rednet.open("back")
  2. local sx,sy = term.getSize()
  3. term.clear()
  4. term.setBackgroundColor(colors.white)
  5. term.clear()
  6. term.setTextColor(colors.black)
  7. term.write("Pairing...")
  8. local turtleId = ""
  9. while true do
  10.   rednet.broadcast("pair","tmzst")
  11.   local senderId, message, protocol = rednet.receive(5)
  12.   if (protocol == "tmzst") then
  13.     term.setBackgroundColor(colors.lime)
  14.     term.clear()
  15.     local wifi = paintutils.loadImage("/img/wifi.nfp")
  16.     paintutils.drawImage(wifi,0,2)    
  17.     term.setTextColor(colors.white)
  18.     term.setBackgroundColor(colors.lime)
  19.     local txt = "Eto vasha cherepaha?"
  20.     term.setCursorPos(sx/2-(txt:len()/2)+1,11)
  21.     term.write(txt)
  22.     local txt = "ID: "..message
  23.     term.setCursorPos(sx/2-(txt:len()/2)+1,12)
  24.     term.write(txt)
  25.     term.setCursorPos(3,14)
  26.     term.setBackgroundColor(colors.white)
  27.     term.setTextColor(colors.black)
  28.     term.write("Da")
  29.     term.setCursorPos(7,14)
  30.     term.write("Net")
  31.     while true do
  32.       local event, button, x, y = os.pullEvent( "mouse_click" )
  33.       if (y == 14) then
  34.         if (x >= 3) and (x <= 5) then
  35.           term.clear()
  36.           turtleId = message
  37.           break
  38.         end
  39.         if (x >= 7) and (x <= 10) then
  40.           os.reboot()
  41.         end
  42.       end
  43.     end
  44.     break
  45.   end
  46. end
  47. term.setBackgroundColor(colors.white)
  48. term.clear()
  49. term.setBackgroundColor(colors.black)
  50. term.setTextColor(colors.white)
  51. local txt = "Cherepha: "..turtleId
  52. term.setCursorPos(sx/2 - (txt:len()/2)+1,1)
  53. term.write(txt)
  54. local txt = "Ispolzui W/S/D/A dly dvizzhenija"
  55. term.setCursorPos(sx/2 - (txt:len()/2)+1,4)
  56. term.write(txt)
  57. local txt = "Shift - Up | Ctrl - Down"
  58. term.setCursorPos(sx/2-txt:len()/2+1,5)
  59. term.write(txt)
  60. local txt = "E - Lomat | Q - Stavit"
  61. term.setCursorPos(sx/2-txt:len()/2+1,6)
  62. term.write(txt)
  63. local function trs(txtt)
  64.   rednet.send(turtleId,txtt,"tmzst")
  65. end
  66. local function control()
  67.   while true do
  68.     local event, key, isHeld = os.pullEvent("key")
  69.     if key == keys.w then
  70.       trs("w")  
  71.     elseif key == keys.s then
  72.       trs("s")
  73.     elseif key == keys.a then
  74.       trs("a")
  75.     elseif key == keys.d then
  76.       trs("d")
  77.     elseif key == keys.leftShift then
  78.       trs("shift")
  79.     elseif key == keys.leftCtrl then
  80.       trs("ctrl")
  81.     elseif key == keys.e then
  82.       trs("e")
  83.     elseif key == keys.q then
  84.       trs("q")
  85.     elseif key == keys.r then
  86.        trs("r")
  87.     end
  88.  end
  89. end
  90. local function receive()
  91.   while true do
  92.   local senderId, message, protocol = rednet.receive()
  93.   if (senderId == turtleId) and (protocol == "tmzstf") then
  94.     term.setCursorPos(1,sy)
  95.     term.write("Fuel: "..message.."      ")
  96.   end
  97.   end
  98. end
  99. parallel.waitForAll(control,receive)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement