Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = {...}
- local mins = 30
- if args[1] ~= nil then mins = tonumber(args[1]) end
- local mins30 = mins*60
- local on = true
- local signal = true
- local function doSignal()
- redstone.setOutput("back", signal)
- end
- local width, height = term.getSize()
- local function draw(per)
- local perw = math.floor((width/100)*per)
- local perc = math.ceil( ((width/100)*(per+1)) - math.floor((width/100)*per) )/100
- for x=1,width do
- local char = " "
- for y=1,height do
- if x <= perw then
- if x == perw then
- if y <= perc then char = "%" else char = " " end
- else
- char = "%"
- end
- end
- term.setCursorPos(x, y)
- local col = colors.lime
- if not signal then col = colors.red end
- term.setBackgroundColor(col)
- term.setTextColor(colors.white)
- term.write(char)
- end
- end
- end
- local t = 0
- local percent = mins30/100
- local timer = os.startTimer(percent)
- while on do
- local event, p1 = os.pullEvent()
- if event == "key" then
- if p1 == 29 then
- on = false
- end
- elseif event == "timer" and timer == p1 then
- t = t + 1
- if t >= 100 then
- signal = (signal == false)
- t = 0
- end
- doSignal()
- draw(t)
- timer = os.startTimer(percent)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement