Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Needs to do: Text snapping to the left at approximately 40% completion of loading bar needs fixing
- --Variables
- mon = term
- monX, monY = mon.getSize()
- --Functions
- clear = function()
- mon.setBackgroundColor(colors.black)
- mon.clear()
- mon.setCursorPos(1,1)
- end
- drawText = function(x,y,text,color_text,color_bg)
- mon.setBackgroundColor(color_bg)
- mon.setTextColor(color_text)
- mon.setCursorPos(x,y)
- mon.write(text)
- end
- drawLine = function(x,y,length,size,color_bar)
- for yPos = y, y+size-1 do
- mon.setBackgroundColor(color_bar)
- mon.setCursorPos(x,yPos)
- mon.write(string.rep(" ", length))
- end
- end
- drawProg = function(x,y,name,length,size,minVal,maxVal,color_bar,color_bg)
- drawLine(x,y,length,size,color_bg)
- local barSize = math.floor((minVal/maxVal)*length)
- drawLine(x,y,barSize,size,color_bar)
- local text = name.." "..math.floor((minVal/maxVal)*100).."%"
- if barSize > monX/2+#text/2 then
- drawText(monX/2-#text/2+2,y+size/2,text,colors.black,color_bar)
- elseif barSize > #text then
- drawText((x+barSize)-#text,y+size/2,text,colors.black,color_bar)
- else
- drawText(monX/2-#text/2+2,y+size/2,text,colors.black,color_bg)
- end
- end
- --Main Stuff Loop
- for i = 1, 100 do
- drawProg(2,12,"Initialising",monX-2,3,i,100,colors.lime,colors.gray)
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement