Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local running=1
- local size={term.getSize()}
- function KaoSOS()
- local function count(input)
- if type(input)~="table" then
- print("incorrect input: "..tostring(input))
- sleep(2)
- return
- end
- local int=0
- for a in pairs(input) do
- int=int+1
- end
- return int
- end
- local function getlongest(input)
- if type(input)~="table" then
- print("incorrect input")
- return
- end
- local int=0
- for k,v in pairs(input) do
- for a,b in pairs(v) do
- if string.len(b)>int then
- int=#b
- end
- end
- end
- return int
- end
- function addparam(params)
- print('Current parameters: ')
- for k,v in pairs(params) do
- print(v)
- end
- write('enter new parameter: ')
- params[(#params or 0)+1]=read()
- return 'added'
- end
- function createnew()
- term.clear()
- term.setCursorPos(1,1)
- write('enter new file name: ')
- local new=read()
- if new=='' then
- print('Invalid entry')
- sleep(2)
- elseif fs.exists(new) then
- print('File already exists')
- sleep(2)
- else
- shell.run('edit',new)
- end
- end
- function check(input)
- return menu2.generate({{{'run',{function() running=0 shell.run(input) running=1 term.clear() end}}, {'run with parameters',{runwith,input}}},{{'edit',{function() running=0 shell.run("edit",input) os.queueEvent("forceTimer") running=1 term.clear() end}}, {'delete',{fs.delete,input}}}},15,3,2,size[1]-4,size[2]-2)
- end
- function runwith(input,params)
- local params=params or {}
- while menu2.generate({{{'done',{function() running=0 shell.run(input,unpack(params)) running=1 term.clear() end}},{'add param',{addparam,params}}}},15,3,2,size[1]-4,size[2]-2)=='added' do
- end
- end
- while true do
- local tall={}
- if shell.dir()=='' then
- tall['tdirs']={{}}
- else
- tall['tdirs']={{{'[..\\]',{shell.setDir,shell.resolve("..\\")}}}}
- end
- tall['tfiles']={{{'#new',{createnew}}}}
- for k,v in pairs(fs.list(shell.dir())) do
- if fs.isDir(shell.resolve(v)) then
- var='tdirs'
- else
- var='tfiles'
- end
- if #tall[var][#tall[var]]==3 then
- tall[var][#tall[var]+1]={}
- end
- tall[var][#tall[var]][#tall[var][#tall[var]]+1]={((var=='tdirs' and '['..v..']') or v),{((var=='tdirs' and shell.setDir) or check),shell.resolve(v)}}
- end
- for k,v in pairs(tall['tfiles']) do
- tall['tdirs'][#tall['tdirs']+1]=v
- end
- local size={term.getSize()}
- --drawborder()
- running=1
- menu2.generate(tall['tdirs'],15,3,2,size[1]-4,size[2]-2)
- end
- end
- local function drawborder()
- local size={term.getSize()}
- for i=1,size[2] do
- term.setCursorPos(2,i)
- if i==1 then
- write('/'..string.rep('-',size[1]-4)..'\\')
- elseif i==size[2] then
- write('\\'..string.rep('-',size[1]-4)..'/')
- else
- write('|')
- term.setCursorPos(size[1]-1,i)
- write('|')
- end
- end
- end
- function cyclingborder(processor,delim)
- while true do
- if processor<=size[1]-4 then
- side='top'
- break
- else
- processor=processor-(size[1]-2)
- if processor<=size[2] then
- side='right'
- break
- else
- processor=processor-size[2]
- if processor<=size[1]-4 then
- side='bottom'
- break
- else
- processor=processor-(size[1]-2)
- if processor<=size[2] then
- side='left'
- break
- else
- processor=processor-size[2]
- end
- end
- end
- end
- end
- term.setCursorPos((side=='top' and processor+2) or (side=='bottom' and size[1]-processor-1) or (side=='left' and 2) or (side=='right' and size[1]-1),(side=='top' and 1) or (side=='bottom' and size[2]) or (side=='left' and size[2]-processor) or (side=='right' and processor))
- write(delim or '*')
- end
- function localSleep( _nTime )
- local timer = os.startTimer( _nTime )
- repeat
- local sEvent, param = os.pullEvent( "timer" )
- until param == timer or sEvent == "forceTimer"
- end
- co1=coroutine.create(function() local a=0 while true do a=a+1 drawborder() cyclingborder(a) cyclingborder(a+1) cyclingborder(a+2) cyclingborder(a+3) localSleep(0.1) end end)
- co2=coroutine.create(KaoSOS)
- term.clear()
- os.queueEvent('start')
- while true do
- events={os.pullEvent()}
- coroutine.resume(co2,unpack(events))
- if running==1 then coroutine.resume(co1,unpack(events)) end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement