Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Declare variables
- local line
- local monX
- local monY
- local headerTextColor
- local headerBGColor
- local headerText
- local centerPOS
- local altColorSwitch
- local altColor1
- local altColor2
- local rankHeaderPos
- local nameHeaderPos
- local rankTitle
- local nameTitle
- -- This is the table that stores the full roster
- local crewRoster = {}
- -- Set variables
- altColorSwitch = 1
- altColor1 = colors.black
- altColor2 = colors.gray
- headerBGColor = colors.blue
- headerTextColor = colors.white
- headerText = "Crew Roster"
- rankTitle = "Rank"
- nameTitle = "Name"
- -- Write startup message to Terminal
- term.clear()
- -- Check to see if the API file exists
- if fs.exists("ImpAPI") == false then
- term.setCursorPos(1,1)
- term.setTextColor(colors.red)
- term.write("Missing API File! Attempting to download...")
- term.setTextColor(colors.white)
- shell.run("pastebin get pwBMKNCb ImpAPI") -- Go out and download it
- sInput = nil
- term.setCursorPos(1,5)
- term.setTextColor(colors.green)
- term.write("API Loaded.")
- term.setCursorPos(1,7)
- term.setTextColor(colors.white)
- term.write("Press enter to continue...")
- while true do
- sInput = read()
- if sInput ~= nil or sInput ~= "" then
- break
- end
- end
- end
- -- load the API
- os.loadAPI("ImpAPI")
- term.clear()
- -- Find the monitor
- mon=ImpAPI.monitorSearch()
- if mon then -- Found it
- ImpAPI.CTWrite(1,6,"Monitor Found!",colors.green)
- ImpAPI.CTWrite(1,8,"System Running",colors.orange)
- else -- No monitor Present
- ImpAPI.CTWrite(1,6,"Monitor Not Found!",colors.red)
- ImpAPI.CTWrite(1,8,"Please Attach a Monitor",colors.red)
- term.setCursorPos(1,9)
- return
- end
- function RCWrite(col, row, monitor, text, color)
- color = color or colors.white
- monitor.setCursorPos(col,row)
- monitor.setTextColor(color)
- monitor.write(text)
- end
- -- Prepare to write to the monitor
- mon.clear()
- -- Big or small?
- mon.setTextScale(1.0)
- mainLoop = 1
- -- Loop so it always shows (CTRL+R to restart program, CTRL+T to stop program)
- while mainLoop > 0 do
- -- Get the monitor's size
- monX, monY = mon.getSize()
- mon.clear()
- line = 2
- -- Write out header
- ImpAPI.draw_line(1, 1, monX, headerBGColor, mon)
- -- Get center of screen for header text
- centerPos = math.floor((monX - #headerText) / 2) + 1
- -- Print headerText
- RCWrite(centerPos, 1, mon, headerText, colors.white)
- -- Clear out the table
- crewRoster = {}
- -- Do this line for each member
- -- Just change the Rank and Name values
- table.insert(crewRoster, { ["Rank"] = "Rank 1", ["Name"] = "Name 1", ["RankColor"] = colors.lime, ["NameColor"] = colors.lightBlue})
- table.insert(crewRoster, { ["Rank"] = "Rank 2", ["Name"] = "Name 2", ["RankColor"] = colors.red, ["NameColor"] = colors.green})
- table.insert(crewRoster, { ["Rank"] = "Rank 3", ["Name"] = "Name 3", ["RankColor"] = colors.pink, ["NameColor"] = colors.blue})
- table.insert(crewRoster, { ["Rank"] = "Rank 4", ["Name"] = "Name 4", ["RankColor"] = colors.lightGray, ["NameColor"] = colors.orange})
- table.insert(crewRoster, { ["Rank"] = "Rank 5", ["Name"] = "Name 5", ["RankColor"] = colors.gray, ["NameColor"] = colors.white})
- table.insert(crewRoster, { ["Rank"] = "Rank 6", ["Name"] = "Name 6", ["RankColor"] = colors.cyan, ["NameColor"] = colors.yellow})
- -- Redefine center for columns
- centerPos = (monX / 2) + 1
- rankHeaderPos = math.floor(((monX / 2) - #rankTitle) / 2)
- nameHeaderPos = math.floor(((monX / 2) - #nameTitle) / 2) + (monX / 2)
- line = 2
- -- Write column headers
- ImpAPI.draw_line(1, 2, monX, colors.black, mon)
- RCWrite(rankHeaderPos, 2, mon, "Rank", colors.orange)
- RCWrite(nameHeaderPos, 2, mon, "Name", colors.orange)
- -- Write top divider
- ImpAPI.draw_line(1, 3, monX, colors.black, mon)
- RCWrite(1, 3, mon, "--------------------------------------------------------------------------------------", colors.gray)
- -- This is the main loop where the crew is printed
- line = 4
- for i = 1,#crewRoster do
- --ImpAPI.draw_line(1, line, monX, colors.black, mon)
- RCWrite(2, line, mon, crewRoster[i].Rank, crewRoster[i].RankColor)
- RCWrite(centerPos, line, mon, crewRoster[i].Name, crewRoster[i].NameColor)
- -- Draw dotted line from Rank to Name
- for d = #crewRoster[i].Rank + 2, centerPos - 1 do
- RCWrite(d, line, mon, ".", colors.gray)
- end
- line = line + 1
- end
- -- Loop timer
- sleep(.50)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement