Chocobot

CookieSystem v1

Jan 17th, 2012
860
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.89 KB | None | 0 0
  1. --Get the new updated version here:
  2. -- http://pastebin.com/J9DAzTKf
  3.  
  4. function createfolders()
  5. fs.makeDir("/CookieSystem")
  6. fs.makeDir("/CookieSystem/CS-System")
  7. fs.makeDir("/CookieSystem/DB")
  8. fs.makeDir("/CookieSystem/DB/DBlog")
  9. fs.makeDir("/CookieSystem/DB/DBlevels")
  10. fs.makeDir("/CookieSystem/DB/DBlevels/uselevel")
  11. fs.makeDir("/CookieSystem/DB/DBlevels/editlevel")
  12. end
  13.  
  14. function createadminaccount()
  15. file = io.open("CookieSystem/DB/DBlog/admin", "w")
  16. file:write("admin\n4")
  17. file:close()
  18. end
  19.  
  20. function createlevelfiles()
  21. file = io.open("CookieSystem/DB/DBlevels/editlevel/1", "w")
  22. file:close()
  23. file = io.open("CookieSystem/DB/DBlevels/editlevel/2", "w")
  24. file:close()
  25. file = io.open("CookieSystem/DB/DBlevels/editlevel/3", "w")
  26. file:close()
  27. file = io.open("CookieSystem/DB/DBlevels/uselevel/1", "w")
  28. file:write([[/CookieSystem/changepass
  29. /rom/programs/id
  30. /rom/programs/label
  31. /rom/programs/reboot
  32. /rom/programs/shutdown
  33. /rom/programs/worm
  34.  
  35. ]])
  36. file:close()
  37. file = io.open("CookieSystem/DB/DBlevels/uselevel/2", "w")
  38. file:write([[/CookieSystem/create
  39. ]])
  40. file:close()
  41. file = io.open("CookieSystem/DB/DBlevels/uselevel/3", "w")
  42. file:write([[/CookieSystem/delete
  43. /CookieSystem/setlvl
  44. ]])
  45. file:close()
  46. end
  47.  
  48. function createlogin()
  49. file = io.open("CookieSystem/login", "w")
  50. file:write([[term.clear()
  51. term.setCursorPos(10,5)
  52. write("==============================")
  53. term.setCursorPos(10,14)
  54. write("==============================")
  55. for n=6,13 do
  56. term.setCursorPos(10,n)
  57. write("|")
  58. term.setCursorPos(39,n)
  59. write("|")
  60. end
  61. term.setCursorPos(22,7)
  62. write("LOGIN")
  63. term.setCursorPos(15,9)
  64. write("Name:")
  65. term.setCursorPos(15,11)
  66. write("Pass:")
  67.  
  68. term.setCursorPos(21,9)
  69. curname = read()
  70. term.setCursorPos(21,11)
  71. pass = read("*")
  72.  
  73. corlogin = false
  74.  
  75. DB = io.open("/CookieSystem/DB/DBlog/" ..curname)
  76. if DB
  77. then
  78. corpass = DB:read()
  79. DB:close()
  80. if pass == corpass
  81. then
  82. corlogin = true
  83. end
  84. end
  85.  
  86. if corlogin == false
  87. then
  88. term.setCursorPos(18,13)
  89. write("Login denied")
  90. sleep(2)
  91. os.shutdown()
  92. end
  93. ]])
  94. file:close()
  95. end
  96.  
  97. function createcreate()
  98. file = io.open("/CookieSystem/create", "w")
  99. file:write([[term.clear()
  100. term.setCursorPos(18,3)
  101. print("Account Creation")
  102.  
  103. term.setCursorPos(10,8)
  104. write("Name: ")
  105. term.setCursorPos(10,10)
  106. write("Password: ")
  107. term.setCursorPos(20,8)
  108. local newname = read()
  109. term.setCursorPos(20,10)
  110. local newpass = read()
  111.  
  112. term.setCursorPos(5,12)
  113.  
  114. DB = io.open("/CookieSystem/DB/DBlog/"..newname, "r")
  115. if DB
  116. then
  117. DB:close()
  118. print("Username already exists")
  119. else
  120. DB = io.open("/CookieSystem/DB/DBlog/"..newname, "w")
  121. DB:write(newpass.."\n"..1)
  122. DB:close()
  123. print("New account created")
  124. end ]])
  125. file:close()
  126. end
  127.  
  128. function createdelete()
  129. file = io.open("/CookieSystem/delete", "w")
  130. file:write([[term.clear()
  131. term.setCursorPos(20,3)
  132. print("Account Deletion")
  133. term.setCursorPos(5,6)
  134. print("Which account do you want to delete?")
  135. term.setCursorPos(10,8)
  136. local delname = read()
  137. term.setCursorPos(5,10)
  138.  
  139. if delname ~= curname and delname ~= "admin" then
  140. db = io.open("/CookieSystem/DB/DBlog/"..delname,"r" )
  141. if db
  142. then
  143. db:close()
  144. shell.run("rm", "/CookieSystem/DB/DBlog/"..delname)
  145. print("Account deleted")
  146. else
  147. print("Account doesn't exist.")
  148. end
  149. end
  150.  
  151. sleep(1)]])
  152. file:close()
  153. end
  154.  
  155. function createsetlvl()
  156. file = io.open("/CookieSystem/setlvl", "w")
  157. file:write([[term.clear()
  158. term.setCursorPos(17,4)
  159. print("Set Clearance level")
  160. term.setCursorPos(5,6)
  161. print("Who's level do you want to change?")
  162. term.setCursorPos(10,8)
  163. local clname = read()
  164. term.setCursorPos(5,10)
  165. print("What do you want to set the level to?")
  166. term.setCursorPos(10,12)
  167. local newlevel = read()
  168. newlevel = tonumber(newlevel)
  169. term.setCursorPos(5,14)
  170. sleep(1)
  171. DB = io.open("/CookieSystem/DB/DBlog/"..clname, "r")
  172. if DB
  173. then
  174. local tarpass = DB:read()
  175. local tarlevel = DB:read()
  176. tarlevel = tonumber(tarlevel)
  177. DB:close()
  178. if curlevel > tarlevel
  179. then
  180. if curlevel > newlevel
  181. then
  182. DB = io.open("/CookieSystem/DB/DBlog/"..clname, "w")
  183. DB:write(tarpass.."\n"..newlevel)
  184. DB:close()
  185. print(clname.."'s level changed to "..newlevel)
  186. else
  187. print("The desired level must be lower than your own")
  188. end
  189. else
  190. print("Target's level is too high to be changed")
  191. end
  192. else
  193. print("Name not found")
  194. end
  195.  
  196. sleep(1) ]])
  197. file:close()
  198. end
  199.  
  200. function createchangepass()
  201.  
  202. file = io.open("/CookieSystem/changepass", "w")
  203. file:write([[term.clear()
  204. term.setCursorPos(18,3)
  205. print("Change Password")
  206. term.setCursorPos(5,5)
  207. print("Do you want to change your password?")
  208. term.setCursorPos(10,7)
  209. local answer = read()
  210. if answer == "yes"
  211. then
  212. term.setCursorPos(5,9)
  213. print("Give your current password")
  214. term.setCursorPos(10,11)
  215. local passtry = read()
  216. if passtry == curpass
  217. then
  218. term.setCursorPos(5,13)
  219. print("What do you want your new password to be?")
  220. term.setCursorPos(10,15)
  221. local newpass = read()
  222. DB = io.open("/CookieSystem/DB/DBlog/"..curname, "w")
  223. DB:write(newpass.."\n"..curlevel)
  224. DB:close()
  225. curpass = newpass
  226. term.setCursorPos(5,17)
  227. print("New password set")
  228. else
  229. term.setCursorPos(5,13)
  230. print("Password incorrect")
  231. end
  232. end
  233. sleep(1)
  234. ]])
  235. file:close()
  236. end
  237.  
  238. function createinterface()
  239.  
  240. file = io.open("/CookieSystem/CS-System/interface", "w")
  241. file:write([[
  242. function ini()
  243. path = "/"
  244. curselx = 1
  245. cursely = 1
  246. preselx = 1
  247. presely = 1
  248. curselthing = ""
  249. cmdln = ""
  250. curtabloc = 1
  251. curpage = 1
  252. infoline = ""
  253. curselminuselvl = 5
  254. curselmineditlvl = 5
  255. maintenance = false
  256.  
  257. DBlog = io.open("/CookieSystem/DB/DBlog/"..curname, "r")
  258. curpass = DBlog:read()
  259. curlevel = DBlog:read()
  260. curlevel = tonumber(curlevel)
  261. DBlog:close()
  262. end
  263.  
  264.  
  265.  
  266.  
  267. function bordersui()
  268. for n=2, 15 do
  269. if n == 2
  270. then
  271. term.setCursorPos(1,1)
  272. write("===================CookieSystem===================")
  273. elseif n == 15
  274. then
  275. write("==================================================")
  276. else
  277. term.setCursorPos(1,n-1)
  278. write("||||||||||||||||||||||||||||||||||||||||||||||||||")
  279. end
  280. end
  281. for n=3, 14 do
  282. for i=2,49 do
  283. term.setCursorPos(i,n)
  284. write(" ")
  285. end
  286. end
  287. end
  288.  
  289.  
  290. function topui()
  291. term.setCursorPos(1,1)
  292. term.clearLine()
  293. write(curname.." | "..curlevel)
  294. term.setCursorPos(40,1)
  295. time = textutils.formatTime(os.time(), true)
  296. write("V1.0 "..time)
  297. end
  298.  
  299.  
  300. function bottomui()
  301. term.setCursorPos(1,18)
  302. term.clearLine()
  303. showpath = path
  304. if string.len(path) > 18
  305. then showpath = string.sub(path, -18)
  306. end
  307. write("Path: "..showpath)
  308. term.setCursorPos(25,18)
  309. write(" Sel: "..curselthing)
  310. term.setCursorPos(1,17)
  311. term.clearLine()
  312. write("Info: "..infoline)
  313. term.setCursorPos(1,16)
  314. term.clearLine()
  315. end
  316.  
  317. function basescreen()
  318. term.clear()
  319. topui()
  320. bordersui()
  321. bottomui()
  322. end
  323.  
  324. function getlist(path)
  325. fullist = {}
  326. fulllist = fs.list(path)
  327. folderlist = {}
  328. programlist = {}
  329. local nl = 0
  330. local il = 0
  331. local jl = 0
  332. while true do
  333. nl = nl + 1
  334. if fulllist[nl] == nil then break end
  335. if fs.isDir(path..fulllist[nl])
  336. then
  337. il = il + 1
  338. folderlist[il] = fulllist[nl]
  339. else
  340. jl = jl + 1
  341. programlist[jl] = fulllist[nl]
  342. end
  343. end
  344. end
  345.  
  346. function getdisplayname(thingy)
  347. displayname = thingy
  348. displaylength = string.len(displayname)
  349. if displaylength < 8
  350. then firsteightchar = string.sub(displayname,1,displaylength)
  351. else firsteightchar = string.sub(displayname,1,8)
  352. end
  353.  
  354. if displaylength > 8
  355. then secondeightchar = string.sub(displayname, 9, 16)
  356. else secondeightchar = ""
  357. end
  358. if fs.isDir(path..thingy) then
  359. displaylineone = "=folder="
  360. else
  361. if string.sub(displayname,-4) == ".txt"
  362. then displaylineone = "==text=="
  363. else displaylineone = "=progrm="
  364. end
  365. end
  366. displaylinetwo = firsteightchar
  367. displaylinethree = secondeightchar
  368. end
  369.  
  370. function getcoordspot(n)
  371. x = n%5
  372. if x == 0 then x = 5 end
  373. y = n/5 - x/5 +1
  374.  
  375. if x == 1 then prx = 1
  376. elseif x == 2 then prx = 11
  377. elseif x == 3 then prx = 21
  378. elseif x == 4 then prx = 31
  379. elseif x == 5 then prx = 41
  380. end
  381. pry = (y*3)
  382. end
  383.  
  384. function printtileborders(prx,pry)
  385. term.setCursorPos(prx,pry)
  386. write("|")
  387. term.setCursorPos(prx,pry+1)
  388. write("|")
  389. term.setCursorPos(prx,pry+2)
  390. write("|")
  391. term.setCursorPos(prx+9,pry)
  392. write("|")
  393. term.setCursorPos(prx+9,pry+1)
  394. write("|")
  395. term.setCursorPos(prx+9,pry+2)
  396. write("|")
  397. end
  398.  
  399. function printtilebordersselected(prx,pry)
  400. term.setCursorPos(prx,pry)
  401. write("*")
  402. term.setCursorPos(prx,pry+1)
  403. write("*")
  404. term.setCursorPos(prx,pry+2)
  405. write("*")
  406. term.setCursorPos(prx+9,pry)
  407. write("*")
  408. term.setCursorPos(prx+9,pry+1)
  409. write("*")
  410. term.setCursorPos(prx+9,pry+2)
  411. write("*")
  412. end
  413.  
  414. function printtile(prx,pry)
  415. term.setCursorPos(prx+1, pry)
  416. write(displaylineone)
  417. term.setCursorPos(prx+1, pry+1)
  418. write(displaylinetwo)
  419. if displaylinethree ~= nil
  420. then
  421. term.setCursorPos(prx+1, pry+2)
  422. write(displaylinethree)
  423. end
  424. end
  425.  
  426. function showstuff()
  427. getlist(path)
  428. maxpage = (math.floor(#fulllist/20) + 1)
  429. i=0
  430. for n=((curpage*20)-20+1), (curpage*20) do
  431. i = i + 1
  432. if fulllist[n] == nil then break end
  433. getdisplayname(fulllist[n])
  434. getcoordspot(i)
  435. printtile(prx,pry)
  436. end
  437. for n=1, 20 do
  438. getcoordspot(n)
  439. printtileborders(prx,pry)
  440. end
  441. end
  442.  
  443. function pagedown()
  444. if curpage < maxpage
  445. then
  446. curpage = curpage + 1
  447. fullrefresh()
  448. end
  449. end
  450.  
  451. function pageup()
  452. if curpage > 1
  453. then
  454. curpage = curpage - 1
  455. fullrefresh()
  456. end
  457. end
  458.  
  459. function movecursor(direction)
  460. if direction == "left"
  461. then
  462. if curselx > 1
  463. then
  464. preselx = curselx
  465. curselx = curselx - 1
  466. end
  467. end
  468. if direction == "right"
  469. then
  470. if curselx < 5
  471. then
  472. preselx = curselx
  473. curselx = curselx + 1
  474. end
  475. end
  476. if direction == "up"
  477. then
  478. if cursely > 1
  479. then
  480. presely = cursely
  481. cursely = cursely - 1
  482. end
  483. end
  484. if direction == "down"
  485. then
  486. if cursely < 4
  487. then
  488. presely = cursely
  489. cursely = cursely + 1
  490. end
  491. end
  492. end
  493.  
  494. function getminimumlevel()
  495. curselminuselvl = 4
  496. curselmineditlvl = 4
  497. for k=3, 1,-1 do
  498. DBU = io.open("/CookieSystem/DB/DBlevels/uselevel/"..k, "r")
  499. while true do
  500. ucheck = DBU:read()
  501. if ucheck == nil then break end
  502. if (path..curselthing) == ucheck then curselminuselvl = k end
  503. end
  504. DBU:close()
  505. DBE = io.open("/CookieSystem/DB/DBlevels/editlevel/"..k, "r")
  506. while true do
  507. echeck = DBE:read()
  508. if echeck == nil then break end
  509. if (path..curselthing) == echeck then curselmineditlvl = k end
  510. end
  511. DBE:close()
  512. end
  513. end
  514.  
  515. function select()
  516. if curselthing ~= "empty spot" then
  517. if fs.isDir(path..curselthing)
  518. then
  519. path = (path..curselthing.."/")
  520. else
  521. getminimumlevel()
  522. if curselminuselvl <= curlevel
  523. then
  524. if string.sub(curselthing, -4) == ".txt"
  525. then shell.run("edit", path..curselthing)
  526. else shell.run(path..curselthing)
  527. end
  528. sleep(1)
  529. else
  530. infoline = "Level too low"
  531. end
  532. end
  533. curpage = 1
  534. fullrefresh()
  535. end
  536. end
  537.  
  538. function back()
  539. if path ~= "/"
  540. then
  541. pathhelp = path
  542. pathhelpn = 1
  543. pathhelpnrawr = 0
  544. pathhelpnpre = 0
  545. while true do
  546. pathhelpnrawr = pathhelpnpre
  547. pathhelpnpre = pathhelpn
  548. pathhelpn = pathhelpn - pathhelpnrawr
  549. if pathhelp == "" or pathhelp == nil then break end
  550. pathhelp = string.sub(pathhelp, pathhelpn+1)
  551. if pathhelp == "" or pathhelp == nil then break end
  552. pathhelpn = string.find(pathhelp, "/")
  553. end
  554. path = string.sub(path,1,pathhelpnrawr)
  555. end
  556. curpage = 1
  557. fullrefresh()
  558. end
  559.  
  560. function tabkey()
  561. tabmax = 2
  562. if curtabloc == 1 then newtabloc = (curtabloc + 1) end
  563. if curtabloc == tabmax then newtabloc = 1 end
  564. curtabloc = newtabloc
  565. end
  566.  
  567. function home()
  568. curpage = 1
  569. path = "/"
  570. curselx = 1
  571. cursely = 1
  572. basescreen()
  573. showstuff()
  574. getcurselthing()
  575. end
  576.  
  577. function exdelete()
  578. if cursel ~= "empty spot"
  579. then
  580. getminimumlevel()
  581. if curselmineditlvl <= curlevel
  582. then
  583. shell.run("rm", path..curselthing)
  584. fullrefresh()
  585. else
  586. infoline = "Level too low"
  587. end
  588. else
  589. infoline = "Select something first"
  590. end
  591. end
  592.  
  593. function interfacebrowser()
  594. event, argument = os.pullEvent()
  595. if event == "key" and argument == 203 then movecursor("left") end
  596. if event == "key" and argument == 205 then movecursor("right") end
  597. if event == "key" and argument == 200 then movecursor("up") end
  598. if event == "key" and argument == 208 then movecursor("down") end
  599. if event == "key" and argument == 28 then select() end
  600. if event == "key" and argument == 14 then back() end
  601. if event == "key" and argument == 15 then tabkey() end
  602. if event == "key" and argument == 209 then pagedown() end
  603. if event == "key" and argument == 201 then pageup() end
  604. if event == "key" and argument == 211 then exdelete() end
  605. if event == "key" and argument == 199 then home() end
  606. end
  607.  
  608. function getcurselthing()
  609. local ns = ((cursely-1)*5 + curselx)+((curpage-1)*20)
  610. if ns <= #fulllist
  611. then
  612. curselthing = fulllist[ns]
  613. else
  614. curselthing = "empty spot"
  615. end
  616. end
  617.  
  618. function exedit()
  619. if curselthing ~= "empty spot"
  620. then
  621. getminimumlevel()
  622. if curselmineditlvl <= curlevel
  623. then
  624. shell.run("edit", path..curselthing)
  625. fullrefresh()
  626. else
  627. infoline = "Level too low"
  628. end
  629. else
  630. infoline = "Select something first"
  631. end
  632. end
  633.  
  634. function exnew()
  635. if string.sub(cmdln, 5, 11) == "program"
  636. then
  637. newprogramname = string.sub(cmdln, 13)
  638. if newprogramname ~= nil and newprogramname ~= ""
  639. then
  640. if fs.exists(path..newprogramname) == false
  641. then
  642. shell.run("edit", path..newprogramname)
  643. fullrefresh()
  644. else
  645. infoline = "That name already exists"
  646. end
  647. else
  648. infoline = "Command is New <folder/program> <name>"
  649. end
  650. elseif string.sub(cmdln, 5, 10) == "folder"
  651. then
  652. newfoldername = string.sub(cmdln, 12)
  653. if newfoldername ~= nil and newfoldername ~= ""
  654. then
  655. if fs.exists(path..newfoldername) == false
  656. then
  657. fs.makeDir(path..newfoldername)
  658. fullrefresh()
  659. else
  660. infoline = "That name already exists"
  661. end
  662. else
  663. infoline = "Command is New <folder/program> <name>"
  664. end
  665. else
  666. infoline = "Command is New <folder/program> <name>"
  667. end
  668. end
  669.  
  670. function exshutdown()
  671. infoline = "Shutting down computer..."
  672. bottomui()
  673. sleep(2)
  674. os.shutdown()
  675. end
  676.  
  677. function exhelp()
  678. local helprawr = string.sub(cmdln,6)
  679. term.clear()
  680. term.setCursorPos(1,1)
  681. shell.run("help", helprawr)
  682. term.setCursorPos(5,18)
  683. write("Press any key to continue")
  684. while true do
  685. event = os.pullEvent()
  686. if event == "key" then break end
  687. end
  688. fullrefresh()
  689. end
  690.  
  691. function excopy()
  692. if curselthing ~= "empty spot"
  693. then
  694. curcopysel = (path..curselthing)
  695. infoline = ("Copying "..curselthing)
  696. else
  697. infoline = "Select something first."
  698. end
  699. end
  700.  
  701. function expaste()
  702. shell.run("cp", curcopysel, path)
  703. fullrefresh()
  704. end
  705.  
  706. function exsetlevel()
  707. local editoruse = "rawr"
  708. local setnewlevel = 0
  709. if string.sub(cmdln,10,12) == "use" then
  710. editoruse = "use"
  711. if string.sub(cmdln, 14,14) == "1" then setnewlevel = "1"
  712. elseif string.sub(cmdln, 14,14) == "2" then setnewlevel = "2"
  713. elseif string.sub(cmdln, 14,14) == "3" then setnewlevel = "3"
  714. else infoline = "Command is setlevel use/edit 1/2/3"
  715. end
  716. else infoline = "Command is setlevel use/edit 1/2/3"
  717. end
  718. if string.sub(cmdln,10,13) == "edit" then
  719. editoruse = "edit"
  720. if string.sub(cmdln, 15,15) == "1" then setnewlevel = "1"
  721. elseif string.sub(cmdln, 15,15) == "2" then setnewlevel = "2"
  722. elseif string.sub(cmdln, 15,15) == "3" then setnewlevel = "3"
  723. else infoline = "Command is setlevel use/edit 1/2/3"
  724. end
  725. else infoline = "Command is setlevel use/edit 1/2/3"
  726. end
  727.  
  728. if setnewlevel ~= 0 then
  729. local curselthingmem = curselthing
  730. local pathmem = path
  731. path = ("/cookiesystem/DB/DBlevels/"..editoruse.."level/")
  732. curselthing = setnewlevel
  733.  
  734. getminimumlevel()
  735. if curselmineditlvl <= curlevel
  736. then
  737. file = io.open(path..curselthing, "a")
  738. file:write("\n"..pathmem..curselthingmem)
  739. file:close()
  740. else
  741. infoline = "Your level is too low"
  742. end
  743. path = pathmem
  744. curselthing = curselthingmem
  745. end
  746. end
  747.  
  748. function exrename()
  749. if curselthing ~= "empty spot"
  750. then
  751. local newname = string.sub(cmdln, 8)
  752. shell.run("move", path..curselthing, path..newname)
  753. fullrefresh()
  754. else
  755. infoline = "select something first"
  756. end
  757. end
  758.  
  759. function executeline()
  760. if cmdln == "edit" then exedit() end
  761. if string.sub(cmdln,1,3) == "new" then exnew() end
  762. if cmdln == "delete" then exdelete() end
  763. if cmdln == "shutdown" then exshutdown() end
  764. if string.sub(cmdln,1,4) == "help" then exhelp() end
  765. if cmdln == "copy" then excopy() end
  766. if cmdln == "paste" then expaste() end
  767. if string.sub(cmdln,1,8) == "setlevel" then exsetlevel() end
  768. if cmdln == "maintenance" and curname == "admin" then maintenance = true infoline = "Maintenance mode activated, hold ctrl+T" end
  769. if string.sub(cmdln,1,6) == "rename" then exrename() end
  770. cmdln = ""
  771. end
  772.  
  773. function commandline()
  774. term.setCursorPos(1,16)
  775. write(">")
  776. while true do
  777. event, argument = os.pullEvent()
  778. if event == "key" and argument == 15 then tabkey() break end
  779. if event == "key" and argument == 28 then executeline() break end
  780. if event == "key" and argument == 14
  781. then
  782. if string.len(cmdln) > 0 then
  783. cmdln = string.sub(cmdln, 1, (string.len(cmdln)-1))
  784. term.setCursorPos(1,16)
  785. write(">"..cmdln.." ")
  786. end end
  787. if event == "char"
  788. then
  789. term.setCursorPos(1,16)
  790. cmdln = (cmdln..argument)
  791. write(">"..cmdln)
  792. end
  793. end
  794. term.setCursorPos(1,16)
  795. write(" ")
  796. end
  797.  
  798.  
  799. function interfaceupdate()
  800. topui()
  801. bottomui()
  802.  
  803. if preselx == 1 then prpsx = 1
  804. elseif preselx == 2 then prpsx = 11
  805. elseif preselx == 3 then prpsx = 21
  806. elseif preselx == 4 then prpsx = 31
  807. elseif preselx == 5 then prpsx = 41
  808. end
  809. prpsy = (presely*3)
  810. printtileborders(prpsx,prpsy)
  811.  
  812. if curselx == 1 then prselx = 1
  813. elseif curselx == 2 then prselx = 11
  814. elseif curselx == 3 then prselx = 21
  815. elseif curselx == 4 then prselx = 31
  816. elseif curselx == 5 then prselx = 41
  817. end
  818. prsely = (cursely*3)
  819. printtilebordersselected(prselx,prsely)
  820.  
  821. preselx = curselx
  822. presely = cursely
  823. end
  824.  
  825. function fullrefresh()
  826. curselx = 1
  827. cursely = 1
  828. basescreen()
  829. showstuff()
  830. getcurselthing()
  831. end
  832.  
  833.  
  834.  
  835. ini()
  836. basescreen()
  837. showstuff()
  838. getcurselthing()
  839.  
  840. while true do
  841. interfaceupdate()
  842. if curtabloc == 1
  843. then
  844. interfacebrowser()
  845. getcurselthing()
  846. end
  847. if curtabloc == 2
  848. then
  849. commandline()
  850. end
  851. end
  852.  
  853. ]])
  854. file:close()
  855. end
  856.  
  857. function createhelpfiles()
  858.  
  859. file = io.open("/CookieSystem/CS-Help", "w")
  860. file:write([[term.clear()
  861. term.setCursorPos(1,1)
  862. print("===================CookieSystem==================")
  863. print("Press tab to change between tab modes.If there is")
  864. print("a > before the commandline you're in cmdln mode. ")
  865. print("In navigation mode you can move trough the field ")
  866. print("with the arrow keys, if there are more than 20 ")
  867. print("items you can move trough pages with pageup/down ")
  868. print("Use backspace to move up a level and enter to go ")
  869. print("in a folder or execute a program. Press home to ")
  870. print("return to the main page and delete to delete. ")
  871. print("In cmdln mode you can use the following commands:")
  872. print("shutdown, help (same as normal), copy, paste, ")
  873. print("delete, rename, setlevel and maintenance (admin ")
  874. print("only). Commands like delete and copy apply to the")
  875. print("currently selected program . ")
  876. print("Add .txt to the end of a program to make a text ")
  877. print("file. These are opened in edit mode when executed")
  878. print("")
  879. term.setCursorPos(5,18)
  880. write("Press any key to continue")
  881. while true do
  882. event = os.pullEvent()
  883. if event == "key" then break end
  884. end
  885. term.clear()
  886. term.setCursorPos(1,1)
  887. ]])
  888. file:close()
  889.  
  890.  
  891. file = io.open("/CookieSystem/CS-Help levels", "w")
  892. file:write([[term.clear()
  893. term.setCursorPos(1,1)
  894. print("===================CookieSystem==================")
  895. print("If the computer is used by multiple players then ")
  896. print("you might want to set up different accounts and ")
  897. print("access levels. The current account level can be ")
  898. print("seen in the top left corner. To set a level you ")
  899. print("must be able to edit the correct file in the DB ")
  900. print("folder. Open it and add the path and name of the ")
  901. print("program or go to the program itself and use the ")
  902. print("command setlevel use/edit 1/2/3 ")
  903. print("To use the command your level needs to be able to")
  904. print("edit the right files. So if you want to set a ")
  905. print("programs use level to 2, you need to be able to ")
  906. print("edit the file CookieSystem/DB/DBlevels/uselevel/2")
  907. print("")
  908. print("The level system treats program and text files ")
  909. print("in the same way, except that you can't execute ")
  910. print("text files like programs. ")
  911. term.setCursorPos(5,18)
  912. write("Press any key to continue")
  913. while true do
  914. event = os.pullEvent()
  915. if event == "key" then break end
  916. end
  917. term.clear()
  918. term.setCursorPos(1,1)
  919. ]])
  920. file:close()
  921. end
  922.  
  923. function createstartup()
  924. file = io.open("startup", "w")
  925. file:write([[while true do
  926. shell.run("/CookieSystem/login")
  927. if corlogin then break end
  928. end
  929. while true do
  930. shell.run("/CookieSystem/CS-System/interface")
  931. if maintenance then break end
  932. end
  933. term.clear()
  934. term.setCursorPos(1,1)]])
  935. file:close()
  936. end
  937.  
  938. function install()
  939. createfolders()
  940. createlevelfiles()
  941. createadminaccount()
  942. createlogin()
  943. createcreate()
  944. createdelete()
  945. createsetlvl()
  946. createchangepass()
  947. createinterface()
  948. createhelpfiles()
  949. createstartup()
  950. end
  951.  
  952. function topthing()
  953. term.clear()
  954. term.setCursorPos(13,2)
  955. write("========================")
  956. term.setCursorPos(13,3)
  957. write("|CookieSystem Installer|")
  958. term.setCursorPos(13,4)
  959. write("========================")
  960. end
  961.  
  962. topthing()
  963. term.setCursorPos(1,5)
  964. print("Do you want to install CS V1 on your computer?")
  965. answer = read()
  966. if answer == "yes"
  967. then
  968. install()
  969. else
  970. term.setCursorPos(15,8)
  971. print("Installation aborted.")
  972. end
Advertisement
Add Comment
Please, Sign In to add comment