Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local char="*"
- local function drawRect(x,y,w,h, clear)
- clear = clear or false
- local ch
- if clear then
- ch = " "
- else
- ch = char
- end
- for i=x-w/2,x+w/2 do
- term.setCursorPos(i,y-h/2)
- term.write(ch)
- term.setCursorPos(i,y+h/2)
- term.write(ch)
- end
- for i=y-h/2+1,y+h/2-1 do
- term.setCursorPos(x-w/2,i)
- term.write(ch)
- term.setCursorPos(x+w/2,i)
- term.write(ch)
- end
- end
- local function animateRect(x,y,w,h)
- local l = math.min(w,h)
- for i=1,l/2 do
- drawRect(x,y,w*2*(i/l),h*2*(i/l))
- sleep(0)
- drawRect(x,y,w*2*(i/l),h*2*(i/l),true)
- end
- drawRect(x,y,w,h)
- end
- local function slowPrint(x,y,str)
- local s=str
- local w = 0
- local h = 0
- while #s > 1 do
- local ind = string.find(s,'\n')
- local line = ""
- if not ind then
- line = s
- s=""
- else
- line = string.sub(s,1,ind)
- s = string.sub(s,ind)
- end
- if not line then
- break
- end
- w=max(w,#line)
- h=h+1
- end
- animateRect(x,y,w+2,h+2)
- term.setCursorPos(x-w/2+1,y-h/2+1)
- textutils.slowPrint(str)
- end
- --animateRect(25,9,20,10)
- slowPrint(25,9,'test')
Add Comment
Please, Sign In to add comment