Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require('component')
- local gpu = component.gpu
- local width, height = gpu.getResolution()
- local maxSize = 0
- local maxAddress = ""
- for address,type in component.list("screen", true) do
- local proxy = component.proxy(address)
- local width, height = proxy.getAspectRatio()
- local size = width*height
- if proxy ~= nil and size > maxSize then
- maxSize = size
- maxAddress = address
- end
- end
- gpu.bind(maxAddress)
- local filesystem = require('filesystem')
- local confdir = "/raid"
- local success = false
- local error = ""
- if not filesystem.exists(confdir) then
- for address,type in component.list("filesystem", true) do
- local proxy = component.proxy(address)
- if proxy ~= nil and proxy.exists("help.conf") then
- --print(address, proxy)
- success, error = filesystem.mount(proxy, confdir)
- break
- end
- end
- end
- if success == nil then
- print("An error occurred loading the filesystem: " .. error)
- return
- end
- local confpath = filesystem.concat(confdir, "help.conf")
- if not success and not filesystem.exists(confpath) then
- print("No filesystem was found with a help.conf in the main directory")
- return
- end
- local lastupdated = filesystem.lastModified(confpath)
- --print(filesystem.exists("/home/raid/help.conf"))
- function loadConf()
- local conf = io.open(confpath)
- --reads pairs of lines
- --the starting coords and the file name to read from
- x = conf:read("*n")
- while (x) do
- y = conf:read("*n")
- filename = string.sub(conf:read(),2)
- --print("raid/"..filename,x,y)
- display(filesystem.concat(confdir, filename),x,y)
- x = conf:read("*n")
- end
- conf:close()
- end
- --detects if the help.conf file has updated to change position of text on screen
- function hasUpdated()
- time = filesystem.lastModified(confpath)
- if time > lastupdated then
- lastupdated = time
- return true
- end
- conf = io.open(confpath)
- if conf == nil then
- return false
- end
- x = conf:read("*n")
- while x do
- conf:read("*n")
- filename = string.sub(conf:read(),2)
- time = filesystem.lastModified(confdir..filename)
- if time > lastupdated then
- lastupdated = time
- return true
- end
- x = conf:read("*n")
- end
- conf:close()
- return false
- end
- function display(filename,x,y)
- col1 = io.lines(filename)
- displayText(col1,x,y)
- end
- function displayText(strs, startX, startY)
- k = startY
- for v in strs do
- gpu.set(startX,k,v)
- k=k+1
- end
- end
- gpu.fill(1,1,width,height, " ")
- while 1 do
- sleeptime = 5
- if hasUpdated() then
- gpu.fill(1, 1, width, height, " ")
- loadConf()
- os.sleep(sleeptime)
- else
- loadConf()
- os.sleep(sleeptime)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement