Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Turtle Tracking Program
- by brad lmoah
- --]]
- os.loadAPI("button")
- local w, h = term.getSize()
- local termC = term.current()
- local turtles = {} -- table of windows
- local protocol = "KurwaTurtleUnsecurev1.0"
- function initScreen()
- -- init bg
- --term.setBackgroundColor(colors.blue)
- paintutils.drawFilledBox(0,0,w,h,colors.cyan)
- paintutils.drawFilledBox(0,0,w,1,colors.blue)
- paintutils.drawFilledBox(0,2,w,2,colors.lightGray)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- term.write("Turtle-Trac 2")
- local width = w/2-1
- local col2pos = width + 3
- term.setBackgroundColor(colors.lightGray)
- local menuTabs = {"File","Edit","Turtle","Help"}
- local p = 1
- for i=1,#menuTabs do
- term.setCursorPos(p,2)
- term.write(menuTabs[i])
- p = p + string.len(menuTabs[i]) + 2
- end
- -- to do - loop initialisation
- turtles[1] = window.create(termC,2,3,w/2-1,5,true)
- turtles[2] = window.create(termC,2,9,w/2-1,5,true)
- turtles[3] = window.create(termC,2,15,w/2-1,5,true)
- turtles[4] = window.create(termC,col2pos,3,w/2-1,5,true)
- turtles[5] = window.create(termC,col2pos,9,w/2-1,5,true)
- turtles[6] = window.create(termC,col2pos,15,w/2-1,5,true)
- for k,v in pairs(turtles) do
- term.redirect(v)
- local tW,tH = term.getSize()
- paintutils.drawFilledBox(0,0,w,h,colors.lightBlue)
- paintutils.drawFilledBox(1,1,w,1,colors.blue)
- local posInit = vector.new(0,0,0)
- updateText("N/A","N/A",posInit)
- term.setCursorPos(tW,1)
- term.setBackgroundColor(colors.red)
- term.write("X")
- term.setCursorPos(tW-1,1)
- term.setBackgroundColor(colors.orange)
- term.write("#")
- end
- end
- function updateText(name,status,pos)
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- term.write(" "..name.." ")
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(1,3)
- term.write(" "..status.." ")
- term.setCursorPos(1,4)
- term.write(" "..pos.x..","..pos.y..","..pos.z.." ")
- end
- -- to do replace with protocols instead
- -- of hard coded id
- function updateScreen(id,msg)
- if id == 42 then
- term.redirect(turtles[1])
- updateText(msg[1],msg[2],msg[3])
- elseif id == 77 then
- term.redirect(turtles[4])
- updateText(msg[1],msg[2],msg[3])
- elseif id == 79 then
- term.redirect(turtles[2])
- updateText(msg[1],msg[2],msg[3])
- elseif id == 80 then
- term.redirect(turtles[5])
- updateText(msg[1],msg[2],msg[3])
- elseif id == 81 then
- term.redirect(turtles[3])
- updateText(msg[1],msg[2],msg[3])
- elseif id == 82 then
- term.redirect(turtles[6])
- updateText(msg[1],msg[2],msg[3])
- end
- term.redirect(termC)
- end
- initScreen()
- rednet.open("top")
- while true do
- local id,msg = rednet.receive(protocol)
- updateScreen(id,msg)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement