Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function load(name)
- local file = fs.open(name,"r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- function save(table,name)
- local file = fs.open(name,"w")
- file.write(textutils.serialize(table))
- file.close()
- end
- function tablelength(T)
- local count = 0
- for _ in pairs(T) do count = count + 1 end
- return count
- end
- local function centerText(text)
- local x,y = term.getSize()
- local x2,y2 = term.getCursorPos()
- term.setCursorPos(math.floor((x / 2) - (string.len(text) / 2)), y2)
- write(text)
- end
- function create(x,y,width,height,color,mon)
- mon.setCursorPos(x,y)
- for j = 0, height do
- mon.setCursorPos(x,y+j)
- for i = 0,width do
- mon.setBackgroundColor(color)
- mon.write(" ")
- end
- end
- end
- function clearAll(mon, color)
- local w,h = mon.getSize()
- for i = 0,h do
- for j = 0, w do
- mon.setCursorPos(1+j,1+i)
- mon.setBackgroundColor(color)
- mon.write(" ")
- end
- end
- end
- function file_exists(name)
- local f=io.open(name,"r")
- if f~=nil then io.close(f) return true else return false end
- end
- local all = 0
- local version = "2.0"
- local mfsu = {}
- local strom = {}
- local length = 0
- local counter = 0
- local stopIt = false
- term.clear()
- function getAllEU()
- local all = 0
- for i = mfsu[1], tablelength(mfsu)+mfsu[1]-1 do
- all = all + strom[i]
- end
- return all
- end
- function progressBar()
- mfsu = load("saves/id")
- for i = mfsu[1], tablelength(mfsu)+mfsu[1]-1 do
- nb = peripheral.wrap("mfsu_" .. i)
- EU = nb.getEUStored()
- strom[i] = EU
- end
- term.write(getAllEU() .."/".. (tablelength(mfsu) * 40000000).."EU")
- sleep(1)
- end
- function startMessage()
- clearAll(term,colors.blue)
- term.setTextColor(colors.white)
- term.setCursorPos(1,1)
- centerText("Welcome to Sutrang's Glass Version ".. version)
- sleep(1)
- end
- function settings()
- term.clear()
- term.setCursorPos(1,1)
- local w, h = term.getSize()
- create(0,0,w, h, colors.blue,term)
- term.setTextColor(colors.white)
- startMessage()
- term.setCursorPos(1,3)
- centerText("Network Cable Side:")
- networkcableside = read()
- save(networkcableside, "saves/networkcable")
- term.setCursorPos(1,5)
- centerText("Name your MFSU's:")
- name = read()
- save(name, "saves/name")
- while stopIt ~= true do
- counter = counter + 1
- term.setCursorPos(1,8 + counter)
- centerText("Write id of your MFSU's:")
- message = read()
- if message == "" then
- stopIt = true
- term.clearLine()
- else
- table.insert(mfsu, message)
- end
- end
- save(mfsu, "saves/id")
- startMessage()
- end
- --{MAIN PROGRAMM}--
- --{INIT}--
- fs.makeDir("saves")
- term.clear()
- term.setCursorPos(1,1)
- if fs.exists("saves/id") ~= true then
- settings()
- end
- networkcableside = load("saves/networkcable")
- nb = peripheral.wrap(networkcableside)
- while true do
- progressBar()
- end
- --{INIT}--
Advertisement
Add Comment
Please, Sign In to add comment