Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Progression API
- -- [By Reububble] --
- function sum()
- wide,high=term.getSize()
- term.setTextColor(2^15)
- while true do
- type,b=os.pullEvent('progress')
- if b~=nil then
- if b<1 then break end
- term.setBackgroundColor(1)
- for y=high/2-1,high/2+1 do
- term.setCursorPos(2,y)
- term.write(string.rep(' ',wide-2))
- end
- term.setCursorPos((wide-#tostring(b))/2,high/2)
- term.write(b)
- end
- end
- end
- function bar()
- wide,high=term.getSize()
- a,b,t=0,0,os.time()*50
- pA = ""
- pB = 0
- pC = 0
- pD = ""
- term.setTextColor(2^15)
- while true do
- s1=os.time()*50
- a=b
- type,b=os.pullEvent("progress")
- if b>=1 then
- return
- end
- s2=os.time()*50
- if s2<t then
- t=t-600
- end
- term.setCursorPos(2,high/2-1)
- term.setBackgroundColor(1)
- term.write(string.rep(" ",wide-2))
- pA="Time Elapsed : "..tostring(math.floor(s2-t))
- term.setCursorPos((wide-#pA)/2,high/2-1)
- term.write(pA)
- term.setCursorPos(2,high/2+1)
- term.write(string.rep(" ",wide-2))
- if 2*s2-t-s1==0 then
- pD="Time remaining : 0"
- else
- pD="Time remaining : "..tostring(math.ceil((1-b)*(((s2-t)/b)*(s2-t)+(s2-s1)*((s2-s1)/(b-a)))/(2*s2-t-s1)))
- end
- term.setCursorPos((wide-#pD)/2,high/2+1)
- term.write(pD)
- term.setCursorPos(2,high/2)
- term.write(" ")
- term.setBackgroundColor(2^14)
- pC=math.floor(b*100).."%" --text
- pB=math.floor(b*(wide-4)) --amound of Red
- term.write(string.rep(" ",pB))
- if pB>0 then
- term.setCursorPos(3,high/2)
- term.write(string.sub(pC,1,pB))
- end
- term.setBackgroundColor(2^5)
- term.setCursorPos(pB+3,high/2)
- term.write(string.rep(" ",math.ceil((1-b)*(wide-4))))
- if pB<#pC then
- term.setCursorPos(pB+3,high/2)
- term.write(string.sub(pC,pB+1))
- end
- term.setBackgroundColor(1)
- term.setCursorPos(wide-1,high/2)
- term.write(" ")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement