Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local backColor = colors.white
- local TurtleID
- function Gui()
- term.setBackgroundColor(backColor)
- term.clear()
- --Title
- paintutils.drawPixel(4,2,backColor)
- term.setCursorPos(4,2)
- term.setTextColor(colors.black)
- term.write("-Turtle manager-")
- --Exit Button
- paintutils.drawPixel(2,2,colors.red)
- term.setCursorPos(2,2)
- term.setTextColor(colors.white)
- term.write("x")
- --List Button
- paintutils.drawPixel(2,4,colors.yellow)
- term.setCursorPos(2,4)
- term.setTextColor(colors.white)
- term.write("List")
- --Control Button
- paintutils.drawPixel(2,6,colors.yellow)
- term.setCursorPos(2,6)
- term.setTextColor(colors.white)
- term.write("Control turtle")
- end
- function ListGui()
- --Get turtles data from rednet
- local lsTurtles = {{"Enie",true}, {"Minie",false}, {"Miny",false}, {"Mou",true}} --Get with rednet
- local loop = true
- while(loop) do
- term.setBackgroundColor(backColor)
- term.clear()
- --Title
- paintutils.drawPixel(4,2,backColor)
- term.setCursorPos(4,2)
- term.setTextColor(colors.black)
- term.write("-Turtle list-")
- --Return Button
- paintutils.drawPixel(2,2,colors.red)
- term.setCursorPos(2,2)
- term.setTextColor(colors.white)
- term.write("<")
- --List of turtles
- for i=1,#lsTurtles,1 do
- local y = i+3
- if (y%2 ~= 0) then y=y+1 end
- --Name
- paintutils.drawPixel(4,y,colors.cyan)
- term.setCursorPos(4,y)
- term.setTextColor(colors.gray)
- term.write(lsTurtles[i][1])
- --Resume/stop Button
- term.setTextColor(colors.white)
- if (lsTurtles[i][2]==true) then
- paintutils.drawPixel(2,y,colors.green)
- term.setCursorPos(2,y)
- term.write(">")
- else
- paintutils.drawPixel(2,y,colors.yellow)
- term.setCursorPos(2,y)
- term.write("#")
- end
- end
- --Button click
- local e,b,x,y = os.pullEvent("mouse_click")
- if (x==2 and y==2) then
- loop = false
- elseif (x==2 and y>=4) then
- end
- end
- end
- function ControlGui()
- rednet.open("back")
- local loop = true
- while(loop) do
- term.setBackgroundColor(backColor)
- term.clear()
- --Title
- paintutils.drawPixel(4,2,backColor)
- term.setCursorPos(4,2)
- term.setTextColor(colors.black)
- term.write("-Turtle control-")
- --Return Button
- paintutils.drawPixel(2,2,colors.red)
- term.setCursorPos(2,2)
- term.setTextColor(colors.white)
- term.write("<")
- --ID Container
- paintutils.drawPixel(2,4,backColor)
- term.setCursorPos(2,4)
- term.setTextColor(colors.black)
- term.write("ID")
- paintutils.drawLine(5,4,10,4,colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(5,4)
- term.write(TurtleID)
- --Fuel level
- paintutils.drawPixel(2,4,backColor)
- term.setCursorPos(12,4)
- term.setTextColor(colors.black)
- term.write("Fuel:")
- term.setCursorPos(18,4)
- rednet.send(TurtleID, "FuelLevel")
- local ID, Msg = rednet.receive()
- term.write(tonumber(Msg))
- --Turn left
- paintutils.drawFilledBox(2,6,6,8,colors.yellow)
- term.setTextColor(colors.white)
- term.setCursorPos(2,7)
- term.write("Left")
- --Turn right
- paintutils.drawFilledBox(21,6,25,8,colors.yellow)
- term.setTextColor(colors.white)
- term.setCursorPos(21,7)
- term.write("Right")
- --Go Up
- paintutils.drawFilledBox(11,6,16,6,colors.yellow)
- term.setTextColor(colors.white)
- term.setCursorPos(13,6)
- term.write("Up")
- --Go Down
- paintutils.drawFilledBox(11,8,16,8,colors.yellow)
- term.setTextColor(colors.white)
- term.setCursorPos(12,8)
- term.write("Down")
- --Start
- paintutils.drawPixel(2,10,colors.green)
- term.setTextColor(colors.white)
- term.setCursorPos(2,10)
- term.write("Start")
- --Stop
- paintutils.drawPixel(8,10,colors.green)
- term.setTextColor(colors.white)
- term.setCursorPos(8,10)
- term.write("Stop")
- --Stop
- paintutils.drawPixel(13,10,colors.green)
- term.setTextColor(colors.white)
- term.setCursorPos(13,10)
- term.write("Forward")
- --Button click
- local e,b,x,y = os.pullEvent("mouse_click")
- if (x==2 and y==2) then
- loop = false
- elseif (x>=5 and x<=10 and y==4) then -- Input ID
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(5,4)
- TurtleID = tonumber(read())
- elseif (x>=2 and x<=6 and y>=6 and y<=8) then --Turn left
- rednet.send(TurtleID, "TurnLeft")
- elseif (x>=21 and x<=25 and y>=6 and y<=8) then --Turn left
- rednet.send(TurtleID, "TurnRight")
- elseif (x>=11 and x<=16 and y==6) then -- Move Up
- rednet.send(TurtleID, "MoveUp")
- elseif (x>=11 and x<=16 and y==8) then -- Move Down
- rednet.send(TurtleID, "MoveDown")
- elseif (x>=2 and x<=6 and y==10) then -- Start
- rednet.send(TurtleID, "Start")
- elseif (x>=8 and x<=11 and y==10) then -- Start
- rednet.send(TurtleID, "Stop")
- elseif (x>=13 and x<=19 and y==10) then -- Start
- rednet.send(TurtleID, "MoveForward")
- end
- end
- rednet.close()
- end
- function Events(x,y)
- if (x==2 and y==2) then
- error("",0)
- elseif (y==4 and x>=2 and x<=5) then
- ListGui()
- elseif (y==6 and x>=2 and x<=8) then
- ControlGui()
- end
- end
- -- Main --
- while(true) do
- Gui()
- local e,b,x,y = os.pullEvent("mouse_click")
- Events(x,y)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement