Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Turtle Tracking Program
- by brad lmoah
- --]]
- local w, h = term.getSize()
- local termC = term.current()
- local turtles = {} -- table of windows
- function initScreen()
- -- init bg
- term.setBackgroundColor(colors.lightGray)
- paintutils.drawFilledBox(0,0,w,h,colors.gray)
- paintutils.drawFilledBox(0,0,w,1,colors.lightGray)
- term.setTextColor(colors.black)
- term.setCursorPos(1,1)
- term.write("Turtle Tracking")
- local width = w/2-1
- local col2pos = width + 3
- turtles["farm1"] = window.create(termC,2,3,w/2-1,5,true)
- turtles["farm2"] = window.create(termC,2,9,w/2-1,5,true)
- turtles["farm3"] = window.create(termC,2,15,w/2-1,5,true)
- turtles["mine1"] = window.create(termC,col2pos,3,w/2-1,5,true)
- turtles["mine2"] = window.create(termC,col2pos,9,w/2-1,5,true)
- turtles["mine3"] = 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.lightGray)
- local posInit = vector.new(0,0,0)
- updateText("N/A","N/A",posInit)
- end
- end
- function updateText(name,status,pos)
- term.setTextColor(colors.black)
- term.setCursorPos(2,2)
- term.write("Name: "..name.." ")
- term.setCursorPos(2,3)
- term.write("State: "..status.." ")
- term.setCursorPos(2,4)
- term.write("Pos:("..pos.x..","..pos.y..","..pos.z..") ")
- end
- -- to do replace with protocols instead
- -- of hard coded id
- function updateScreen(id,msg)
- if id == 27 then
- term.redirect(turtles["farm1"])
- updateText(msg[1],msg[2],msg[3])
- elseif id == 43 then
- term.redirect(turtles["mine1"])
- updateText(msg[1],msg[2],msg[3])
- elseif id == 42 then
- term.redirect(turtles["mine2"])
- updateText(msg[1],msg[2],msg[3])
- end
- term.redirect(termC)
- end
- initScreen()
- rednet.open("top")
- while true do
- local id,msg = rednet.receive()
- updateScreen(id,msg)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement