Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- local sx,sy = term.getSize()
- term.clear()
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setTextColor(colors.black)
- term.write("Pairing...")
- local turtleId = ""
- while true do
- rednet.broadcast("pair","tmzst")
- local senderId, message, protocol = rednet.receive(5)
- if (protocol == "tmzst") then
- term.setBackgroundColor(colors.lime)
- term.clear()
- local wifi = paintutils.loadImage("/img/wifi.nfp")
- paintutils.drawImage(wifi,0,2)
- term.setTextColor(colors.white)
- term.setBackgroundColor(colors.lime)
- local txt = "Eto vasha cherepaha?"
- term.setCursorPos(sx/2-(txt:len()/2)+1,11)
- term.write(txt)
- local txt = "ID: "..message
- term.setCursorPos(sx/2-(txt:len()/2)+1,12)
- term.write(txt)
- term.setCursorPos(3,14)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.write("Da")
- term.setCursorPos(7,14)
- term.write("Net")
- while true do
- local event, button, x, y = os.pullEvent( "mouse_click" )
- if (y == 14) then
- if (x >= 3) and (x <= 5) then
- term.clear()
- turtleId = message
- break
- end
- if (x >= 7) and (x <= 10) then
- os.reboot()
- end
- end
- end
- break
- end
- end
- term.setBackgroundColor(colors.white)
- term.clear()
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- local txt = "Cherepha: "..turtleId
- term.setCursorPos(sx/2 - (txt:len()/2)+1,1)
- term.write(txt)
- local txt = "Ispolzui W/S/D/A dly dvizzhenija"
- term.setCursorPos(sx/2 - (txt:len()/2)+1,4)
- term.write(txt)
- local txt = "Shift - Up | Ctrl - Down"
- term.setCursorPos(sx/2-txt:len()/2+1,5)
- term.write(txt)
- local txt = "E - Lomat | Q - Stavit"
- term.setCursorPos(sx/2-txt:len()/2+1,6)
- term.write(txt)
- local function trs(txtt)
- rednet.send(turtleId,txtt,"tmzst")
- end
- local function control()
- while true do
- local event, key, isHeld = os.pullEvent("key")
- if key == keys.w then
- trs("w")
- elseif key == keys.s then
- trs("s")
- elseif key == keys.a then
- trs("a")
- elseif key == keys.d then
- trs("d")
- elseif key == keys.leftShift then
- trs("shift")
- elseif key == keys.leftCtrl then
- trs("ctrl")
- elseif key == keys.e then
- trs("e")
- elseif key == keys.q then
- trs("q")
- elseif key == keys.r then
- trs("r")
- end
- end
- end
- local function receive()
- while true do
- local senderId, message, protocol = rednet.receive()
- if (senderId == turtleId) and (protocol == "tmzstf") then
- term.setCursorPos(1,sy)
- term.write("Fuel: "..message.." ")
- end
- end
- end
- parallel.waitForAll(control,receive)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement