Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- allEU = 0
- counter = 0
- local mfsu = {}
- ckd = 0
- 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
- 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)
- while stopIt ~= true do
- counter = counter + 1
- term.setCursorPos(1,4 + 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")
- end
- fs.makeDir("saves")
- term.clear()
- term.setCursorPos(1,1)
- if fs.exists("saves/id") ~= true then
- settings()
- end
- function getAllEU()
- allEU = 0
- mfsu = load("saves/id")
- for i = 1, tablelength(mfsu) do
- p = peripheral.wrap("mfsu_"..mfsu[i])
- allEU = allEU + p.getEUStored()
- end
- return allEU
- end
- while true do
- term.clear()
- term.setCursorPos(1,1)
- local w, h = term.getSize()
- create(0,0,w, h, colors.blue,term)
- term.setTextColor(colors.white)
- eu = getAllEU()
- term.clear()
- mfsu = load("saves/id")
- centerText(eu .. "/" .. tablelength(mfsu) * 40000000)
- term.setCursorPos(1,1)
- local w, h = term.getSize()
- create(0,0,w, h-4, colors.black,term)
- ckd = ckd + 1
- euheight = eu / (tablelength(mfsu) * 40000000) * h-4
- create(0,0,w, euheight, colors.orange,term)
- sleep(0.5)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement