Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local mon = peripheral.find("monitor")
- local tankList = peripheral.getNames()
- local blackList = {"back","right","top","left","bottom","front"}
- local oldTerm = term.redirect(mon)
- local function newButton(xStart,yStart,label)
- term.setCursorPos(xStart,yStart)
- term.write("["..label.."]")
- local xEnd,yEnd = term.getCursorPos()
- return {xStart, yStart, xEnd, yEnd, label}
- end
- local function waitButtonPressed(list) --Returns index # of button pressed from button press
- local event, side, x, y = os.pullEvent( "monitor_touch" )
- for i = 1, #list do
- if x >= list[i][1] and x <= list[i][3] and y >= list[i][2] and y <= list[i][4] then
- return list[i][5]
- end
- end
- return false
- end
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.clear()
- mon.setTextScale(0.5)
- mon.setCursorPos(1,1)
- local width,height = mon.getSize()
- mon.write("Getting connected tanks...")
- --Filter out non tank peripherals
- for i = #tankList, 1, -1 do
- for j,filter in ipairs(blackList) do
- if tankList[i] == filter then
- table.remove(tankList, i)
- break
- end
- end
- end
- os.sleep(2)
- mon.clear()
- mon.setCursorPos(1,1)
- print("Found "..#tankList.." tanks:")
- print()
- for i,tankName in ipairs(tankList) do
- print("["..i.."] "..tankName)
- local x,y = mon.getCursorPos()
- end
- os.sleep(2)
- mon.clear()
- mon.setCursorPos(1,1)
- mon.setBackgroundColor(colors.orange)
- for i = 1, width do
- mon.write(" ")
- end
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.black)
- mon.write("Tank Controller")
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.white)
- mon.setCursorPos((width*0.5)-10,2)
- print("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement