Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function drawProgBar(done, max, x, y, wide, colorBright, colorDark)
- local oldX, oldY = term.getCursorPos()
- local oldBC = term.getBackgroundColor()
- local oldTC = term.getTextColor()
- local val = done / max
- term.setBackgroundColor(colors.black)
- term.setTextColour(colors.black)
- if oldBC == colors.black then
- term.setBackgroundColor(colors.black)
- term.setTextColor(colors.gray)
- end
- term.setCursorPos(x,y)
- write((string.char(153)):rep(wide))
- term.setTextColor(colorDark)
- term.setBackgroundColor(colorBright)
- term.setCursorPos(x,y)
- write((string.char(153)):rep(math.floor(val
- * wide)))
- term.setBackgroundColor(oldBC)
- term.setTextColour(oldTC)
- term.setCursorPos(oldX, oldY)
- end
- function calcPercent(done, max)
- local val = done / max
- local per = math.floor(val * 100)
- return per
- end
- function tableCount(t)
- local table = t
- local count = 0
- for _ in pairs(table) do
- count = count + 1
- end
- return count
- end
- function smoothAdd(fromNum, toNum, speed)
- return ((toNum - fromNum) / (speed or 10))
- end
- local demo = false
- local per = 0
- local change = 0.1
- local max = 10
- local w, h = term.getSize()
- while demo do
- w, h = term.getSize()
- if per > max then
- per = max
- change = -0.1
- end
- if per < 0 then
- per = 0
- change = 0.1
- end
- drawProgBar(per, max, 2, 2, 5, colors.green, colors.lime)
- drawProgBar(per, max, 2, 4, 10, colors.blue, colors.cyan)
- drawProgBar(per, max, 2, 6, 15, colors.red, colors.orange)
- per = per + change
- sleep(0.1)
- end
Add Comment
Please, Sign In to add comment