Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local computer = require("computer")
- local term = require("term")
- local event = require("event")
- local thread = require("thread")
- local os = require("os")
- local sg = component.stargate
- local gpu = component.gpu
- local w,h = gpu.getResolution()
- local version = "0.1"
- local locAddr = sg.localAddress()
- local console = {}
- gpu.setDepth(gpu.maxDepth())
- function strChk(string1,string2)
- return string.find(string1,string2)
- end
- function bgClr()
- gpu.setBackground(0x0F0F0F)
- end
- function bgCol()
- gpu.setBackground(0x696969)
- end
- function lineReset(y)
- bgClr()
- gpu.fill(0,0,w,y," ")
- end
- function baseDraw()
- --Variables
- local pcEn = tostring(math.floor(computer.energy())).." RF"
- local sgEn = tostring(math.floor(sg.energyAvailable()*80)).." RF"
- local sgState,sgEng,sgDir = sg.stargateState()
- local remAddr = sg.remoteAddress()
- local sgIris = sg.irisState()
- --Draw Start
- bgCol()
- --Lines
- gpu.fill(1,1,w,1," ")
- gpu.fill(1,h,w,1," ")
- gpu.fill(5,5,w-8,1," ")
- gpu.fill(1,14,w,1," ")
- gpu.fill(1,16,w,1," ")
- --OS info
- gpu.set(1,1,"Stargate Control V."..version)
- gpu.set(w-14,1,"Power: "..pcEn)
- gpu.set(w-10,h,os.date("%X%p"))
- gpu.set(3,14,"Command Line")
- gpu.set(3,16,"Information Console")
- --Console
- if #console ~= 0 then
- bgClr()
- gpu.fill(1,17,w,8," ")
- for i=1,#console do
- gpu.set(1,(h)-i,console[i])
- end
- bgCol()
- end
- --SG info
- gpu.setBackground(0x4B4B4B)
- gpu.fill(5,6,w-8,5," ")
- gpu.set(10,6,"Stargate Status: "..sgState)
- gpu.set(10,10,"Iris Status: "..sgIris)
- if sgState ~= "Idle" then
- gpu.set(12,7,"Direction: "..sgDir)
- gpu.set(12,8,"Address: "..remAddr)
- gpu.set(12,9,"Chervon: "..sgEng)
- end
- bgCol()
- gpu.fill(5,5,w-8,1,"=")
- gpu.set(6,5,"[Stargate Info]")
- gpu.set(23,5,"[Local: "..locAddr.."]")
- gpu.set(w-30,5,"[Energy: "..sgEn.."]")
- --Draw End
- bgClr()
- os.sleep(1)
- end
- t = thread.create(function()
- term.clear()
- term.setCursor(1,3)
- while true do
- baseDraw()
- end
- end)
- while true do
- if #console >= 9 then
- table.remove(console,9)
- end
- term.setCursor(1,15)
- term.clearLine()
- input = io.read()
- term.setCursor(1,15)
- if input == "dc" then
- sg.disconnect()
- table.insert(console,1,os.date("%X%p: ").."Stargate disconnected")
- elseif input == "dial" then
- term.write("Enter address: ")
- local to = io.read()
- sg.dial(to)
- table.insert(console,1,os.date("%X%p: ").."Stargate Dialed to "..to)
- elseif input == "iris" then
- if sg.irisState() == "Open" then
- sg.closeIris()
- table.insert(console,1,os.date("%X%p: ").."Iris Closed")
- else
- sg.openIris()
- table.insert(console,1,os.date("%X%p: ").."Iris Opened")
- end
- elseif input == "exit" then
- term.write("Are you sure? Y/N ")
- if io.read() == "y" then break end
- end
- end
- t:kill()
- term.clear()
- print("Good night!")
- os.sleep(3)
- term.clear()
- os.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement