Andy73

vBenchmark Minified

Jun 8th, 2015
618
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 16.86 KB | None | 0 0
  1. local s={
  2. App="0.2.3",
  3. DebugID="REL",
  4. }
  5. local m=false
  6. term.redirect(term.native())
  7. local i,r=term.getSize()
  8. term.setBackgroundColor(colors.black)
  9. term.clear()
  10. term.setCursorPos(1,1)
  11. local function t(e,o,a)
  12. if not fs.exists("/"..(a and e..".lua"or e))and not _G[e]then
  13. printError("No "..e.." API found, downloading one...")
  14. shell.run("pastebin get "..o.." /"..(a and e..".lua"or e))
  15. error()
  16. end
  17. return true
  18. end
  19. t("sha256","P3KBjR3M")
  20. t("aes","DMx8M0LP")
  21. t("crc32","x52gQYWp")
  22. t("json","jK22eUfn")
  23. t("Test","wZbpA1Gy",true)
  24. local t={
  25. ["Test.lua"]=dofile,
  26. ["sha256"]=os.loadAPI,
  27. ["aes"]=os.loadAPI,
  28. ["crc32"]=os.loadAPI,
  29. ["json"]=os.loadAPI,
  30. }
  31. for t,e in pairs(t)do
  32. local t,e=pcall(e,"/"..t)
  33. if not t then print(e)sleep(2)end
  34. end
  35. pcall(fs.delete,"/.vBenchmarkUpdater.lua")
  36. s.Library=Test.Version
  37. local function y()
  38. local e=tostring({})
  39. os.queueEvent(e)
  40. coroutine.yield(e)
  41. end
  42. local function v(a,o)
  43. local e={}
  44. for t in pairs(a)do table.insert(e,t)end
  45. table.sort(e,o)
  46. local t=0
  47. local e=function()
  48. t=t+1
  49. if e[t]==nil then return nil
  50. else return e[t],a[e[t]]
  51. end
  52. end
  53. return e
  54. end
  55. local n
  56. local l={
  57. ["ow"]="Optimized write test",
  58. ["uw"]="Unoptimized write test",
  59. ["tb"]="term.blit write test",
  60. ["ct"]="Color swap/rainbow test",
  61. ["lc"]="Line clear speed test",
  62. ["cs"]="Clear speed test",
  63. ["scr"]="Buffer scroll test",
  64. ["aa"]="Anti-aliasing test",
  65. ["hsh"]="SHA256 hash test",
  66. ["aese"]="AES Encryption perf. test",
  67. ["aesd"]="AES Decryption perf. test",
  68. ["tec"]="Table entry creation",
  69. ["ted"]="Table entry deletion",
  70. ["tea"]="Table entry access",
  71. ["dhke"]="Diffie-Hellman key exchange",
  72. ["crc"]="CRC32 hash test",
  73. ["cmpl1"]="Simple compilation",
  74. ["cmpl2"]="Medium compilation",
  75. }
  76. local d={}
  77. for e,t in pairs(l)do
  78. d[e]=true
  79. end
  80. local o="/benchmark.txt"
  81. local a=2
  82. local t=1e4
  83. local function u(e)
  84. if type(e)~="string"then error("(1)Expected string, got "..type(e),2)end
  85. if e:sub(#e,#e)~=","then e=e..","end
  86. local t={}
  87. for e in e:gmatch("(%a+),")do
  88. table.insert(t,e)
  89. end
  90. return t
  91. end
  92. local function f(e)
  93. local t=[[
  94.  
  95. Welcome to vBenchmark!
  96.      
  97.   vBenchmark is a complex benchmarking program for ComputerCraft 1.6+, made by viluon (a.k.a. Andy73)
  98.  
  99.   [Usage]
  100.     vBenchmark -option value --flag -option2 list,of,values
  101.    
  102.    
  103.  
  104.     NOTE: Options and flags are executed in the order they're supplied in
  105.      
  106.    <required value> [optional value] (name)
  107.  
  108.    Available options:
  109.    =================
  110.      update (update) updates the program
  111.      =====
  112.      help OR ? OR /? ['light'] (help/usage) displays this page, optionally using black text on white background (this option stops the execution automatically)
  113.      =====
  114.      -o <path> (output) sets the output file to <path>
  115.      =====
  116.      -list [path] (list) lists the names and corresponding codes of available benchmark functions, optionally saving them to [path]
  117.      =====
  118.      -maxtime <seconds> (maximum time limit) sets the time limit per ONE benchmark function to <seconds> - default: 2
  119.      =====
  120.      -maxcalls <calls> (maximum function calls) sets the maximum amount of function calls per ONE benchmark function to <calls> - default: 10 000
  121.      =====
  122.      -exclude <tests> (exclude) excludes a list of tests from the benchmark, <tests> is a list of test codes
  123.      =====
  124.      -testonly <tests> (test only) sets the test list for the benchmark to <tests>
  125.      =====
  126.  
  127.    Available flags:
  128.    ===============
  129.      --test (test) prints some debug text on the screen
  130.      =====
  131.      --stop (stop) stops the execution of the benchmark
  132.      =====
  133.      --version (version info) displays the version information of the program and used libraries
  134.      =====
  135.      --SUICIDE (suicidal mode) Enables the suicidal mode:
  136.          Suicidal mode is intended for debugging, evaluating and precision testing of CC emulators or SINGLEPLAYER CC. Do NOT use the suicidal benchmark in multiplayer!!! Suicidal benchmark does not yield to produce the most relevant results. As such, it should NOT be used for regular benchmarking. The suicidal mode can corrupt files and do IRREVERSIBLE HARM!!! Use at your own risk.
  137.      =====
  138.      --safe (safe mode) enables safety features:
  139.          -output file backup
  140.          -visible error reports - launches the benchmark in a temporary handler (/.vBenchmarkSafe) that pauses after crashing => errors visible
  141.          -does not intersect with suicidal mode
  142.      ]]
  143. term.setBackgroundColor(e and colors.white or colors.black)
  144. term.setTextColor(e and colors.black or colors.white)
  145. term.clear()
  146. term.setCursorPos(1,1)
  147. textutils.pagedPrint(t)
  148. end
  149. local c={...}
  150. local h={}
  151. for e,t in pairs(c)do
  152. h[e]=t
  153. end
  154. local m={
  155. ["test"]=function()
  156. print"This is a test"
  157. sleep(3)
  158. end,
  159. ["stop"]=function()
  160. error()
  161. end,
  162. ["version"]=function()
  163. print(textutils.serialize(s))
  164. end,
  165. ["suicide"]=function()
  166. m=true
  167. end,
  168. ["safe"]=function()
  169. if fs.exists(o)then
  170. local e,t=".bkp1",2
  171. while fs.exists(o..e)do
  172. e=".bkp"..t
  173. t=t+1
  174. end
  175. local t,e=pcall(fs.copy,o,o..e)
  176. if not t then
  177. print"[ERROR] Failed to create backup"
  178. print(e)
  179. print"Press ENTER to exit"
  180. read" "
  181. end
  182. end
  183. local t=fs.open("/.vBenchmarkSafe","w")
  184. if not t then print"[ERROR] Failed to open file for writing: /.vBenchmarkSafe"print(e)sleep(5)error()end
  185. t.write([[
  186. print"Launching vBenchmark in safe mode"
  187. sleep(2)
  188. local path,args="]]..shell.getRunningProgram()..[[",{...}
  189. local f=fs.open(path,"r")
  190. local fn=f.readAll()
  191. f.close()
  192. fn=loadstring(fn,"vBenchmark [SAFE MODE]")
  193. if not fn then error("Failed to execute safe mode: file is corrupt!",0) end
  194. setfenv(fn,setmetatable({shell=setmetatable({getRunningProgram=function()return path end},{__index=_G})},{__index=_G}))
  195. local ok,err=pcall(fn,unpack(args)) --line 10
  196. if not ok then
  197. printError"vBenchmark has crashed."
  198. print""
  199. print(err)
  200. print"Enter to continue..."
  201. read" "
  202. end
  203. return true
  204.  
  205. --line 20
  206. ]])
  207. t.close()
  208. local e=c
  209. for t,a in pairs(e)do
  210. if a:lower()=="--safe"then table.remove(e,t)end
  211. if#e<1 or#e==t then break end
  212. end
  213. shell.run("/.vBenchmarkSafe",unpack(e))
  214. error()
  215. end,
  216. }
  217. local u={
  218. ["o"]={
  219. function(e)
  220. if type(e)~="string"then error("Expected string as output path, got "..type(e),0)end
  221. o=e
  222. end,
  223. 1,
  224. 1,
  225. },
  226. ["list"]={
  227. function(e)
  228. for e,t in pairs(l)do
  229. print(t.."="..e)
  230. end
  231. if type(e)=="string"then
  232. if fs.exists(e)then
  233. local e=fs.open(e,"w")
  234. e.write(textutils.serialize(l))
  235. e.close()
  236. end
  237. end
  238. end,
  239. 1,
  240. 0,
  241. },
  242. ["maxcalls"]={
  243. function(e)
  244. if not tonumber(e)then error("Expected number for the maximum amount of calls, got "..type(e),0)end
  245. t=tonumber(e)
  246. end,
  247. 1,
  248. 1,
  249. },
  250. ["maxtime"]={
  251. function(e)
  252. if not tonumber(e)then error("Expected number for the maximum time, got "..type(e),0)end
  253. a=tonumber(e)
  254. end,
  255. 1,
  256. 1,
  257. },
  258. ["testonly"]={
  259. function(e)
  260. if type(e)~="string"then error("Expected string as a list of tests, got "..type(e),0)end
  261. d={}
  262. for t,e in pairs(u(e))do
  263. d[e]=true
  264. end
  265. end,
  266. 1,
  267. 1,
  268. },
  269. ["exclude"]={
  270. function(e)
  271. for t,e in pairs(u(e))do
  272. d[e]=false
  273. end
  274. end,
  275. 1,
  276. 1,
  277. },
  278. }
  279. for a,e in pairs(h)do
  280. if e:sub(1,2)=="--"then
  281. if not m[e:sub(3,#e):lower()]then print("Hint: use '"..shell.getRunningProgram().." help' to see the proper usage")error("Unknown flag: "..e:sub(3,#e),0)end
  282. m[e:sub(3,#e):lower()]()
  283. elseif e:sub(1,1)=="-"then
  284. if not u[e:sub(2,#e):lower()]then print("Hint: use '"..shell.getRunningProgram().." help' to see the proper usage")error("Unknown option: "..e:sub(2,#e),0)end
  285. local t={}
  286. for e=a+1,a+u[e:sub(2,#e):lower()][2]do
  287. if not h[e]then break end
  288. if h[e]:sub(1,1)=="-"then break end
  289. t[#t+1]=h[e]
  290. h[e]=nil
  291. end
  292. u[e:sub(2,#e):lower()][1](unpack(t))
  293. elseif e:lower()=="help"or e=="?"or e=="/?"then
  294. if h[a+1]=="light"then return f(true)end
  295. return f()
  296. elseif e:lower()=="update"then
  297. local e=fs.open("/.vBenchmarkUpdater.lua","w")
  298. e.write("shell.run'rm "..shell.getRunningProgram().."'shell.run'pastebin get nCEk57MH "..shell.getRunningProgram().."'print'Update complete'sleep(3)return shell.run'"..shell.getRunningProgram().." --stop'")
  299. e.close()
  300. return shell.run"/.vBenchmarkUpdater.lua"
  301. end
  302. end
  303. Test.SetTaskList(d)
  304. local function b()
  305. local i,o=term.getSize()
  306. local function e(e,t,a)
  307. term.setBackgroundColor(t or colors.black)
  308. term.setTextColor(e or colors.white)
  309. term.clear()
  310. for e=1,o do
  311. term.setCursorPos(1,e)
  312. term.write(string.rep(a or"X",i))
  313. end
  314. end
  315. local n=Test.New("ow",nil,t,a,true,e)
  316. n.Run()
  317. print(unpack(unpack({n.GetResults()})))
  318. local function n(e,t,a)
  319. term.setBackgroundColor(t or colors.black)
  320. term.setTextColor(e or colors.white)
  321. term.clear()
  322. for t=1,o do
  323. for e=1,i do
  324. term.setCursorPos(e,t)
  325. term.write(a or"X")
  326. end
  327. end
  328. end
  329. local n=Test.New("uw",nil,t,a,true,n)
  330. n.Run()
  331. local function n()
  332. for e=1,o do
  333. term.setCursorPos(1,e)
  334. term.blit("asd")
  335. end
  336. end
  337. local function n()
  338. for e=0,15 do
  339. term.setBackgroundColor(2^e)
  340. term.clear()
  341. end
  342. end
  343. local n=Test.New("ct",nil,t,a,true,n)
  344. n.Run()
  345. local function n(e)
  346. term.setBackgroundColor(e or colors.black)
  347. for e=1,o do
  348. term.setCursorPos(1,e)
  349. term.clearLine()
  350. end
  351. end
  352. local n=Test.New("lc",nil,t,a,true,n)
  353. n.Run()
  354. term.setBackgroundColor(colors.black)
  355. local n=term.clear
  356. local n=Test.New("cs",nil,t,a,true,n)
  357. n.Run()
  358. local function n()
  359. e()
  360. for e=1,o do
  361. term.scroll(1)
  362. end
  363. end
  364. local e=Test.New("scr",nil,t,a,true,n)
  365. e.Run()
  366. local n=function(t,a,e)
  367. alphaStep=255/4
  368. if e>255-alphaStep then
  369. term.setBackgroundColor(colors.white)
  370. elseif e>255-alphaStep*2 then
  371. term.setBackgroundColor(colors.lightGray)
  372. elseif e>255-alphaStep*3 then
  373. term.setBackgroundColor(colors.gray)
  374. else
  375. term.setBackgroundColor(colors.black)
  376. return
  377. end
  378. term.setCursorPos(t,a)
  379. term.write(" ")
  380. end
  381. local r=function(e,t,a,o)
  382. dx=math.abs(a-e)
  383. if e<a then sx=1 else sx=-1 end
  384. dy=math.abs(o-t)
  385. if t<o then sy=1 else sy=-1 end
  386. err=dx-dy
  387. if dx+dy==0 then
  388. ed=1
  389. else
  390. ed=math.sqrt(dx*dx+dy*dy)
  391. end
  392. while true do
  393. n(e,t,255-(255*math.abs(err-dx+dy)/ed));
  394. e2=err
  395. x2=e
  396. if(2*e2>=-dx)then
  397. if(e==a)then break end
  398. if(e2+dy<ed)then n(e,t+sy,255-(255*(e2+dy)/ed))end
  399. err=err-dy;
  400. e=e+sx;
  401. end
  402. if(2*e2<=dy)then
  403. if(t==o)then break end
  404. if(dx-e2<ed)then n(x2+sx,t,255-(255*(dx-e2)/ed))end
  405. err=err+dx;
  406. t=t+sy;
  407. end
  408. end
  409. end
  410. local e,e=math.floor(i/4),math.floor(o/2)
  411. local function d()
  412. local o,n=1,1
  413. local s,h=15,15
  414. local e,a,t,i=o,n,o+1,n+1
  415. return function()
  416. r(e,a,t,i)
  417. if t>s then t=o i=i+1
  418. elseif i>h then
  419. elseif e>s then e=o a=a+1
  420. elseif a>h then a=n t=t+1
  421. else e=e+1 end
  422. end
  423. end
  424. local e=Test.New("aa",nil,t,a,true,d())
  425. e.Run()
  426. end
  427. local function g()
  428. local o=256
  429. local e=""
  430. for t=1,o do
  431. e=e..
  432. string.char(math.random(128))
  433. end
  434. local o=sha256.sha256
  435. local e=Test.New("hsh","Math",t,a,true,o,e)
  436. e.Run()
  437. local e=crc32.Hash
  438. local o,n,i=false
  439. local function s(s,a)
  440. local e=""
  441. local t=""
  442. for t=1,s do
  443. e=e.."b"
  444. end
  445. for e=1,a do
  446. t=t..string.char(math.random(128))
  447. end
  448. o=aes.encrypt(e,t)
  449. n=e
  450. i=true
  451. end
  452. local e=Test.New("aese","Math",t,a,true,s,32,2048)
  453. e.Run()
  454. local e=aes.decrypt
  455. if i then
  456. local e=Test.New("aesd","Math",t,a,true,e,n,o)
  457. e.Run()
  458. end
  459. local function s()
  460. local function t(e,a,t)
  461. for a=1,a-1 do
  462. e=e*e
  463. if e>=t then
  464. e=e%t
  465. end
  466. end
  467. return e
  468. end
  469. local o,e=11,625210769
  470. local i=math.random(1e5,999999)
  471. local a=math.random(1e5,999999)
  472. local n=t(o,i,e)
  473. local o=t(o,a,e)
  474. t(o,i,e)
  475. t(n,a,e)
  476. end
  477. local e=Test.New("dhke","Math",t,a,true,s)
  478. e.Run()
  479. local function o()
  480. local e=[[
  481.   do end
  482.   ]]
  483. loadstring(e)
  484. end
  485. local e=Test.New("cmpl1","Math",t,a,true,o)
  486. e.Run()
  487. local function e()
  488. local e=[[
  489.   local function asd()
  490.     while true do end
  491.   end
  492.   for i=1,10 do
  493.     print(i)
  494.   end
  495.   return _G.x or asd
  496.   ]]
  497. loadstring(e)
  498. end
  499. local e=Test.New("cmpl2","Math",t,a,true,e)
  500. e.Run()
  501. local function e()
  502. end
  503. end
  504. local function u()
  505. end
  506. local function m()
  507. end
  508. local function f()
  509. end
  510. local function h()
  511. local function o()
  512. local e={}
  513. for t=1,4e4 do
  514. e[#e+1]=true
  515. end
  516. e=nil
  517. end
  518. local e=Test.New("tec","Memory Allocation",t,a,true,o)
  519. e.Run()
  520. local function o()
  521. local e={}
  522. for t=1,4e4 do
  523. e[#e+1]=true
  524. end
  525. for t,a in ipairs(e)do
  526. e[t]=nil
  527. end
  528. e=nil
  529. end
  530. local e=Test.New("ted","Memory Allocation",t,a,true,o)
  531. e.Run()
  532. local function e()
  533. local e={true}
  534. local t=false
  535. for a=1,4e4 do
  536. t=e[1]
  537. end
  538. end
  539. local e=Test.New("tea","Memory Allocation",t,a,true,e)
  540. e.Run()
  541. end
  542. local t,a={},1
  543. t[1]=window.create(term.native(),1,1,i,r-5,true)
  544. local function w()
  545. for e,a in pairs(t)do
  546. t[e].setVisible(false)
  547. end
  548. end
  549. local function p()
  550. n=Test.GetResults()
  551. local e
  552. if fs.exists(o)then
  553. local t=fs.open(o,"r")
  554. e=t.readAll()
  555. t.close()
  556. e=textutils.unserialize(e)
  557. if not e then
  558. local t=o.."-unsupported.txt"
  559. local e=1
  560. while fs.exists(t)do
  561. t=o.."-unsupported"..e..".txt"
  562. e=e+1
  563. end
  564. fs.move(o,t)
  565. end
  566. n["Last"]=e
  567. end
  568. term.setBackgroundColor(colors.black)
  569. term.setTextColor(colors.white)
  570. term.clear()
  571. term.setCursorPos(1,1)
  572. local a={}
  573. for e,t in pairs(n)do
  574. if e~="Last"and e~="Version"and e~="Median"then
  575. if not a[t["g"]]then a[t["g"]]={}end
  576. table.insert(a[t["g"]],e)
  577. end
  578. end
  579. for a,o in pairs(a)do
  580. term.setTextColor(colors.yellow)
  581. print(a)
  582. local a={}
  583. for t,e in pairs(o)do
  584. a[l[e]]=e
  585. end
  586. for o,a in v(a)do
  587. if d[a]then
  588. term.setTextColor(colors.white)
  589. term.write("  "..o..": ")
  590. term.setTextColor(colors.lightGray)
  591. term.write((n[a]["mark"]).."")
  592. if e and e[a]and type(e[a]["mark"])=="number"and(e.Version and(e.Version.Library and(Test.Version and(e.Version.Library.Matrix==Test.Version.Matrix))))then
  593. term.setTextColor((e[a]["mark"]>n[a]["mark"]and colors.red or colors.lime))
  594. term.write(" "..(e[a]["mark"]>n[a]["mark"]and"v"or"^"))
  595. term.setTextColor(colors.lightGray)
  596. print(" ("..(e[a]["mark"])..")")
  597. else
  598. print()
  599. end
  600. local a,e=term.getCursorPos()
  601. if e>r-9 then
  602. t[#t+1]=window.create(term.native(),1,1,i,r-5,false)
  603. term.redirect(t[#t])
  604. end
  605. end
  606. end
  607. end
  608. term.redirect(term.native())
  609. end
  610. local function l()
  611. w()
  612. t[a].setVisible(true)
  613. t[a].redraw()
  614. local o,e=term.getCursorPos()
  615. term.setBackgroundColor(colors.black)
  616. term.setTextColor(colors.gray)
  617. term.setCursorPos(i-10,r-5)
  618. term.write("page ")
  619. term.setTextColor(colors.lightGray)
  620. term.write(a.."/"..#t.."    ")
  621. term.setCursorPos(o,e)
  622. end
  623. local function e()
  624. b()
  625. g()
  626. u()
  627. m()
  628. f()
  629. h()
  630. end
  631. e()
  632. term.setBackgroundColor(colors.black)
  633. term.clear()
  634. term.redirect(t[1])
  635. p()
  636. term.setCursorPos(1,r-5)
  637. local h,e=term.getCursorPos()
  638. term.setCursorPos(i/2-5,e+2)
  639. term.setTextColor(colors.gray)
  640. term.write"Loading..."
  641. term.setTextColor(colors.white)
  642. term.setCursorPos(h,e)
  643. local h=fs.open(shell.getRunningProgram(),"r")
  644. local e="''"
  645. if http then
  646. local t=http.get"http://acos.bluefile.cz/Utilities/Online/ip.php"
  647. if t then
  648. e=t.readAll()
  649. t.close()
  650. end
  651. end
  652. e=textutils.unserialize(e)
  653. local d=h.readAll()
  654. h.close()
  655. s.Hash=sha256.sha256(d)
  656. s.Fingerprint=sha256.sha256(s.Hash.."Fingerprint"..os.getComputerID()..e)
  657. n["Version"]=s
  658. local e=fs.open(o,"w")
  659. e.write("--viluon's Ultimate Benchmark output, os.time()="..os.time()..", os.day()="..os.day().."\n\n")
  660. e.write(textutils.serialize(n))
  661. y""
  662. e.close()
  663. local n,e=0,n.Last
  664. while true do
  665. n=n+1
  666. if e==nil then break end
  667. e=(e and e.Last or nil)
  668. end
  669. print""
  670. print("Total runs:"..n)
  671. print("Results were logged (see "..o.."). Would you like to re-run the benchmark now?")
  672. print""
  673. term.setBackgroundColor(colors.green)
  674. term.setTextColor(colors.white)
  675. term.write(string.rep(" ",((i/2)/2)-4).."[Re-run]"..string.rep(" ",((i/2)/2)-3))
  676. term.setBackgroundColor(colors.red)
  677. term.setTextColor(colors.black)
  678. term.write(string.rep(" ",((i/2)/2)-3).."[Exit]"..string.rep(" ",((i/2)/2)-1))
  679. local n=false
  680. while true do
  681. l()
  682. local e={coroutine.yield()}
  683. if e[1]=="mouse_scroll"then
  684. a=a+e[2]
  685. elseif e[1]=="mouse_click"and e[4]==r then
  686. if e[3]<i/2 then
  687. n=true break
  688. else
  689. local e={
  690. "       ______________________________________",
  691. "      / | \\            |                 |  ",
  692. "_    /  |_/  _       _ |_         _      |  ",
  693. " \\  /   | \\ /_\\ +-+ /  | | +-+-+ '_\\ ,_  |/ ",
  694. "  \\/    |_/ \\_  | | \\_ | | | | | (_| | ' |\\ "
  695. }
  696. local a,t=term.getSize()
  697. local t=a/2
  698. local i=window.create(term.native(),t,1,#e[1],5,true)
  699. term.setBackgroundColor(colors.black)
  700. term.clear()
  701. term.setCursorPos(2,6)
  702. term.write"(c) "
  703. term.setTextColor(colors.yellow)
  704. term.write"viluon"
  705. term.setTextColor(colors.white)
  706. term.write" 2015"
  707. term.redirect(i)
  708. term.setTextColor(colors.yellow)
  709. for t,e in ipairs(e)do
  710. term.setCursorPos(1,t)
  711. term.write(e:sub(1,6))
  712. end
  713. term.setTextColor(colors.white)
  714. term.setCursorPos(1,3)
  715. term.write"_"
  716. for o=6,#e[1]do
  717. for a,e in ipairs(e)do
  718. term.setCursorPos(o,a)
  719. term.write(e:sub(o,o))
  720. end
  721. t=t-((a/2-2)/(#e[1]-6))
  722. i.reposition(t,1)
  723. sleep(0)
  724. end
  725. term.redirect(term.native())
  726. term.setCursorPos(a-#s.App-(a-#e[1]),6)
  727. term.write("v"..s.App)
  728. sleep(1)
  729. break
  730. end
  731. elseif e[1]=="key"then
  732. if e[2]==keys.right or e[2]==keys.pageDown then
  733. a=a+1
  734. elseif e[2]==keys.left or e[2]==keys.pageUp then
  735. a=a-1
  736. end
  737. end
  738. if a<1 then a=1
  739. elseif a>#t then a=#t end
  740. end
  741. if n then term.setTextColor(colors.white)shell.run"clear"return shell.run(shell.getRunningProgram(),unpack(c))end
Advertisement
Add Comment
Please, Sign In to add comment