Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --This is just a test prorgam so I can get familiar with various computercraft peripherals. Please excuse the mess.
- -- load the API
- os.loadAPI("ocs/apis/sensor")
- -- Change the peripheral names accordingly
- -- Prox = sensor (requires a proximity card) | mon = monitor | glass = terminal glass bridge | printer = printer
- prox = sensor.wrap("top")
- mon = peripheral.wrap("left")
- glass = peripheral.wrap("right")
- -- Set this to 0 to disable printing
- printReadout = 1
- printer = peripheral.wrap("bottom")
- -- get the targets
- local targets = prox.getTargets()
- --Redirects output to monitor
- term.redirect(mon)
- term.clear()
- term.setCursorPos(1,1)
- term.setTextColor(colors.yellow)
- print("Sensor Readout - Entities:")
- print()
- glass.clear()
- --List
- glass.addBox(348,1,180,200,0xFFFFFF, 0.2)
- glass.addText(350,2,"Radar Readout:", 0xF2B233)
- glassY = 12
- -- Page tracker for printer
- pgCt = 1
- term.setTextColor(colors.white)
- if printReadout == 1 then
- printer.newPage()
- printer.setPageTitle("Radar Printout Page " .. pgCt)
- -- Y value tracker for printer - will start a new page once it gets to the bottom
- printY = 1
- -- Updates the cursor position on the page = for printer
- printer.setCursorPos(1,printY)
- end
- -- Checks if the page is full. If so, it starts a new page
- function printCheck ()
- if printY > 21 then
- -- Ends the page
- printer.endPage()
- -- Adds one to the page counter
- pgCt = pgCt + 1
- -- Starts a new page
- printer.newPage()
- printer.setPageTitle("Radar Printout Page " .. pgCt)
- -- Resets printer Y position to 1
- printY = 1
- printer.setCursorPos(1,printY)
- end
- end
- -- loop through targets from sensor
- for name, basicDetails in pairs(targets) do
- -- get more details about them
- local moreDetails = prox.getTargetDetails(name)
- -- Changes the text color to yellow if it lists a player. Otherwise, it's white
- if moreDetails.IsPlayer == true then
- term.setTextColor(colors.yellow)
- print("Found player: "..name)
- if printReadout == 1 then
- printer.setCursorPos(1,printY)
- printer.write("Found player: "..name)
- printY = printY + 1
- printCheck()
- end
- else
- term.setTextColor(colors.white)
- print("Found entity: "..name)
- if printReadout == 1 then
- printer.write("Found entity: "..name)
- printY = printY + 1
- printCheck()
- end
- end
- -- print their health
- print("Health: "..moreDetails.Health)
- if printReadout == 1 then
- printer.setCursorPos(1,printY)
- printer.write("Health: "..moreDetails.Health)
- printY = printY + 1
- printCheck()
- end
- term.setTextColor(colors.white)
- print("------")
- if printReadout == 1 then
- printer.setCursorPos(1,printY)
- printer.write("------")
- printY = printY + 1
- printCheck()
- end
- end
- if printReadout == 1 then
- printer.endPage()
- end
- term.restore()
- function glassCheck()
- if glassY > 200 then
- sleep(5)
- glass.clear()
- glass.addBox(348,1,180,200,0xFFFFFF, 0.2)
- glass.addText(350,2,"Radar Readout:", 0xF2B233)
- glassY = 12
- end
- end
- -- loop through targets from sensor
- for name, basicDetails in pairs(targets) do
- -- get more details about them
- local moreDetails = prox.getTargetDetails(name)
- -- Changes the text color to yellow if it lists a player. Otherwise, it's white
- if moreDetails.IsPlayer == nil then
- glass.addText(350,glassY,"Found ??????: "..name, 0xF2B233)
- glassY = glassY + 10
- glassCheck()
- elseif moreDetails.IsPlayer == true then
- glass.addText(350,glassY,"Found player: "..name, 0xF2B233)
- glassY = glassY + 10
- glassCheck()
- else
- glass.addText(350,glassY,"Found entity: "..name, 0x000000)
- glassY = glassY + 10
- glassCheck()
- end
- -- print their health
- glass.addText(350,glassY,"Health: "..moreDetails.Health, 0x000000)
- glassY = glassY + 10
- glassCheck()
- glass.addText(350,glassY,"------", 0x000000)
- glassY = glassY + 10
- glassCheck()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement