Advertisement
cyber_Ahn

caw_os.3.0

Apr 1st, 2015
954
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.32 KB | None | 0 0
  1. --last update 09.12.2016
  2. --SETTINGS--
  3. --Password for Guest = 0000
  4. -- MONITOR was CHANGED in monitor.cfg in line 1
  5. --optimal monitor size 5*4
  6.  
  7. -- CawOS install this programs automatically:
  8. -- OS_API  by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  9. -- Mail Client by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  10. -- NetChat  by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  11. -- Download Manager  by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  12.  
  13. -- Programs in Download Manager:
  14. -- NpaintPro by NITROGENFINGERS  http://pastebin.com/pzWSRqNF user: http://pastebin.com/u/nitrogenfingers
  15. -- Nitrosoft Games by NITROGENFINGERS  http://pastebin.com/KZsuv1pc user: http://pastebin.com/u/nitrogenfingers
  16. -- File_manager by  A GUEST ON FEB 26TH, 2013 http://pastebin.com/CTrCeDBt
  17. -- Big Reactor Control by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  18. -- Big Reactor Status by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  19. -- Bundled Cable Remote (for cable server) by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  20. -- LanteaCraft Gate Control (alpha) by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  21. -- Train Control (alpha) by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  22. -- Command Remote (alpha) by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  23. -- Radio Prog (openFM) by cyber_Ahn http://pastebin.com/u/cyber_Ahn
  24.  
  25.  
  26. --monitor file chek---
  27. local monitor_number = "monitor_1"
  28. local PeripheralsPlusPlus = false
  29. local found = fs.exists("config/monitor.cfg")
  30. if found == false then
  31. print("Input Monitor Number:")
  32. input = read()
  33. local file = fs.open("config/monitor.cfg","w")
  34. file.writeLine(input)
  35. file.writeLine("peripheralspluplus_off")
  36. file.writeLine("space")
  37. file.writeLine("clear")
  38. file.close()
  39. end
  40.  
  41. --monitor set--
  42. file = fs.open("config/monitor.cfg","r")
  43. local fileData = {}
  44. local line = file.readLine()
  45. repeat
  46. table.insert(fileData,line)
  47. line = file.readLine()
  48. until line == nil
  49. file.close()
  50. monitor_number = fileData[1]
  51. PeripheralsPlusPlus = fileData[2]
  52. wpName = fileData[4]
  53. if(PeripheralsPlusPlus == "peripheralspluplus_on") then
  54. PeripheralsPlusPlus = true
  55. end
  56. local mon = peripheral.wrap(monitor_number)
  57. local programs = {}
  58. local user = "guest"
  59. local start_a = 0
  60.  
  61. --load installed programs--
  62. function getPrograms()
  63. fDir = shell.programs()
  64. programs = {}
  65. for i=1,#fDir do
  66. if(fDir[i] ~= "worm") and (fDir[i] ~= "type") and (fDir[i] ~= "time") and (fDir[i] ~= "startup") and (fDir[i] ~= "shutdown") and (fDir[i] ~= "shell") and (fDir[i] ~= "rename") and (fDir[i] ~= "redset") and (fDir[i] ~= "redpulse") and (fDir[i] ~= "redprobe") and (fDir[i] ~= "reboot") and (fDir[i] ~= "programs") and (fDir[i] ~= "pastebin") and (fDir[i] ~= "paint") and (fDir[i] ~= "move") and (fDir[i] ~= "monitor") and (fDir[i] ~= "mkdir") and (fDir[i] ~= "lua") and (fDir[i] ~= "list") and (fDir[i] ~= "label") and (fDir[i] ~= "id") and (fDir[i] ~= "help") and (fDir[i] ~= "hello") and (fDir[i] ~= "gps") and (fDir[i] ~= "exit") and (fDir[i] ~= "eject") and (fDir[i] ~= "edit") and (fDir[i] ~= "drive") and (fDir[i] ~= "dj") and (fDir[i] ~= "copy") and (fDir[i] ~= "clear") and (fDir[i] ~= "caAPI") and (fDir[i] ~= "apis") and (fDir[i] ~= "delete") and (fDir[i] ~= "cd") and (fDir[i] ~= "alias") and (fDir[i] ~= "adventure") and (fDir[i] ~= "Caw_OS") and (fDir[i] ~= "bg") and (fDir[i] ~= "fg") and (fDir[i] ~= "chat") and (fDir[i] ~= "multishell") and (fDir[i] ~= "redstone") and (fDir[i] ~= "repeat") and (fDir[i] ~= "sensor_plugin")then
  67. table.insert(programs, fDir[i])
  68. end
  69. end
  70. end
  71.  
  72. --start program--
  73. function startP(namP)
  74. if (PeripheralsPlusPlus == true) then
  75. text = "Start program "..namP
  76. caAPI.chat(text)
  77. caAPI.sound(5,1)
  78. end
  79. shell.run("monitor",monitor_number,namP)
  80. end
  81.  
  82. --menu--
  83. function menu(posx,posy)
  84. mon.setBackgroundColor(128)
  85. mon.setCursorPos(posx,posy)
  86. mon.write("          X")
  87. mon.setCursorPos(posx,(posy+1))
  88. mon.write("  Reboot   ")
  89. mon.setCursorPos(posx,(posy+2))
  90. mon.write("  Shutdown ")
  91. mon.setCursorPos(posx,(posy+3))
  92. mon.write("  Logout   ")
  93. mon.setCursorPos(posx,(posy+4))
  94. mon.write("  Uninstall")
  95. mon.setCursorPos(posx,(posy+5))
  96. mon.write("  Hardware ")
  97. mon.setCursorPos(posx,(posy+6))
  98. mon.write("  Wallpaper")
  99. mon.setCursorPos(posx,(posy+7))
  100. mon.write("  User     ")
  101. mon.setCursorPos(posx,(posy+8))
  102. mon.write("  Autostart")
  103. mon.setCursorPos(posx,(posy+9))
  104. mon.write("  Del Autos")
  105. mon.setBackgroundColor(8)
  106. ix = false
  107. while ix == false do
  108. event,side,x,y = os.pullEvent()
  109. if event == "monitor_touch" then
  110. if x > posx and x < (posx+10) and y == posy then
  111. mainmenu(user)
  112. end
  113. if x > posx and x < (posx+10) and y == (posy+1) then
  114. if (PeripheralsPlusPlus == true) then
  115. text = "Reboot PC"
  116. caAPI.chat(text)
  117. end
  118. if (PeripheralsPlusPlus == true) then
  119. caAPI.lamp(8)
  120. caAPI.sound(5,1)
  121. sleep(1)
  122. caAPI.lamp(32)
  123. caAPI.sound(6,1)
  124. sleep(1)
  125. caAPI.lamp(8)
  126. caAPI.sound(5,1)
  127. sleep(1)
  128. caAPI.lamp(1)
  129. caAPI.sound(6,1)
  130. end
  131. shell.run("clear")
  132. shell.run("reboot")
  133. end
  134. if x > posx and x < (posx+10) and y == (posy+2) then
  135. shell.run("clear")
  136. mon.setBackgroundColor(colors.black)
  137. shell.run("clear")
  138. mon.setBackgroundColor(colors.black)
  139. shell.run("clear")
  140. if (PeripheralsPlusPlus == true) then
  141. text = "Shutdown PC"
  142. caAPI.chat(text)
  143. end
  144. if (PeripheralsPlusPlus == true) then
  145. caAPI.lamp(8)
  146. caAPI.sound(5,1)
  147. sleep(1)
  148. caAPI.lamp(32)
  149. caAPI.sound(6,1)
  150. sleep(1)
  151. caAPI.lamp(8)
  152. caAPI.sound(5,1)
  153. sleep(1)
  154. caAPI.lamp(1)
  155. caAPI.sound(6,1)
  156. end
  157. shell.run("clear")
  158. shell.run("shutdown")
  159. end
  160. if x > posx and x < (posx+10) and y == (posy+4) then
  161. mon.setBackgroundColor(colors.black)
  162. mon.clear()
  163. if (PeripheralsPlusPlus == true) then
  164. text = "Unistall"
  165. caAPI.chat(text)
  166. end
  167. shell.run("rm","*")
  168. shell.run("shutdown")
  169. end
  170. if x > posx and x < (posx+10) and y == (posy+3) then
  171. login()
  172. end
  173. if x > posx and x < (posx+10) and y == (posy+5) then
  174. ix = true
  175. settings(1,1)
  176. end
  177. if x > posx and x < (posx+10) and y == (posy+6) then
  178. ix = true
  179. wallpaper_m((posx+11),(posy+6))
  180. end
  181. if x > posx and x < (posx+10) and y == (posy+7) then
  182. ix = true
  183. user_m((posx+11),(posy+7))
  184. end
  185. if x > posx and x < (posx+10) and y == (posy+8) then
  186. ix = true
  187. auto_s((posx+11),(posy+8))
  188. end
  189. if x > posx and x < (posx+10) and y == (posy+9) then
  190. ix = true
  191. auto_d()
  192. end
  193. end
  194. end
  195. end
  196.  
  197. --delete autostart--
  198. function auto_d()
  199. local found = fs.exists("config/autostart.cfg")
  200. if found == true then
  201. shell.run("delete config/autostart.cfg")
  202. end
  203. shell.run("reboot")
  204. end
  205.  
  206. --autostart--
  207. function auto_s(posx,posy)
  208. local found = fs.exists("config/autostart.cfg")
  209. if found == true then
  210. shell.run("delete config/autostart.cfg")
  211. end
  212. mon.setBackgroundColor(128)
  213. mon.setCursorPos(posx,posy)
  214. mon.write("Enter Username:")
  215. user_n = read()
  216. mon.setCursorPos(posx,(posy+1))
  217. mon.write("Enter Programname:")
  218. program_s = read()
  219. local file = fs.open("config/autostart.cfg","w")
  220. file.writeLine(user_n)
  221. file.writeLine(program_s)
  222. file.close()
  223. shell.run("reboot")
  224. end
  225.  
  226. --user menu--
  227. function user_m(posx,posy)
  228. mon.setBackgroundColor(128)
  229. mon.setCursorPos(posx,posy)
  230. mon.write("            X")
  231. mon.setCursorPos(posx,(posy+1))
  232. mon.write("  Delete User")
  233. mon.setCursorPos(posx,(posy+2))
  234. mon.write("  Change PW  ")
  235. iy = false
  236. while iy == false do
  237. event,side,x,y = os.pullEvent()
  238. if event == "monitor_touch" then
  239. if x > posx and x < (posx+10) and y == posy then
  240. iy = true
  241. mainmenu(user)
  242. end
  243. if x > posx and x < (posx+10) and y == (posy+1) then
  244. iy = true
  245. deleteU(2,12)
  246. end
  247. if x > posx and x < (posx+10) and y == (posy+2) then
  248. iy = true
  249. changePW(2,12)
  250. end
  251. end
  252. end
  253. end
  254.  
  255. --delete user menu--
  256. function deleteU(posx,posy)
  257. mon.setBackgroundColor(128)
  258. mon.setCursorPos(posx,posy)
  259. mon.write("Delete User:                                   X")
  260. mon.setCursorPos(posx,(posy+1))
  261. mon.write("                                                ")
  262. mon.setCursorPos(posx,(posy+2))
  263. mon.write("                                                ")
  264. mon.setCursorPos(posx,(posy+3))
  265. mon.write("                                                ")
  266. mon.setCursorPos(posx,(posy+4))
  267. mon.write("                                                ")
  268. mon.setCursorPos(posx,(posy+5))
  269. mon.write("                                                ")
  270. mon.setCursorPos(posx,(posy+6))
  271. mon.write("                                                ")
  272. mon.setCursorPos(posx,(posy+7))
  273. mon.write("                                                ")
  274. mon.setCursorPos(posx,(posy+8))
  275. mon.write("                                                ")
  276. file = fs.open("database/user.db","r")
  277. local fileData = {}
  278. local line = file.readLine()
  279. repeat
  280. table.insert(fileData,line)
  281. line = file.readLine()
  282. until line == nil
  283. file.close()
  284. posyX = posy +2
  285. for iud=1,(#fileData) do
  286. dataU = caAPI.split(fileData[iud],"#")
  287. mon.setCursorPos(3,posyX)
  288. mon.write(dataU[1])
  289. posyX = posyX + 1
  290. end
  291. iy = false
  292. while iy == false do
  293. event,side,x,y = os.pullEvent()
  294. if event == "monitor_touch" then
  295. if x > posx and x < (posx+10) and y == posy then
  296. iy = true
  297. mainmenu(user)
  298. end
  299. if x > posx and x < (posx+10) and y == (posy+2) then
  300. iy = true
  301. dleU(1)
  302. mainmenu(user)
  303. end
  304. if x > posx and x < (posx+10) and y == (posy+3) then
  305. iy = true
  306. dleU(2)
  307. mainmenu(user)
  308. end
  309. if x > posx and x < (posx+10) and y == (posy+4) then
  310. iy = true
  311. dleU(3)
  312. mainmenu(user)
  313. end
  314. if x > posx and x < (posx+10) and y == (posy+5) then
  315. iy = true
  316. dleU(4)
  317. mainmenu(user)
  318. end
  319. if x > posx and x < (posx+10) and y == (posy+6) then
  320. iy = true
  321. dleU(5)
  322. mainmenu(user)
  323. end
  324. if x > posx and x < (posx+10) and y == (posy+7) then
  325. iy = true
  326. dleU(6)
  327. mainmenu(user)
  328. end
  329. end
  330. end
  331. end
  332.  
  333. --delete user
  334. function dleU(num)
  335. file = fs.open("database/user.db","r")
  336. local fileData = {}
  337. local line = file.readLine()
  338. repeat
  339. table.insert(fileData,line)
  340. line = file.readLine()
  341. until line == nil
  342. file.close()
  343. table.remove(fileData,num)
  344. local file = fs.open("database/user.db","w")
  345. for iux=1,#fileData do
  346. file.writeLine(fileData[iux])
  347. end
  348. file.close()
  349. end
  350.  
  351. --change pw menu--
  352. function changePW(posx,posy)
  353. mon.setBackgroundColor(128)
  354. mon.setCursorPos(posx,posy)
  355. mon.write("Change Password:                               X")
  356. mon.setCursorPos(posx,(posy+1))
  357. mon.write("                                                ")
  358. mon.setCursorPos(posx,(posy+2))
  359. mon.write("                                                ")
  360. mon.setCursorPos(posx,(posy+3))
  361. mon.write("                                                ")
  362. mon.setCursorPos(posx,(posy+4))
  363. mon.write("                                                ")
  364. mon.setCursorPos(posx,(posy+5))
  365. mon.write("                                                ")
  366. mon.setCursorPos(posx,(posy+6))
  367. mon.write("                                                ")
  368. mon.setCursorPos(posx,(posy+7))
  369. mon.write("                                                ")
  370. mon.setCursorPos(posx,(posy+8))
  371. mon.write("                                                ")
  372. mon.setCursorPos((posx+1),(posy+3))
  373. mon.write("Enter new password")
  374. mon.setCursorPos((posx+1),(posy+4))
  375. nwpd1 = read("*")
  376. mon.setCursorPos((posx+1),(posy+5))
  377. mon.write("Enter password again")
  378. mon.setCursorPos((posx+1),(posy+6))
  379. nwpd2 = read("*")
  380. if nwpd1 == nwpd2 then
  381. mon.setCursorPos((posx+1),(posy+6))
  382. mon.write("Password changed")
  383. sleep(5)
  384. file = fs.open("database/user.db","r")
  385. local fileData = {}
  386. local line = file.readLine()
  387. repeat
  388. table.insert(fileData,line)
  389. line = file.readLine()
  390. until line == nil
  391. file.close()
  392. for iux=1,#fileData do
  393. dataU = caAPI.split(fileData[iux],"#")
  394. if user == dataU[1] then
  395. table.remove(fileData,iux)
  396. end
  397. end
  398. local file = fs.open("database/user.db","w")
  399. for iux=1,#fileData do
  400. file.writeLine(fileData[iux])
  401. end
  402. file.writeLine(user.."#"..nwpd1)
  403. file.close()
  404. mainmenu(user)
  405. else
  406. changePW(posx,posy)
  407. end
  408. end
  409.  
  410. --wallpaper menu--
  411. function wallpaper_m(posx,posy)
  412. mon.setBackgroundColor(128)
  413. mon.setCursorPos(posx,posy)
  414. mon.write("          X")
  415. mon.setCursorPos(posx,(posy+1))
  416. mon.write("  Pig      ")
  417. mon.setCursorPos(posx,(posy+2))
  418. mon.write("  Steve    ")
  419. mon.setCursorPos(posx,(posy+3))
  420. mon.write("  Crepper  ")
  421. mon.setCursorPos(posx,(posy+4))
  422. mon.write("  Clear    ")
  423. iy = false
  424. while iy == false do
  425. event,side,x,y = os.pullEvent()
  426. if event == "monitor_touch" then
  427. if x > posx and x < (posx+10) and y == posy then
  428. iy = true
  429. mainmenu(user)
  430. end
  431. if x > posx and x < (posx+10) and y == (posy+1) then
  432. iy = true
  433. wpName = "pig"
  434. set_wp(wpName)
  435. mainmenu(user)
  436. end
  437. if x > posx and x < (posx+10) and y == (posy+2) then
  438. iy = true
  439. wpName = "steve"
  440. set_wp(wpName)
  441. mainmenu(user)
  442. end
  443. if x > posx and x < (posx+10) and y == (posy+3) then
  444. iy = true
  445. wpName = "creeper"
  446. set_wp(wpName)
  447. mainmenu(user)
  448. end
  449. if x > posx and x < (posx+10) and y == (posy+4) then
  450. iy = true
  451. wpName = "clear"
  452. set_wp(wpName)
  453. mainmenu(user)
  454. end
  455. end
  456. end
  457. end
  458.  
  459. --set new wp
  460. function set_wp(wp_name)
  461. file = fs.open("config/monitor.cfg","r")
  462. local fileData = {}
  463. local line = file.readLine()
  464. repeat
  465. table.insert(fileData,line)
  466. line = file.readLine()
  467. until line == nil
  468. file.close()
  469. num = 4
  470. table.remove(fileData,num)
  471. local file = fs.open("config/monitor.cfg","w")
  472. for iux=1,#fileData do
  473. file.writeLine(fileData[iux])
  474. end
  475. file.writeLine(wp_name)
  476. file.close()
  477. end
  478.  
  479. --settings menu--
  480. function settings(posx,posy)
  481. mon.setBackgroundColor(128)
  482. for iuZ=1,26 do
  483. mon.setCursorPos(posx,iuZ)
  484. mon.write("                                                  ")
  485. end
  486. mon.setCursorPos(50,1)
  487. mon.setBackgroundColor(colors.red)
  488. mon.setTextColor(colors.black)
  489. mon.write("X")
  490. mon.setBackgroundColor(colors.gray)
  491. mon.setTextColor(colors.white)
  492. mon.setCursorPos(1,1)
  493. mon.write("Hardware Settings")
  494. file = fs.open("config/monitor.cfg","r")
  495. local fileDataZ = {}
  496. local line = file.readLine()
  497. repeat
  498. table.insert(fileDataZ,line)
  499. line = file.readLine()
  500. until line == nil
  501. file.close()
  502. mon_nu = fileDataZ[1]
  503. per_nu = fileDataZ[2]
  504. rad_nu = fileDataZ[3]
  505. local per_st = false
  506. local found = fs.exists("config/per_plus_plus.cfg")
  507. if found == true then
  508. file = fs.open("config/per_plus_plus.cfg","r")
  509. local fileDataZZ = {}
  510. local line = file.readLine()
  511. repeat
  512. table.insert(fileDataZZ,line)
  513. line = file.readLine()
  514. until line == nil
  515. file.close()
  516. per_st = true
  517. spe_nu = fileDataZZ[1]
  518. cha_nu = fileDataZZ[2]
  519. not_nu = fileDataZZ[3]
  520. lam_nu = fileDataZZ[4]
  521. else
  522. spe_nu = "Please Reboot"
  523. cha_nu = "Please Reboot"
  524. not_nu = "Please Reboot"
  525. lam_nu = "Please Reboot"
  526. end
  527. mon.setCursorPos(3,3)
  528. mon.write("Monitor:")
  529. mon.setCursorPos(20,3)
  530. mon.write(mon_nu)
  531. mon.setCursorPos(3,5)
  532. mon.write("Computronics/Peripherals++")
  533. mon.setCursorPos(3,9)
  534. mon.write("Speaker:")
  535. mon.setCursorPos(20,9)
  536. mon.write(spe_nu)
  537. mon.setCursorPos(3,11)
  538. mon.write("Chat Box:")
  539. mon.setCursorPos(20,11)
  540. mon.write(cha_nu)
  541. mon.setCursorPos(3,13)
  542. mon.write("Iron Noteblock:")
  543. mon.setCursorPos(20,13)
  544. mon.write(not_nu)
  545. mon.setCursorPos(3,15)
  546. mon.write("Colorful Lamp:")
  547. mon.setCursorPos(20,15)
  548. mon.write(lam_nu)
  549. mon.setBackgroundColor(colors.blue)
  550. mon.setTextColor(colors.white)
  551. mon.setCursorPos(38,3)
  552. mon.write("Change")
  553. mon.setCursorPos(38,9)
  554. mon.write("Change")
  555. mon.setCursorPos(38,11)
  556. mon.write("Change")
  557. mon.setCursorPos(38,13)
  558. mon.write("Change")
  559. mon.setCursorPos(38,15)
  560. mon.write("Change")
  561. mon.setBackgroundColor(colors.white)
  562. if per_nu == "peripheralspluplus_off" then
  563. mon.setBackgroundColor(colors.white)
  564. mon.setCursorPos(38,5)
  565. mon.write("  ")
  566. mon.setBackgroundColor(colors.blue)
  567. mon.setCursorPos(40,5)
  568. mon.write("  ")
  569. mon.setCursorPos(43,5)
  570. mon.write("OFF")
  571. else
  572. mon.setBackgroundColor(colors.blue)
  573. mon.setCursorPos(38,5)
  574. mon.write("  ")
  575. mon.setBackgroundColor(colors.white)
  576. mon.setCursorPos(40,5)
  577. mon.write("  ")
  578. mon.setBackgroundColor(colors.blue)
  579. mon.setCursorPos(43,5)
  580. mon.write("ON")
  581. end
  582. iy = false
  583. while iy == false do
  584. event,side,x,y = os.pullEvent()
  585. if event == "monitor_touch" then
  586. if x == 50 and y == 1 then
  587. iy = true
  588. mainmenu(user)
  589. end
  590. if y == 3 then
  591. iy = true
  592. mon.setCursorPos(3,20)
  593. mon.write("Input Monitor Number:")
  594. mon.setCursorPos(3,21)
  595. input = read()
  596. set_sett_m(input,1)
  597. mon.setCursorPos(3,22)
  598. mon.write("Saved")
  599. sleep(5)
  600. settings(posx,posy)
  601. end
  602. if y == 5 then
  603. if per_nu == "peripheralspluplus_off" then
  604. set_sett_m("peripheralspluplus_on",2)
  605. settings(posx,posy)
  606. else
  607. set_sett_m("peripheralspluplus_off",2)
  608. settings(posx,posy)
  609. end
  610. end
  611. if y == 9 and per_st == true then
  612. iy = true
  613. mon.setCursorPos(3,20)
  614. mon.write("Input Speaker Number:")
  615. mon.setCursorPos(3,21)
  616. input = read()
  617. set_sett_p(input,1)
  618. mon.setCursorPos(3,22)
  619. mon.write("Saved")
  620. sleep(5)
  621. settings(posx,posy)
  622. end
  623. if y == 11 and per_st == true then
  624. iy = true
  625. mon.setCursorPos(3,20)
  626. mon.write("Input Chat Box Number:")
  627. mon.setCursorPos(3,21)
  628. input = read()
  629. set_sett_p(input,2)
  630. mon.setCursorPos(3,22)
  631. mon.write("Saved")
  632. sleep(5)
  633. settings(posx,posy)
  634. end
  635. if y == 13 and per_st == true then
  636. iy = true
  637. mon.setCursorPos(3,20)
  638. mon.write("Input Notebloack Number:")
  639. mon.setCursorPos(3,21)
  640. input = read()
  641. set_sett_p(input,3)
  642. mon.setCursorPos(3,22)
  643. mon.write("Saved")
  644. sleep(5)
  645. settings(posx,posy)
  646. end
  647. if y == 15 and per_st == true then
  648. iy = true
  649. mon.setCursorPos(3,20)
  650. mon.write("Input Lamp Number:")
  651. mon.setCursorPos(3,21)
  652. input = read()
  653. set_sett_p(input,4)
  654. mon.setCursorPos(3,22)
  655. mon.write("Saved")
  656. sleep(5)
  657. settings(posx,posy)
  658. end
  659. end
  660. end
  661. end
  662.  
  663. --save sett m wp
  664. function set_sett_m(wp_name,num)
  665. file = fs.open("config/monitor.cfg","r")
  666. local fileData = {}
  667. local line = file.readLine()
  668. repeat
  669. table.insert(fileData,line)
  670. line = file.readLine()
  671. until line == nil
  672. file.close()
  673. table.remove(fileData,num)
  674. table.insert(fileData,num,wp_name)
  675. local file = fs.open("config/monitor.cfg","w")
  676. for iux=1,#fileData do
  677. file.writeLine(fileData[iux])
  678. end
  679. file.close()
  680. end
  681.  
  682. --save sett p wp
  683. function set_sett_p(wp_name,num)
  684. file = fs.open("config/per_plus_plus.cfg","r")
  685. local fileData = {}
  686. local line = file.readLine()
  687. repeat
  688. table.insert(fileData,line)
  689. line = file.readLine()
  690. until line == nil
  691. file.close()
  692. table.remove(fileData,num)
  693. table.insert(fileData,num,wp_name)
  694. local file = fs.open("config/per_plus_plus.cfg","w")
  695. for iux=1,#fileData do
  696. file.writeLine(fileData[iux])
  697. end
  698. file.close()
  699. end
  700.  
  701. --Bios--
  702. function bios()
  703.   mon.clear()
  704.   mon.setTextColor(1)
  705.   mon.setBackgroundColor(colors.black)
  706.   mon.clear()
  707.   mon.setCursorPos(1,1)
  708.   mon.setTextColor(colors.yellow)
  709.   mon.write("caworks Modular Bios V.10")
  710.   sleep(0.5)
  711.   mon.setCursorPos(1,2)
  712.   mon.setTextColor(colors.white)
  713.   mon.write("2011 - 2013 caworks Software Inc")
  714.   sleep(0.5)
  715.   mon.setCursorPos(1,3)
  716.   mon.write("Processor caCore 2,4 GHZ x4")
  717.   sleep(0.5)
  718.   mon.setCursorPos(1,4)
  719.   mon.write("Memory Testing: ok  2096084K")
  720.   sleep(0.5)
  721.   mon.setCursorPos(1,5)
  722.   mon.write("----------------------------------------")
  723.   mon.setCursorPos(1,6)
  724.   mon.write("IDE Channel 0: Master  CW34342525 500GB")
  725.   mon.setCursorPos(1,7)
  726.   mon.write("IDE Channel 1: NONE")
  727.   mon.setCursorPos(1,24)
  728.   mon.write("Press F12 for Bios Setup")
  729.   sleep(5)
  730.   mon.clear()
  731. end
  732.  
  733. --loading screen--
  734. function loadingscreen()
  735. mon.clear()
  736. mon.setCursorPos(1,1)
  737. mon.write("_")
  738. sleep(3)
  739. mon.clear()
  740. mon.setTextColor(1)
  741. mon.setBackgroundColor(8)
  742. mon.clear()
  743. bootlogo = paintutils.loadImage("images/bootlogo")
  744. paintutils.drawImage(bootlogo, 1, 1)
  745. mon.setTextColor(1)
  746. mon.setBackgroundColor(8)
  747. mon.setCursorPos(17,15)
  748. mon.write("CawOS Loading")
  749. mon.setCursorPos(18,16)
  750. mon.setBackgroundColor(colors.red)
  751. mon.write(textutils.slowWrite("          ",1))
  752. mon.setBackgroundColor(8)
  753. mon.setCursorPos(17,17)
  754. if (PeripheralsPlusPlus == true) then
  755. caAPI.lamp(8)
  756. caAPI.sound(5,1)
  757. sleep(1)
  758. caAPI.lamp(32)
  759. caAPI.sound(6,1)
  760. sleep(1)
  761. caAPI.lamp(8)
  762. caAPI.sound(5,1)
  763. sleep(1)
  764. caAPI.lamp(32)
  765. caAPI.sound(6,1)
  766. end
  767. mon.write("Loging in..")
  768. sleep(2)
  769. end
  770.  
  771. --mainmenu screen(desktop)--
  772. function mainmenu(user)
  773. ix = false
  774. while ix == false do
  775. getPrograms()
  776. if wpName == "" or wpName == nil then
  777. wpName = "clear"
  778. end
  779. mon.setTextColor(colors.white)
  780. mon.clear()
  781. background = paintutils.loadImage("images/wallpaper/"..wpName)
  782. paintutils.drawImage(background, 1, 6)
  783. mon.setCursorPos(1,1)
  784. mon.setBackgroundColor(2048)
  785. mon.write("Menu|"..user.."                                 ")
  786. mon.setCursorPos(22,1)
  787. mon.write(caAPI.getTime())
  788. mon.setCursorPos(41,1)
  789. mon.write("CawOS v3.0")
  790. mon.setBackgroundColor(8)
  791.    --draw icons--
  792. startposx = 2
  793. startposy = 3
  794. space = 12
  795. maxSymbols = 4
  796. for xa=1,#programs do
  797. if xa == 5 or xa == 9 or xa == 13 then
  798. startposy = (startposy + 6)
  799. startposx = 2
  800. end
  801. caAPI.icon(startposx,startposy)
  802. mon.setCursorPos(startposx,(startposy+4))
  803. mon.write(string.sub(programs[xa],0,9))
  804. startposx = (startposx + space)
  805. end
  806. local found = fs.exists("config/autostart.cfg")
  807. if found == true and start_a == 0 then
  808. sleep(3)
  809. file = fs.open("config/autostart.cfg","r")
  810. local fileDataA = {}
  811. local line = file.readLine()
  812. repeat
  813. table.insert(fileDataA,line)
  814. line = file.readLine()
  815. until line == nil
  816. file.close()
  817. name = fileDataA[2]
  818. mon.setCursorPos(1,26)
  819. start_a = 1
  820. mon.write("Start "..name.."...")
  821. sleep(5)
  822. startP(name)
  823. end
  824. --touch--
  825. event,side,x,y = os.pullEvent()
  826. if event == "monitor_touch" then
  827. posP = 0
  828. --line1--
  829. if x > 2 and x < 8 and y > 3 and y < 7 then
  830. posP = 1
  831. name = programs[posP]
  832. if name ~= nil then
  833. mon.setCursorPos(1,26)
  834. mon.write("Start "..name.."...")
  835. sleep(5)
  836. startP(name)
  837. end
  838. end
  839. if x > 14 and x < 20 and y > 3 and y < 7 then
  840. posP = 2
  841. name = programs[posP]
  842. if name ~= nil then
  843. mon.setCursorPos(1,26)
  844. mon.write("Start "..name.."...")
  845. sleep(5)
  846. startP(name)
  847. end
  848. end
  849. if x > 26 and x < 32 and y > 3 and y < 7 then
  850. posP = 3
  851. name = programs[posP]
  852. if name ~= nil then
  853. mon.setCursorPos(1,26)
  854. mon.write("Start "..name.."...")
  855. sleep(5)
  856. startP(name)
  857. end
  858. end
  859. if x > 38 and x < 44 and y > 3 and y < 7 then
  860. posP = 4
  861. name = programs[posP]
  862. if name ~= nil then
  863. mon.setCursorPos(1,26)
  864. mon.write("Start "..name.."...")
  865. sleep(5)
  866. startP(name)
  867. end
  868. end
  869. --line2--
  870. if x > 2 and x < 8 and y > 9 and y < 13 then
  871. posP = 5
  872. name = programs[posP]
  873. if name ~= nil then
  874. mon.setCursorPos(1,26)
  875. mon.write("Start "..name.."...")
  876. sleep(5)
  877. startP(name)
  878. end
  879. end
  880. if x > 14 and x < 20 and y > 9 and y < 13 then
  881. posP = 6
  882. name = programs[posP]
  883. if name ~= nil then
  884. mon.setCursorPos(1,26)
  885. mon.write("Start "..name.."...")
  886. sleep(5)
  887. startP(name)
  888. end
  889. end
  890. if x > 26 and x < 32 and y > 9 and y < 13 then
  891. posP = 7
  892. name = programs[posP]
  893. if name ~= nil then
  894. mon.setCursorPos(1,26)
  895. mon.write("Start "..name.."...")
  896. sleep(5)
  897. startP(name)
  898. end
  899. end
  900. if x > 38 and x < 44 and y > 9 and y < 13 then
  901. posP = 8
  902. name = programs[posP]
  903. if name ~= nil then
  904. mon.setCursorPos(1,26)
  905. mon.write("Start "..name.."...")
  906. sleep(5)
  907. startP(name)
  908. end
  909. end
  910. --line3--
  911. if x > 2 and x < 8 and y > 15 and y < 19 then
  912. posP = 9
  913. name = programs[posP]
  914. if name ~= nil then
  915. mon.setCursorPos(1,26)
  916. mon.write("Start "..name.."...")
  917. sleep(5)
  918. startP(name)
  919. end
  920. end
  921. if x > 14 and x < 20 and y > 15 and y < 19 then
  922. posP = 10
  923. name = programs[posP]
  924. if name ~= nil then
  925. mon.setCursorPos(1,26)
  926. mon.write("Start "..name.."...")
  927. sleep(5)
  928. startP(name)
  929. end
  930. end
  931. if x > 26 and x < 32 and y > 15 and y < 19 then
  932. posP = 11
  933. name = programs[posP]
  934. if name ~= nil then
  935. mon.setCursorPos(1,26)
  936. mon.write("Start "..name.."...")
  937. sleep(5)
  938. startP(name)
  939. end
  940. end
  941. if x > 38 and x < 44 and y > 15 and y < 19 then
  942. posP = 12
  943. name = programs[posP]
  944. if name ~= nil then
  945. mon.setCursorPos(1,26)
  946. mon.write("Start "..name.."...")
  947. sleep(5)
  948. startP(name)
  949. end
  950. end
  951. --line4--
  952. if x > 2 and x < 8 and y > 21 and y < 25 then
  953. posP = 13
  954. name = programs[posP]
  955. if name ~= nil then
  956. mon.setCursorPos(1,26)
  957. mon.write("Start "..name.."...")
  958. sleep(5)
  959. startP(name)
  960. end
  961. end
  962. if x > 14 and x < 20 and y > 21 and y < 25 then
  963. posP = 14
  964. name = programs[posP]
  965. if name ~= nil then
  966. mon.setCursorPos(1,26)
  967. mon.write("Start "..name.."...")
  968. sleep(5)
  969. startP(name)
  970. end
  971. end
  972. if x > 26 and x < 32 and y > 21 and y < 25 then
  973. posP = 15
  974. name = programs[posP]
  975. if name ~= nil then
  976. mon.setCursorPos(1,26)
  977. mon.write("Start "..name.."...")
  978. sleep(5)
  979. startP(name)
  980. end
  981. end
  982. if x > 38 and x < 44 and y > 21 and y < 25 then
  983. posP = 16
  984. name = programs[posP]
  985. if name ~= nil then
  986. mon.setCursorPos(1,26)
  987. mon.write("Start "..name.."...")
  988. sleep(5)
  989. startP(name)
  990. end
  991. end
  992. if x > 1 and x < 6 and y == 1 then
  993. xi = true
  994. menu(2,2)
  995. end
  996. end
  997. end
  998. end
  999.  
  1000. --login--
  1001. function login()
  1002. local found = fs.exists("database/user.db")
  1003. if found == false then
  1004. local file = fs.open("database/user.db","w")
  1005. file.writeLine("Guest#0000")
  1006. file.close()
  1007. end
  1008. local found = fs.exists("config/autostart.cfg")
  1009. if found == true then
  1010. file = fs.open("config/autostart.cfg","r")
  1011. local fileDataA = {}
  1012. local line = file.readLine()
  1013. repeat
  1014. table.insert(fileDataA,line)
  1015. line = file.readLine()
  1016. until line == nil
  1017. file.close()
  1018. user = fileDataA[1]
  1019. mainmenu(user)
  1020. end
  1021. file = fs.open("database/user.db","r")
  1022. local fileData = {}
  1023. local line = file.readLine()
  1024. repeat
  1025. table.insert(fileData,line)
  1026. line = file.readLine()
  1027. until line == nil
  1028. file.close()
  1029. mon.setBackgroundColor(colors.gray)
  1030. local startdraw = 10
  1031. for iud=1,(#fileData + 3) do
  1032. mon.setCursorPos(14,startdraw)
  1033. mon.write("                ")
  1034. startdraw = startdraw + 1
  1035. end
  1036. mon.setCursorPos(15,(startdraw-1))
  1037. mon.setTextColor(colors.red)
  1038. mon.write("New User")
  1039. mon.setCursorPos((15-1),startdraw)
  1040. mon.setTextColor(colors.green)
  1041. mon.write(" Sensor         ")
  1042. mon.setTextColor(colors.white)
  1043. mon.setCursorPos(15,10)
  1044. mon.write("User:")
  1045. local startcursor = 11
  1046. for iu=1,#fileData do
  1047. mon.setCursorPos(15,startcursor)
  1048. dataU = caAPI.split(fileData[iu],"#")
  1049. mon.write(dataU[1])
  1050. startcursor = startcursor + 1
  1051. end
  1052. mon.setBackgroundColor(8)
  1053. mon.setBackgroundColor(8)
  1054.    --Input--
  1055. local ixu = false
  1056. while ixu == false do
  1057. event,side,x,y = os.pullEvent()
  1058. if event == "monitor_touch" then
  1059. posU = 0
  1060. if x > 15 and x < 30 and y == (startdraw-1) then
  1061. ixu = true
  1062. new_user()
  1063. end
  1064. if x > 15 and x < 30 and y == (startdraw) then
  1065. ixu = true
  1066. os.loadAPI("sensor_plugin")
  1067. check_st = sensor_plugin.sensor()
  1068. check_sp = caAPI.split(check_st,"#")
  1069. check_st = check_sp[1]
  1070. if check_st == "ok" then
  1071. user = check_sp[2]
  1072. mainmenu(user)
  1073. else
  1074. login()
  1075. end
  1076. end
  1077. if x > 15 and x < 30 and y == 11 then
  1078. posU = 1
  1079. user = fileData[posU]
  1080. if user ~= nil then
  1081. dataU = caAPI.split(user,"#")
  1082. user = dataU[1]
  1083. pwd = dataU[2]
  1084. mon.setCursorPos(14,7)
  1085. mon.write("                        ")
  1086. mon.setCursorPos(14,7)
  1087. mon.write("Password for "..user)
  1088. mon.setCursorPos(14,8)
  1089. mon.write("                        ")
  1090. mon.setCursorPos(14,8)
  1091. local nwpw = read("*")
  1092. if user ~= nil and nwpw == pwd then
  1093. ixu = true
  1094. mainmenu(user)
  1095. sleep(2)
  1096. else
  1097. mon.setCursorPos(14,8)
  1098. mon.write("Wrong PW!! Choose a User")
  1099. login()
  1100. end
  1101. end
  1102. end
  1103. if x > 15 and x < 30 and y == 12 then
  1104. posU = 2
  1105. user = fileData[posU]
  1106. if user ~= nil then
  1107. dataU = caAPI.split(user,"#")
  1108. user = dataU[1]
  1109. pwd = dataU[2]
  1110. mon.setCursorPos(14,7)
  1111. mon.write("                        ")
  1112. mon.setCursorPos(14,7)
  1113. mon.write("Password for "..user)
  1114. mon.setCursorPos(14,8)
  1115. mon.write("                        ")
  1116. mon.setCursorPos(14,8)
  1117. local nwpw = read("*")
  1118. if user ~= nil and nwpw == pwd then
  1119. ixu = true
  1120. mainmenu(user)
  1121. sleep(2)
  1122. else
  1123. mon.setCursorPos(14,8)
  1124. mon.write("Wrong PW!! Choose a User")
  1125. login()
  1126. end
  1127. end
  1128. end
  1129. if x > 15 and x < 30 and y == 13 then
  1130. posU = 3
  1131. user = fileData[posU]
  1132. if user ~= nil then
  1133. dataU = caAPI.split(user,"#")
  1134. user = dataU[1]
  1135. pwd = dataU[2]
  1136. mon.setCursorPos(14,7)
  1137. mon.write("                        ")
  1138. mon.setCursorPos(14,7)
  1139. mon.write("Password for "..user)
  1140. mon.setCursorPos(14,8)
  1141. mon.write("                        ")
  1142. mon.setCursorPos(14,8)
  1143. local nwpw = read("*")
  1144. if user ~= nil and nwpw == pwd then
  1145. ixu = true
  1146. mainmenu(user)
  1147. sleep(2)
  1148. else
  1149. mon.setCursorPos(14,8)
  1150. mon.write("Wrong PW!! Choose a User")
  1151. login()
  1152. end
  1153. end
  1154. end
  1155. if x > 15 and x < 30 and y == 14 then
  1156. posU = 4
  1157. user = fileData[posU]
  1158. if user ~= nil then
  1159. dataU = caAPI.split(user,"#")
  1160. user = dataU[1]
  1161. pwd = dataU[2]
  1162. mon.setCursorPos(14,7)
  1163. mon.write("                        ")
  1164. mon.setCursorPos(14,7)
  1165. mon.write("Password for "..user)
  1166. mon.setCursorPos(14,8)
  1167. mon.write("                        ")
  1168. mon.setCursorPos(14,8)
  1169. local nwpw = read("*")
  1170. if user ~= nil and nwpw == pwd then
  1171. ixu = true
  1172. mainmenu(user)
  1173. sleep(2)
  1174. else
  1175. mon.setCursorPos(14,8)
  1176. mon.write("Wrong PW!! Choose a User")
  1177. login()
  1178. end
  1179. end
  1180. end
  1181. if x > 15 and x < 30 and y == 15 then
  1182. posU = 5
  1183. user = fileData[posU]
  1184. if user ~= nil then
  1185. pwd = dataU[2]
  1186. mon.setCursorPos(14,7)
  1187. mon.write("                        ")
  1188. mon.setCursorPos(14,7)
  1189. mon.write("Password for "..user)
  1190. mon.setCursorPos(14,8)
  1191. mon.write("                        ")
  1192. mon.setCursorPos(14,8)
  1193. local nwpw = read("*")
  1194. if user ~= nil and nwpw == pwd then
  1195. ixu = true
  1196. mainmenu(user)
  1197. sleep(2)
  1198. else
  1199. mon.setCursorPos(14,8)
  1200. mon.write("Wrong PW!! Choose a User")
  1201. login()
  1202. end
  1203. end
  1204. end
  1205. end
  1206. end
  1207. if (PeripheralsPlusPlus == true) then
  1208. caAPI.sound(5,1)
  1209. end
  1210. end
  1211.  
  1212. --new user--
  1213. function new_user()
  1214. mon.setBackgroundColor(colors.white)
  1215. mon.setTextColor(colors.black)
  1216. mon.setCursorPos(15,8)
  1217. mon.write("New User:")
  1218. mon.setCursorPos(15,9)
  1219. local nwus = read()
  1220. mon.setCursorPos(15,8)
  1221. mon.write("Password")
  1222. mon.setCursorPos(15,9)
  1223. local nwpw = read("*")
  1224. local file = fs.open("database/user.db","a")
  1225. file.writeLine(nwus.."#"..nwpw)
  1226. file.close()
  1227. sleep(2)
  1228. login()
  1229. end
  1230.  
  1231. --downlaod programs--
  1232. function download()
  1233. shell.run("mkdir images")
  1234. shell.run("mkdir images/wallpaper")
  1235. shell.run("mkdir config")
  1236. shell.run("mkdir database")
  1237. mon.clear()
  1238. mon.setCursorPos(1,1)
  1239. shell.run("delete caAPI")
  1240. shell.run("pastebin get EDLdR1nF caAPI")
  1241. shell.run("delete sensor_plugin")
  1242. shell.run("pastebin get sUjKS14y sensor_plugin")
  1243. shell.run("delete Email")
  1244. shell.run("pastebin get 8SDMFXbE Email")
  1245. shell.run("delete NetChat")
  1246. shell.run("pastebin get CQfGf71b NetChat")
  1247. shell.run("delete Download")
  1248. shell.run("pastebin get BSE3VEzU Download")
  1249. shell.run("delete images/bootlogo")
  1250. shell.run("pastebin get 6TMaAkDt images/bootlogo")
  1251. shell.run("delete images/icon")
  1252. shell.run("pastebin get 8bpP81nj images/icon")
  1253. shell.run("delete images/wallpaper/clear")
  1254. shell.run("pastebin get n7VBnnB9 images/wallpaper/clear")
  1255. shell.run("delete images/wallpaper/creeper")
  1256. shell.run("pastebin get 6CGEBn0G images/wallpaper/creeper")
  1257. shell.run("delete images/wallpaper/pig")
  1258. shell.run("pastebin get SkDqceqX images/wallpaper/pig")
  1259. shell.run("delete images/wallpaper/steve")
  1260. shell.run("pastebin get Ln8J74df images/wallpaper/steve")
  1261. sleep(5)
  1262. --load API---
  1263. os.loadAPI("caAPI")
  1264. --ini peripheralPlusPlus--
  1265. if (PeripheralsPlusPlus == true) then
  1266. caAPI.ini_peripheralPlusPlus()
  1267. end
  1268. end
  1269.  
  1270. --program--
  1271. bios()
  1272. download()
  1273. rs.setBundledOutput("bottom",colors.black)
  1274. loadingscreen()
  1275. login()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement