Advertisement
Guest User

Touchmk1

a guest
Aug 6th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 66.38 KB | None | 0 0
  1. --Code by Max Wason
  2.  
  3. monitorSide = "left"
  4. wirelessRedstoneSide = "back"
  5. wirelessModemSide = "right"
  6. mystcraftTurtleID = 3
  7. AEcomputerID = 14
  8. tankComputerID = 16
  9. powerComputerID = 6
  10.  
  11. wr = peripheral.wrap(wirelessRedstoneSide)
  12. rednet.open(wirelessModemSide)
  13.  
  14.  
  15. -- monitor = peripheral.wrap(monitorSide)
  16. -- print(monitor.getSize())
  17.  
  18. os.loadAPI("touchpointEdited")
  19. -- local page1 = touchpointEdited.new(monitorSide)
  20. -- local page2 = touchpointEdited.new(monitorSide)
  21. local loginPage = touchpointEdited.new(monitorSide) --Login
  22. local mainPage = touchpointEdited.new(monitorSide) --Main screen after login
  23.  
  24. local accountPage = touchpointEdited.new(monitorSide)
  25. local changePasswordPage = touchpointEdited.new(monitorSide)
  26. local changeAccessPage = touchpointEdited.new(monitorSide)
  27. local changeAddUserPage = touchpointEdited.new(monitorSide)
  28. local changeRemoveUserPage = touchpointEdited.new(monitorSide)
  29.  
  30. local mystcraftPage = touchpointEdited.new(monitorSide)
  31. local mystcraftInterlinkingPage = touchpointEdited.new(monitorSide)
  32. local mystcraftIntralinkingPage = touchpointEdited.new(monitorSide)
  33.  
  34. local powerPage = touchpointEdited.new(monitorSide)
  35.  
  36. local oreProcessingPage = touchpointEdited.new(monitorSide)
  37.  
  38. local aePage = touchpointEdited.new(monitorSide)
  39.  
  40. local nuclearControlPage = touchpointEdited.new(monitorSide)
  41.  
  42. local t
  43.  
  44. --*******************************************************Profile Class********************************************************************
  45.  
  46. Profile = {}
  47. Profile.__index = Profile
  48.  
  49. function Profile.create(name, password, access)
  50. local profile = {}
  51. setmetatable(profile,Profile)
  52. profile.name = name
  53. profile.password = password
  54. profile.access = access
  55. return profile
  56. end
  57.  
  58.  
  59. --********************************************************END OF PROFILE CLASS*************************************************************
  60.  
  61.  
  62. --*******************************************************FILE IO************************************************************************
  63.  
  64. fileName = "userData.txt"
  65.  
  66. function file_exists(name)
  67. local f=io.open(name,"r")
  68. if f~=nil then io.close(f) return true else return false end
  69. end
  70.  
  71. local write, writeIndent, writers, refCount;
  72.  
  73. persistence =
  74. {
  75. store = function (path, ...)
  76. local file, e = io.open(path, "w");
  77. if not file then
  78. return error(e);
  79. end
  80. local n = select("#", ...);
  81. -- Count references
  82. local objRefCount = {}; -- Stores reference that will be exported
  83. for i = 1, n do
  84. refCount(objRefCount, (select(i,...)));
  85. end;
  86. -- Export Objects with more than one ref and assign name
  87. -- First, create empty tables for each
  88. local objRefNames = {};
  89. local objRefIdx = 0;
  90. file:write("-- Persistent Data\n");
  91. file:write("local multiRefObjects = {\n");
  92. for obj, count in pairs(objRefCount) do
  93. if count > 1 then
  94. objRefIdx = objRefIdx + 1;
  95. objRefNames[obj] = objRefIdx;
  96. file:write("{};"); -- table objRefIdx
  97. end;
  98. end;
  99. file:write("\n} -- multiRefObjects\n");
  100. -- Then fill them (this requires all empty multiRefObjects to exist)
  101. for obj, idx in pairs(objRefNames) do
  102. for k, v in pairs(obj) do
  103. file:write("multiRefObjects["..idx.."][");
  104. write(file, k, 0, objRefNames);
  105. file:write("] = ");
  106. write(file, v, 0, objRefNames);
  107. file:write(";\n");
  108. end;
  109. end;
  110. -- Create the remaining objects
  111. for i = 1, n do
  112. file:write("local ".."obj"..i.." = ");
  113. write(file, (select(i,...)), 0, objRefNames);
  114. file:write("\n");
  115. end
  116. -- Return them
  117. if n > 0 then
  118. file:write("return obj1");
  119. for i = 2, n do
  120. file:write(" ,obj"..i);
  121. end;
  122. file:write("\n");
  123. else
  124. file:write("return\n");
  125. end;
  126. file:close();
  127. end;
  128.  
  129. load = function (path)
  130. local f, e = loadfile(path);
  131. if f then
  132. return f();
  133. else
  134. return nil, e;
  135. end;
  136. end;
  137. }
  138.  
  139. -- Private methods
  140.  
  141. -- write thing (dispatcher)
  142. write = function (file, item, level, objRefNames)
  143. writers[type(item)](file, item, level, objRefNames);
  144. end;
  145.  
  146. -- write indent
  147. writeIndent = function (file, level)
  148. for i = 1, level do
  149. file:write("\t");
  150. end;
  151. end;
  152.  
  153. -- recursively count references
  154. refCount = function (objRefCount, item)
  155. -- only count reference types (tables)
  156. if type(item) == "table" then
  157. -- Increase ref count
  158. if objRefCount[item] then
  159. objRefCount[item] = objRefCount[item] + 1;
  160. else
  161. objRefCount[item] = 1;
  162. -- If first encounter, traverse
  163. for k, v in pairs(item) do
  164. refCount(objRefCount, k);
  165. refCount(objRefCount, v);
  166. end;
  167. end;
  168. end;
  169. end;
  170.  
  171. -- Format items for the purpose of restoring
  172. writers = {
  173. ["nil"] = function (file, item)
  174. file:write("nil");
  175. end;
  176. ["number"] = function (file, item)
  177. file:write(tostring(item));
  178. end;
  179. ["string"] = function (file, item)
  180. file:write(string.format("%q", item));
  181. end;
  182. ["boolean"] = function (file, item)
  183. if item then
  184. file:write("true");
  185. else
  186. file:write("false");
  187. end
  188. end;
  189. ["table"] = function (file, item, level, objRefNames)
  190. local refIdx = objRefNames[item];
  191. if refIdx then
  192. -- Table with multiple references
  193. file:write("multiRefObjects["..refIdx.."]");
  194. else
  195. -- Single use table
  196. file:write("{\n");
  197. for k, v in pairs(item) do
  198. writeIndent(file, level+1);
  199. file:write("[");
  200. write(file, k, level+1, objRefNames);
  201. file:write("] = ");
  202. write(file, v, level+1, objRefNames);
  203. file:write(";\n");
  204. end
  205. writeIndent(file, level);
  206. file:write("}");
  207. end;
  208. end;
  209. ["function"] = function (file, item)
  210. -- Does only work for "normal" functions, not those
  211. -- with upvalues or c functions
  212. local dInfo = debug.getinfo(item, "uS");
  213. if dInfo.nups > 0 then
  214. file:write("nil --[[functions with upvalue not supported]]");
  215. elseif dInfo.what ~= "Lua" then
  216. file:write("nil --[[non-lua function not supported]]");
  217. else
  218. local r, s = pcall(string.dump,item);
  219. if r then
  220. file:write(string.format("loadstring(%q)", s));
  221. else
  222. file:write("nil --[[function could not be dumped]]");
  223. end
  224. end
  225. end;
  226. ["thread"] = function (file, item)
  227. file:write("nil --[[thread]]\n");
  228. end;
  229. ["userdata"] = function (file, item)
  230. file:write("nil --[[userdata]]\n");
  231. end;
  232. }
  233.  
  234. if file_exists(fileName) then
  235. profileArray = persistence.load(fileName);
  236. else
  237. profileArray = {
  238. Profile.create("gr8pefish", "temporary", 1),
  239. Profile.create("admin", "pass", 1),
  240. Profile.create("guest", "password", 3),
  241. Profile.create("Test Account", "Pass 123", 1)
  242. }
  243. persistence.store(fileName, profileArray)
  244. end
  245.  
  246.  
  247. --***************************************************EDN OF FILE IO************************************************************************
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254. --********************************************************KEYBOARD/LOGIN********************************************************************
  255. username = ""
  256. password = ""
  257. input = ""
  258. useUppercase = false
  259. useUsername = true
  260. usePassword = false
  261.  
  262. usernameSubmittedExists = false
  263. loginPasswordExists = false
  264. loginUsernameExists = false
  265. loginPassword = ""
  266. loginUsername = ""
  267.  
  268. currentUser = nil
  269. valid = false
  270.  
  271. function checkValid()
  272. if (loginPasswordExists and loginUsernameExists) then
  273. for key, value in pairs(profileArray) do
  274. if loginUsername == value.name then
  275. usernameSubmittedExists = true
  276. if loginPassword == value.password then
  277. valid = true
  278. currentUser = value
  279. else
  280. valid = false
  281. end
  282. end
  283. end
  284. drawMessage()
  285. end
  286. end
  287.  
  288. function checkValidUsernameAndPassword(confirm)
  289. if confirm == "goOn" then
  290. t = mainPage
  291. elseif confirm == "backToPassword" then
  292. drawPassword()
  293. elseif confirm == "backToUsername" then
  294. drawUsername()
  295. elseif confirm == "password" then
  296. confirmPassword()
  297. checkValid()
  298. elseif confirm == "username" then
  299. confirmUsername()
  300. checkValid()
  301. end
  302. end
  303.  
  304.  
  305.  
  306. function confirmPassword()
  307. loginPassword = input
  308. loginPasswordExists = true
  309. input = ""
  310. usePassword = false
  311. useUsername = true
  312. drawUsername()
  313. doBackspace()
  314. end
  315.  
  316. function confirmUsername()
  317. loginUsername = input
  318. loginUsernameExists = true
  319. input = ""
  320. useUsername = false
  321. usePassword = true
  322. drawPassword()
  323. doBackspace()
  324. end
  325.  
  326. local inputTable = {
  327. " ",
  328. " ",
  329. label = "inputLabel",
  330. }
  331.  
  332. local ArrowTable = {
  333. "-->",
  334. label = "ArrowLabel",
  335. }
  336.  
  337. local additionalOkayTable = {
  338. "Okay",
  339. label = "additionalOkayLabel"
  340. }
  341.  
  342. local loginTable = {
  343. " Please Login ",
  344. " ",
  345. "Enter your username and password.",
  346. "Press okay to confirm each. ",
  347. label = "loginTableLabel",
  348. }
  349.  
  350. local infoTableUsername = {
  351. "Enter your username: ",
  352. label = "infoLabel"
  353. }
  354.  
  355. function drawMessage()
  356. if valid then
  357. infoTableContinue = {"Welcome Back!", label = "infoLabel"}
  358. loginPage:rename("infoLabel", infoTableContinue)
  359.  
  360. inputTableContinue = {currentUser.name,"Access Level: "..currentUser.access, label = "inputLabel"}
  361. loginPage:rename("inputLabel", inputTableContinue)
  362.  
  363. key = "goOn"
  364. elseif usernameSubmittedExists then
  365. infoTableContinue = {"You seem to have entered", label = "infoLabel"}
  366. loginPage:rename("infoLabel", infoTableContinue)
  367.  
  368. inputTableContinue = {"the wrong password",loginUsername, label = "inputLabel"}
  369. loginPage:rename("inputLabel", inputTableContinue)
  370.  
  371. loginPasswordExists = false
  372. useUsername = false
  373. usePassword = true
  374. input = ""
  375. key = "backToPassword"
  376. else
  377. infoTableContinue = {"There is no username called", label = "infoLabel"}
  378. loginPage:rename("infoLabel", infoTableContinue)
  379.  
  380. inputTableContinue = {loginUsername," ", label = "inputLabel"}
  381. loginPage:rename("inputLabel", inputTableContinue)
  382.  
  383. loginPasswordExists = false
  384. loginUsernameExists = false
  385. useUsername = true
  386. usePassword = false
  387. input = ""
  388. key = "backToUsername"
  389. end
  390. end
  391.  
  392.  
  393. function drawUsername()
  394. key = "username"
  395. loginPage:rename("infoLabel", infoTableUsername)
  396. doBackspace()
  397. end
  398.  
  399. function drawPassword()
  400. key = "password"
  401. infoTablePassword = {"Enter your password: ", label = "infoLabel"}
  402. loginPage:rename("infoLabel", infoTablePassword)
  403. doBackspace()
  404. end
  405.  
  406. function updateUsernameOutput(input)
  407. if (#input < 16) then
  408. input = (input..(string.rep(" ",(16-#input))))
  409. end
  410.  
  411. newInput = {input," ", label = "inputLabel"}
  412. loginPage:rename("inputLabel", newInput, true)
  413. end
  414.  
  415. function addToInput(char)
  416. if useUppercase then char = char:upper() end
  417. if (#input >= 16) then
  418. input = input:sub(0,16)
  419. else
  420. input = (input..char)
  421. end
  422.  
  423. if useUsername then
  424. updateUsernameOutput(input)
  425. else
  426. updatePasswordOutput(input)
  427. end
  428. end
  429.  
  430. function updatePasswordOutput(input)
  431. input2 = string.rep("*", #input)
  432.  
  433. if (#input < 16) then
  434. input = (input..(string.rep(" ",(16-#input))))
  435. end
  436.  
  437. newInput = {input2," ", label = "inputLabel"}
  438. loginPage:rename("inputLabel", newInput, true)
  439. end
  440.  
  441. key = "username"
  442. loginPage:add(loginTable, nil, 3, 35, 2, 5, colors.black, colors.black, colors.brown)
  443.  
  444. loginPage:add(infoTableUsername, nil, 5, 28, 9, 9, colors.black, colors.black, colors.lightGray)
  445. loginPage:add(ArrowTable, nil, 1, 4, 10, 10, colors.black, colors.black, colors.brown)
  446. loginPage:add(inputTable, nil, 5, 22, 10, 11, colors.black, colors.black, colors.lightGray)
  447. loginPage:add("Okay", function() checkValidUsernameAndPassword(key) end, 25, 30, 10, 10, colors.black, colors.black, colors.cyan)
  448.  
  449. loginPage:add("1", function() addToInput("1") end, 5, 5, 14, 14, colors.black, colors.black, colors.lightGray)
  450. loginPage:add("2", function() addToInput("2") end, 7, 7, 14, 14, colors.black, colors.black, colors.lightGray)
  451. loginPage:add("3", function() addToInput("3") end, 9, 9, 14, 14, colors.black, colors.black, colors.lightGray)
  452. loginPage:add("4", function() addToInput("4") end, 11, 11, 14, 14, colors.black, colors.black, colors.lightGray)
  453. loginPage:add("5", function() addToInput("5") end, 13, 13, 14, 14, colors.black, colors.black, colors.lightGray)
  454. loginPage:add("6", function() addToInput("6") end, 15, 15, 14, 14, colors.black, colors.black, colors.lightGray)
  455. loginPage:add("7", function() addToInput("7") end, 17, 17, 14, 14, colors.black, colors.black, colors.lightGray)
  456. loginPage:add("8", function() addToInput("8") end, 19, 19, 14, 14, colors.black, colors.black, colors.lightGray)
  457. loginPage:add("9", function() addToInput("9") end, 21, 21, 14, 14, colors.black, colors.black, colors.lightGray)
  458. loginPage:add("0", function() addToInput("0") end, 23, 23, 14, 14, colors.black, colors.black, colors.lightGray)
  459.  
  460. loginPage:add("Q", function() addToInput("q") end, 5, 5, 15, 15, colors.black, colors.black, colors.lightGray)
  461. loginPage:add("W", function() addToInput("w") end, 7, 7, 15, 15, colors.black, colors.black, colors.lightGray)
  462. loginPage:add("E", function() addToInput("e") end, 9, 9, 15, 15, colors.black, colors.black, colors.lightGray)
  463. loginPage:add("R", function() addToInput("r") end, 11, 11, 15, 15, colors.black, colors.black, colors.lightGray)
  464. loginPage:add("T", function() addToInput("t") end, 13, 13, 15, 15, colors.black, colors.black, colors.lightGray)
  465. loginPage:add("Y", function() addToInput("y") end, 15, 15, 15, 15, colors.black, colors.black, colors.lightGray)
  466. loginPage:add("U", function() addToInput("u") end, 17, 17, 15, 15, colors.black, colors.black, colors.lightGray)
  467. loginPage:add("I", function() addToInput("i") end, 19, 19, 15, 15, colors.black, colors.black, colors.lightGray)
  468. loginPage:add("O", function() addToInput("o") end, 21, 21, 15, 15, colors.black, colors.black, colors.lightGray)
  469. loginPage:add("P", function() addToInput("p") end, 23, 23, 15, 15, colors.black, colors.black, colors.lightGray)
  470.  
  471. loginPage:add("A", function() addToInput("a") end, 6, 6, 16, 16, colors.black, colors.black, colors.lightGray)
  472. loginPage:add("S", function() addToInput("s") end, 8, 8, 16, 16, colors.black, colors.black, colors.lightGray)
  473. loginPage:add("D", function() addToInput("d") end, 10, 10, 16, 16, colors.black, colors.black, colors.lightGray)
  474. loginPage:add("F", function() addToInput("f") end, 12, 12, 16, 16, colors.black, colors.black, colors.lightGray)
  475. loginPage:add("G", function() addToInput("g") end, 14, 14, 16, 16, colors.black, colors.black, colors.lightGray)
  476. loginPage:add("H", function() addToInput("h") end, 16, 16, 16, 16, colors.black, colors.black, colors.lightGray)
  477. loginPage:add("J", function() addToInput("j") end, 18, 18, 16, 16, colors.black, colors.black, colors.lightGray)
  478. loginPage:add("K", function() addToInput("k") end, 20, 20, 16, 16, colors.black, colors.black, colors.lightGray)
  479. loginPage:add("L", function() addToInput("l") end, 22, 22, 16, 16, colors.black, colors.black, colors.lightGray)
  480.  
  481. loginPage:add("Z", function() addToInput("z") end, 7, 7, 17, 17, colors.black, colors.black, colors.lightGray)
  482. loginPage:add("X", function() addToInput("x") end, 9, 9, 17, 17, colors.black, colors.black, colors.lightGray)
  483. loginPage:add("C", function() addToInput("c") end, 11, 11, 17, 17, colors.black, colors.black, colors.lightGray)
  484. loginPage:add("V", function() addToInput("v") end, 13, 13, 17, 17, colors.black, colors.black, colors.lightGray)
  485. loginPage:add("B", function() addToInput("b") end, 15, 15, 17, 17, colors.black, colors.black, colors.lightGray)
  486. loginPage:add("N", function() addToInput("n") end, 17, 17, 17, 17, colors.black, colors.black, colors.lightGray)
  487. loginPage:add("M", function() addToInput("m") end, 19, 19, 17, 17, colors.black, colors.black, colors.lightGray)
  488.  
  489. loginPage:add("Shift",function() doShift() end, 29, 35, 15, 15, colors.cyan, colors.green, colors.white)
  490. loginPage:add("Backspace", function() doBackspace() end, 26, 39, 17, 17, colors.black, colors.black, colors.cyan)
  491. loginPage:add("Space", function() addToInput(" ") end, 29, 35, 16, 16, colors.black, colors.black, colors.cyan)
  492.  
  493.  
  494. function doBackspace()
  495. input = input:sub(0, #input-1)
  496. if useUsername then updateUsernameOutput(input) else updatePasswordOutput(input) end
  497. end
  498.  
  499. function doShift()
  500. loginPage:toggleButton("Shift")
  501. if (loginPage.buttonList["Shift"].active) then useUppercase = true else useUppercase = false end
  502. end
  503.  
  504.  
  505.  
  506.  
  507. --**************************************************END OF KEYBOARD/PAGE 3**************************************************************************
  508.  
  509.  
  510.  
  511. --****************************************************START OF ACCOUNT PAGE***********************************************************************
  512. local mainTOaccount = {
  513. "View Account",
  514. " Details",
  515. label = "mainToaccountLabel",
  516. }
  517.  
  518. local mainTOmystcraft = {
  519. " Mystcraft",
  520. "Portal Controls",
  521. label = "mainTOmystcraftLabel",
  522. }
  523.  
  524. local mainTOpower = {
  525. " Power",
  526. "Information",
  527. label = "mainTOpowerLabel",
  528. }
  529.  
  530. local mainTOoreProcessing = {
  531. " Ore",
  532. "Processing",
  533. label = "mainTOoreProcessingLabel",
  534. }
  535.  
  536. local mainTOae = {
  537. " AE",
  538. "Control",
  539. label = "mainTOaeLabel",
  540. }
  541.  
  542. local mainTOnuke = {
  543. "Nuclear",
  544. "Control",
  545. label = "mainTOnukeLabel"
  546. }
  547.  
  548. function addmainPage()
  549. --Add these for everyone
  550. welcomeMainScreenXPos = ((20) - ((8 + currentUser.name:len())/2))
  551. if math.floor(welcomeMainScreenXPos) <= 0 then welcomeMainScreenXPos = 1 end
  552. -- print("printing name at x="..welcomeMainScreenXPos)
  553. mainPage:add("Welcome "..currentUser.name, nil, math.floor(welcomeMainScreenXPos), math.floor((welcomeMainScreenXPos)+(9+currentUser.name:len())), 2, 2, colors.black, colors.black, colors.brown)
  554. mainPage:add(mainTOaccount, mainToAccountPage, 5,18, 5,6, colors.black, colors.black, colors.cyan)
  555. mainPage:add(mainTOmystcraft, mainToMystcraftPage, 23,35, 5,6, colors.black, colors.black, colors.cyan)
  556. mainPage:add(mainTOpower, mainToPowerPage, 5,18, 10,11, colors.black, colors.black, colors.cyan)
  557. mainPage:add(mainTOoreProcessing, mainToOreProcessingPage, 25,35, 10,11, colors.black, colors.black, colors.cyan)
  558.  
  559. --Add these if the access level is high enough
  560. if (currentUser.access < 3) then
  561. mainPage:add(mainTOae, mainTOaePage, 7,18, 15,16, colors.black, colors.black, colors.cyan)
  562. end
  563. if (currentUser.access < 2) then
  564. mainPage:add(mainTOnuke, mainToNukePage, 26,35, 15,16, colors.black, colors.black, colors.cyan)
  565. end
  566.  
  567. end
  568.  
  569. function mainToAccountPage() t = accountPage end
  570.  
  571. function mainToMystcraftPage() t = mystcraftPage end
  572.  
  573. function mainToPowerPage() t = powerPage end
  574.  
  575. function mainToOreProcessingPage() t=oreProcessingPage end
  576.  
  577. function mainTOaePage() t=aePage end
  578.  
  579. function mainToNukePage() t=nuclearControlPage end
  580.  
  581. --*************************************************END OF ACCOUNT PAGE*************************************************************************
  582.  
  583. --**************************************************START OF ACCOUNT PAGE*****************************************************************
  584.  
  585.  
  586. goBack = {
  587. "<-",
  588. label = "goBackLabel",
  589. }
  590.  
  591. local accountChangePasswordTable = {
  592. "Change your",
  593. " password ",
  594. label = "accountChangePasswordLabel"
  595. }
  596.  
  597. local accountChangeAccessPermissionsTable = {
  598. "Change Access",
  599. " Permissions ",
  600. label = "accountChangeAccessPermissionsLabel",
  601. }
  602.  
  603. local accountCreateNewUserTable = {
  604. " Create a ",
  605. "New Profile",
  606. label = "accountCreateNewUserLabel",
  607. }
  608.  
  609. local accountRemoveUserTable = {
  610. " Remove an ",
  611. "existing user",
  612. label = "accountRemoveUserLabel",
  613. }
  614.  
  615.  
  616.  
  617. function addAccountPage()
  618. accountPagePasswordTable = {
  619. "Password: "..currentUser.password.."",
  620. label = "accountPagePasswordLabel",
  621. }
  622.  
  623. accountPageAccessTable = {
  624. "Access Level: "..currentUser.access,
  625. label = "accountPageAccessLabel",
  626. }
  627.  
  628. accountPage:add(goBack, goBackMain, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  629. accountPage:add("Account Information", nil, 10, 30, 2, 2, colors.black, colors.black, colors.brown)
  630.  
  631. accountPage:add("Name: "..currentUser.name, nil, 2, tonumber(9+currentUser.name:len()), 6, 6, colors.black, colors.black, colors.lightGray)
  632. accountPage:add(accountPagePasswordTable, nil, 3, 25, 8,8, colors.black, colors.black, colors.lightGray)
  633. accountPage:add(accountPageAccessTable, nil, 3, 19, 10, 10, colors.black, colors.black, colors.lightGray)
  634.  
  635. if currentUser.name ~= "guest" then
  636. accountPage:add(accountChangePasswordTable, accountToChangePassword, 5, 15, 13, 14, colors.black, colors.black, colors.cyan)
  637. end
  638. accountPage:add("Log out", logOut, 27, 35, 8, 8, colors.black, colors.black, colors.cyan)
  639.  
  640. if (currentUser.access < 2) then--if highest access level
  641. accountPage:add(accountChangeAccessPermissionsTable, accountToChangeAccessPermissions, 22, 38, 13, 14, colors.black, colors.black, colors.cyan)
  642. accountPage:add(accountCreateNewUserTable, accountToCreateNewUser, 5,15, 17,18, colors.black, colors.black, colors.cyan)
  643. accountPage:add(accountRemoveUserTable, accountToRemoveUser, 22,38, 17,18, colors.black, colors.black, colors.cyan)
  644. end
  645. end
  646.  
  647. function goBackMain()
  648. mainPage = nil
  649. mainPageNotDrawn = true
  650. mainPage = touchpointEdited.new(monitorSide)
  651. t = mainPage
  652. end
  653.  
  654. function logOut() os.reboot() end
  655.  
  656. function accountToChangePassword() t = changePasswordPage end
  657.  
  658. function accountToChangeAccessPermissions() t = changeAccessPage end
  659.  
  660. function accountToCreateNewUser()
  661. if (#profileArray <= 5) then
  662. t = changeAddUserPage
  663. end
  664. end
  665.  
  666. function accountToRemoveUser() t = changeRemoveUserPage end
  667.  
  668.  
  669. --*************************************************END OF ACCOUNT PAGE*******************************************************************
  670.  
  671.  
  672.  
  673. --*************************************************START OF CHANGE PASSWORD PAGE*********************************************************
  674.  
  675.  
  676.  
  677. function addChangePasswordPage()
  678. passkey = "firstEntry"
  679. input = ""
  680. useUppercase = false
  681.  
  682. useNewPassword = true
  683. useConfirmPassword = false
  684. newPasswordConfirmed = false
  685. confirmedPasswordConfirmed = false
  686.  
  687. changePasswordPageCurrentPasswordTable = {
  688. "Your current password is: "..currentUser.password,
  689. label = "changePasswordPageCurrentPasswordLabel",
  690. }
  691.  
  692. newPasswordInputTable = {
  693. " ",
  694. label = "newPasswordInputLabel",
  695. }
  696.  
  697. local changePasswordTitleTable = {
  698. "Please enter your",
  699. "desired password:",
  700. label = "changePasswordTitleLabel",
  701. }
  702.  
  703. changePasswordPage:add(goBack, goBackAccessPage, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  704. changePasswordPage:add("Change Password", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
  705. changePasswordPage:add(changePasswordPageCurrentPasswordTable, nil, 2,35, 5,5, colors.black, colors.black, colors.brown)
  706. changePasswordPage:add(changePasswordTitleTable, nil, 4,39, 8,9, colors.black, colors.black, colors.lightGray)
  707. changePasswordPage:add(ArrowTable, nil, 1, 4, 10, 10, colors.black, colors.black, colors.brown)
  708.  
  709. changePasswordPage:add(newPasswordInputTable, nil, 5, 22, 10, 10, colors.black, colors.black, colors.lightGray)
  710. changePasswordPage:add("Okay", function() confirmNewPassword(passkey) end, 25, 30, 10, 10, colors.black, colors.black, colors.cyan)
  711.  
  712. changePasswordPage:add("1", function() addToPasswordInput("1") end, 5, 5, 14, 14, colors.black, colors.black, colors.lightGray)
  713. changePasswordPage:add("2", function() addToPasswordInput("2") end, 7, 7, 14, 14, colors.black, colors.black, colors.lightGray)
  714. changePasswordPage:add("3", function() addToPasswordInput("3") end, 9, 9, 14, 14, colors.black, colors.black, colors.lightGray)
  715. changePasswordPage:add("4", function() addToPasswordInput("4") end, 11, 11, 14, 14, colors.black, colors.black, colors.lightGray)
  716. changePasswordPage:add("5", function() addToPasswordInput("5") end, 13, 13, 14, 14, colors.black, colors.black, colors.lightGray)
  717. changePasswordPage:add("6", function() addToPasswordInput("6") end, 15, 15, 14, 14, colors.black, colors.black, colors.lightGray)
  718. changePasswordPage:add("7", function() addToPasswordInput("7") end, 17, 17, 14, 14, colors.black, colors.black, colors.lightGray)
  719. changePasswordPage:add("8", function() addToPasswordInput("8") end, 19, 19, 14, 14, colors.black, colors.black, colors.lightGray)
  720. changePasswordPage:add("9", function() addToPasswordInput("9") end, 21, 21, 14, 14, colors.black, colors.black, colors.lightGray)
  721. changePasswordPage:add("0", function() addToPasswordInput("0") end, 23, 23, 14, 14, colors.black, colors.black, colors.lightGray)
  722.  
  723. changePasswordPage:add("Q", function() addToPasswordInput("q") end, 5, 5, 15, 15, colors.black, colors.black, colors.lightGray)
  724. changePasswordPage:add("W", function() addToPasswordInput("w") end, 7, 7, 15, 15, colors.black, colors.black, colors.lightGray)
  725. changePasswordPage:add("E", function() addToPasswordInput("e") end, 9, 9, 15, 15, colors.black, colors.black, colors.lightGray)
  726. changePasswordPage:add("R", function() addToPasswordInput("r") end, 11, 11, 15, 15, colors.black, colors.black, colors.lightGray)
  727. changePasswordPage:add("T", function() addToPasswordInput("t") end, 13, 13, 15, 15, colors.black, colors.black, colors.lightGray)
  728. changePasswordPage:add("Y", function() addToPasswordInput("y") end, 15, 15, 15, 15, colors.black, colors.black, colors.lightGray)
  729. changePasswordPage:add("U", function() addToPasswordInput("u") end, 17, 17, 15, 15, colors.black, colors.black, colors.lightGray)
  730. changePasswordPage:add("I", function() addToPasswordInput("i") end, 19, 19, 15, 15, colors.black, colors.black, colors.lightGray)
  731. changePasswordPage:add("O", function() addToPasswordInput("o") end, 21, 21, 15, 15, colors.black, colors.black, colors.lightGray)
  732. changePasswordPage:add("P", function() addToPasswordInput("p") end, 23, 23, 15, 15, colors.black, colors.black, colors.lightGray)
  733.  
  734. changePasswordPage:add("A", function() addToPasswordInput("a") end, 6, 6, 16, 16, colors.black, colors.black, colors.lightGray)
  735. changePasswordPage:add("S", function() addToPasswordInput("s") end, 8, 8, 16, 16, colors.black, colors.black, colors.lightGray)
  736. changePasswordPage:add("D", function() addToPasswordInput("d") end, 10, 10, 16, 16, colors.black, colors.black, colors.lightGray)
  737. changePasswordPage:add("F", function() addToPasswordInput("f") end, 12, 12, 16, 16, colors.black, colors.black, colors.lightGray)
  738. changePasswordPage:add("G", function() addToPasswordInput("g") end, 14, 14, 16, 16, colors.black, colors.black, colors.lightGray)
  739. changePasswordPage:add("H", function() addToPasswordInput("h") end, 16, 16, 16, 16, colors.black, colors.black, colors.lightGray)
  740. changePasswordPage:add("J", function() addToPasswordInput("j") end, 18, 18, 16, 16, colors.black, colors.black, colors.lightGray)
  741. changePasswordPage:add("K", function() addToPasswordInput("k") end, 20, 20, 16, 16, colors.black, colors.black, colors.lightGray)
  742. changePasswordPage:add("L", function() addToPasswordInput("l") end, 22, 22, 16, 16, colors.black, colors.black, colors.lightGray)
  743.  
  744. changePasswordPage:add("Z", function() addToPasswordInput("z") end, 7, 7, 17, 17, colors.black, colors.black, colors.lightGray)
  745. changePasswordPage:add("X", function() addToPasswordInput("x") end, 9, 9, 17, 17, colors.black, colors.black, colors.lightGray)
  746. changePasswordPage:add("C", function() addToPasswordInput("c") end, 11, 11, 17, 17, colors.black, colors.black, colors.lightGray)
  747. changePasswordPage:add("V", function() addToPasswordInput("v") end, 13, 13, 17, 17, colors.black, colors.black, colors.lightGray)
  748. changePasswordPage:add("B", function() addToPasswordInput("b") end, 15, 15, 17, 17, colors.black, colors.black, colors.lightGray)
  749. changePasswordPage:add("N", function() addToPasswordInput("n") end, 17, 17, 17, 17, colors.black, colors.black, colors.lightGray)
  750. changePasswordPage:add("M", function() addToPasswordInput("m") end, 19, 19, 17, 17, colors.black, colors.black, colors.lightGray)
  751.  
  752. changePasswordPage:add("Shift",function() doPasswordShift() end, 29, 35, 15, 15, colors.cyan, colors.green, colors.white)
  753. changePasswordPage:add("Backspace", function() doPasswordBackspace() end, 26, 39, 17, 17, colors.black, colors.black, colors.cyan)
  754. changePasswordPage:add("Space", function() addToPasswordInput(" ") end, 29, 35, 16, 16, colors.black, colors.black, colors.cyan)
  755.  
  756. end
  757.  
  758. function goBackAccessPage()
  759. accountPage = nil
  760. accountPageNotDrawn = true
  761. accountPage = touchpointEdited.new(monitorSide)
  762. t = accountPage
  763. end
  764.  
  765. function confirmNewPassword(Key)
  766. if (Key == "firstEntry") then
  767.  
  768. print("Changing "..currentUser.name.."'s password to: "..input)
  769. currentUser.password = input
  770. persistence.store(fileName, profileArray)
  771.  
  772. newPasswordTable = {
  773. "Your current password is: "..currentUser.password,
  774. label = "changePasswordPageCurrentPasswordLabel",
  775. }
  776. changePasswordPage:rename("changePasswordPageCurrentPasswordLabel", newPasswordTable)
  777.  
  778. for i = 0, 16 do doPasswordBackspace() end
  779.  
  780. elseif (Key == "confrimEntry") then
  781. print("confirming entry")
  782. end
  783. end
  784.  
  785. function doPasswordShift()
  786. changePasswordPage:toggleButton("Shift")
  787. if (changePasswordPage.buttonList["Shift"].active) then useUppercase = true else useUppercase = false end
  788. end
  789.  
  790. function doPasswordBackspace()
  791. input = input:sub(0, #input-1)
  792. updateChangePasswordOutput(input)
  793. end
  794.  
  795. function updateChangePasswordOutput(input)
  796. input2 = string.rep("*", #input)
  797.  
  798. if (#input < 16) then
  799. input = (input..(string.rep(" ",(16-#input))))
  800. end
  801.  
  802. newInput = {input2, label = "newPasswordInputLabel"}
  803. changePasswordPage:rename("newPasswordInputLabel", newInput, true)
  804. end
  805.  
  806. function addToPasswordInput(char)
  807. if useUppercase then char = char:upper() end
  808. if (#input >= 16) then
  809. input = input:sub(0,16)
  810. else
  811. input = (input..char)
  812. end
  813.  
  814. updateChangePasswordOutput(input)
  815. end
  816.  
  817. --************************************************END OF CHANGE PASSWORD PAGE*************************************************************
  818.  
  819. --***********************************************START OF ADD USER PAGE****************************************************************
  820.  
  821. function addAddUserPage()
  822. local addUserTable1 = {
  823. "1",
  824. label = "addUserLabel1",
  825. }
  826.  
  827. local addUserTable2 = {
  828. "2",
  829. label = "addUserLabel2",
  830. }
  831.  
  832. local addUserTable3 = {
  833. "3",
  834. label = "addUserLabel3",
  835. }
  836.  
  837. local addUserInfoTable = {
  838. "Note: The password will",
  839. " default to 'password' ",
  840. label = "addUserInfoLabel",
  841. }
  842.  
  843. local additionalArrowTable = {
  844. "-->",
  845. label = "additionalArrowLabel",
  846. }
  847.  
  848. local addUserCreateProfileTable = {
  849. "Create",
  850. "Profile",
  851. label = "addUserCreateProfileLabel",
  852. }
  853.  
  854. newUserInputTable = {
  855. " ",
  856. label = "newUserInputLabel",
  857. }
  858.  
  859. useUppercase = false
  860. input = ""
  861. tempNewUserAccess = nil
  862.  
  863. changeAddUserPage:add("Add New User", nil, 5, 35, 2, 2, colors.black, colors.black, colors.brown)
  864. changeAddUserPage:add(addUserInfoTable, nil, 9,22, 4,5, colors.black, colors.black, colors.brown)
  865. changeAddUserPage:add(goBack, goBackAccessPage, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  866.  
  867. changeAddUserPage:add("Enter the desired username:", nil, 3, 33, 10, 10, colors.black, colors.black, colors.lightGray)
  868. changeAddUserPage:add(ArrowTable, nil, 1, 4, 11,11, colors.black, colors.black, colors.brown)
  869. changeAddUserPage:add(newUserInputTable, nil, 5, 22, 11, 11, colors.black, colors.black, colors.lightGray)
  870. changeAddUserPage:add(addUserCreateProfileTable, function() checkValidNewUser() end, 29, 39, 11, 12, colors.black, colors.black, colors.cyan)
  871.  
  872. changeAddUserPage:add("Choose the access level:", nil, 1,33, 7, 7, colors.black, colors.black, colors.lightGray)
  873. changeAddUserPage:add(additionalArrowTable, nil, 1,4, 8, 8, colors.black, colors.black, colors.brown)
  874. changeAddUserPage:add(addUserTable1, function() getNewUserAccessLevel(1) end, 5,5, 8,8, colors.black, colors.black, colors.cyan, colors.green)
  875. changeAddUserPage:add("(highest)", nil, 6,16, 8,8, colors.black, colors.black, colors.brown)
  876. changeAddUserPage:add(addUserTable2, function() getNewUserAccessLevel(2) end, 19,19, 8,8, colors.black, colors.black, colors.cyan, colors.green)
  877. changeAddUserPage:add(addUserTable3, function() getNewUserAccessLevel(3) end, 25,25, 8,8, colors.black, colors.black, colors.cyan, colors.green)
  878. changeAddUserPage:add("(lowest)", nil, 26,35, 8,8, colors.black, colors.black, colors.brown)
  879.  
  880. changeAddUserPage:add("1", function() addToAddUserInput("1") end, 5, 5, 14, 14, colors.black, colors.black, colors.lightGray)
  881. changeAddUserPage:add("2", function() addToAddUserInput("2") end, 7, 7, 14, 14, colors.black, colors.black, colors.lightGray)
  882. changeAddUserPage:add("3", function() addToAddUserInput("3") end, 9, 9, 14, 14, colors.black, colors.black, colors.lightGray)
  883. changeAddUserPage:add("4", function() addToAddUserInput("4") end, 11, 11, 14, 14, colors.black, colors.black, colors.lightGray)
  884. changeAddUserPage:add("5", function() addToAddUserInput("5") end, 13, 13, 14, 14, colors.black, colors.black, colors.lightGray)
  885. changeAddUserPage:add("6", function() addToAddUserInput("6") end, 15, 15, 14, 14, colors.black, colors.black, colors.lightGray)
  886. changeAddUserPage:add("7", function() addToAddUserInput("7") end, 17, 17, 14, 14, colors.black, colors.black, colors.lightGray)
  887. changeAddUserPage:add("8", function() addToAddUserInput("8") end, 19, 19, 14, 14, colors.black, colors.black, colors.lightGray)
  888. changeAddUserPage:add("9", function() addToAddUserInput("9") end, 21, 21, 14, 14, colors.black, colors.black, colors.lightGray)
  889. changeAddUserPage:add("0", function() addToAddUserInput("0") end, 23, 23, 14, 14, colors.black, colors.black, colors.lightGray)
  890.  
  891. changeAddUserPage:add("Q", function() addToAddUserInput("q") end, 5, 5, 15, 15, colors.black, colors.black, colors.lightGray)
  892. changeAddUserPage:add("W", function() addToAddUserInput("w") end, 7, 7, 15, 15, colors.black, colors.black, colors.lightGray)
  893. changeAddUserPage:add("E", function() addToAddUserInput("e") end, 9, 9, 15, 15, colors.black, colors.black, colors.lightGray)
  894. changeAddUserPage:add("R", function() addToAddUserInput("r") end, 11, 11, 15, 15, colors.black, colors.black, colors.lightGray)
  895. changeAddUserPage:add("T", function() addToAddUserInput("t") end, 13, 13, 15, 15, colors.black, colors.black, colors.lightGray)
  896. changeAddUserPage:add("Y", function() addToAddUserInput("y") end, 15, 15, 15, 15, colors.black, colors.black, colors.lightGray)
  897. changeAddUserPage:add("U", function() addToAddUserInput("u") end, 17, 17, 15, 15, colors.black, colors.black, colors.lightGray)
  898. changeAddUserPage:add("I", function() addToAddUserInput("i") end, 19, 19, 15, 15, colors.black, colors.black, colors.lightGray)
  899. changeAddUserPage:add("O", function() addToAddUserInput("o") end, 21, 21, 15, 15, colors.black, colors.black, colors.lightGray)
  900. changeAddUserPage:add("P", function() addToAddUserInput("p") end, 23, 23, 15, 15, colors.black, colors.black, colors.lightGray)
  901.  
  902. changeAddUserPage:add("A", function() addToAddUserInput("a") end, 6, 6, 16, 16, colors.black, colors.black, colors.lightGray)
  903. changeAddUserPage:add("S", function() addToAddUserInput("s") end, 8, 8, 16, 16, colors.black, colors.black, colors.lightGray)
  904. changeAddUserPage:add("D", function() addToAddUserInput("d") end, 10, 10, 16, 16, colors.black, colors.black, colors.lightGray)
  905. changeAddUserPage:add("F", function() addToAddUserInput("f") end, 12, 12, 16, 16, colors.black, colors.black, colors.lightGray)
  906. changeAddUserPage:add("G", function() addToAddUserInput("g") end, 14, 14, 16, 16, colors.black, colors.black, colors.lightGray)
  907. changeAddUserPage:add("H", function() addToAddUserInput("h") end, 16, 16, 16, 16, colors.black, colors.black, colors.lightGray)
  908. changeAddUserPage:add("J", function() addToAddUserInput("j") end, 18, 18, 16, 16, colors.black, colors.black, colors.lightGray)
  909. changeAddUserPage:add("K", function() addToAddUserInput("k") end, 20, 20, 16, 16, colors.black, colors.black, colors.lightGray)
  910. changeAddUserPage:add("L", function() addToAddUserInput("l") end, 22, 22, 16, 16, colors.black, colors.black, colors.lightGray)
  911.  
  912. changeAddUserPage:add("Z", function() addToAddUserInput("z") end, 7, 7, 17, 17, colors.black, colors.black, colors.lightGray)
  913. changeAddUserPage:add("X", function() addToAddUserInput("x") end, 9, 9, 17, 17, colors.black, colors.black, colors.lightGray)
  914. changeAddUserPage:add("C", function() addToAddUserInput("c") end, 11, 11, 17, 17, colors.black, colors.black, colors.lightGray)
  915. changeAddUserPage:add("V", function() addToAddUserInput("v") end, 13, 13, 17, 17, colors.black, colors.black, colors.lightGray)
  916. changeAddUserPage:add("B", function() addToAddUserInput("b") end, 15, 15, 17, 17, colors.black, colors.black, colors.lightGray)
  917. changeAddUserPage:add("N", function() addToAddUserInput("n") end, 17, 17, 17, 17, colors.black, colors.black, colors.lightGray)
  918. changeAddUserPage:add("M", function() addToAddUserInput("m") end, 19, 19, 17, 17, colors.black, colors.black, colors.lightGray)
  919.  
  920. changeAddUserPage:add("Shift",function() doAddUserShift() end, 29, 35, 15, 15, colors.cyan, colors.green, colors.white)
  921. changeAddUserPage:add("Backspace", function() doAddUserBackspace() end, 26, 39, 17, 17, colors.black, colors.black, colors.cyan)
  922. changeAddUserPage:add("Space", function() addToAddUserInput(" ") end, 29, 35, 16, 16, colors.black, colors.black, colors.cyan)
  923.  
  924. end
  925.  
  926.  
  927. function addToAddUserInput(char)
  928. if useUppercase then char = char:upper() end
  929. if (#input >= 16) then
  930. input = input:sub(0,16)
  931. else
  932. input = (input..char)
  933. end
  934. updateAddUserOutput(input)
  935. end
  936.  
  937. function getNewUserAccessLevel(num)
  938. if (num == 1) then
  939. changeAddUserPage:toggleButton("addUserLabel1")
  940. if changeAddUserPage.buttonList["addUserLabel1"].active then
  941. tempNewUserAccess = num
  942. end
  943. if changeAddUserPage.buttonList["addUserLabel2"].active then changeAddUserPage:toggleButton("addUserLabel2") end
  944. if changeAddUserPage.buttonList["addUserLabel3"].active then changeAddUserPage:toggleButton("addUserLabel3") end
  945. elseif (num == 2) then
  946. changeAddUserPage:toggleButton("addUserLabel2")
  947. if changeAddUserPage.buttonList["addUserLabel2"].active then
  948. tempNewUserAccess = num
  949. end
  950. if changeAddUserPage.buttonList["addUserLabel1"].active then changeAddUserPage:toggleButton("addUserLabel1") end
  951. if changeAddUserPage.buttonList["addUserLabel3"].active then changeAddUserPage:toggleButton("addUserLabel3") end
  952. elseif (num == 3) then
  953. changeAddUserPage:toggleButton("addUserLabel3")
  954. if changeAddUserPage.buttonList["addUserLabel3"].active then
  955. tempNewUserAccess = num
  956. end
  957. if changeAddUserPage.buttonList["addUserLabel2"].active then changeAddUserPage:toggleButton("addUserLabel2") end
  958. if changeAddUserPage.buttonList["addUserLabel1"].active then changeAddUserPage:toggleButton("addUserLabel1") end
  959. end
  960. end
  961.  
  962. function doAddUserShift()
  963. changeAddUserPage:toggleButton("Shift")
  964. if (changeAddUserPage.buttonList["Shift"].active) then useUppercase = true else useUppercase = false end
  965. end
  966.  
  967. function doAddUserBackspace()
  968. input = input:sub(0, #input-1)
  969. updateAddUserOutput(input)
  970. end
  971.  
  972. function updateAddUserOutput(input)
  973. if (#input < 16) then
  974. input = (input..(string.rep(" ",(16-#input))))
  975. end
  976.  
  977. newInput = {input, label = "newUserInputLabel"}
  978. changeAddUserPage:rename("newUserInputLabel", newInput, true)
  979. end
  980.  
  981. function checkValidNewUser()
  982. if (tempNewUserAccess ~= nil) and (input ~= "") then
  983. profileArray[#profileArray+1] = (Profile.create(input, "password", tempNewUserAccess))
  984. persistence.store(fileName, profileArray)
  985. for i = 0, 16 do doAddUserBackspace() end
  986. if changeAddUserPage.buttonList["addUserLabel1"].active then changeAddUserPage:toggleButton("addUserLabel1") end
  987. if changeAddUserPage.buttonList["addUserLabel2"].active then changeAddUserPage:toggleButton("addUserLabel2") end
  988. if changeAddUserPage.buttonList["addUserLabel3"].active then changeAddUserPage:toggleButton("addUserLabel3") end
  989. goBackAccessPage()
  990. useUppercase = false
  991. input = ""
  992. tempNewUserAccess = nil
  993. end
  994. end
  995.  
  996.  
  997.  
  998. --***********************************************END OF ADD USER PAGE********************************************************************
  999.  
  1000. --***********************************************START OF REMOVE USER PAGE****************************************************************
  1001.  
  1002. function addRemoveUserPage()
  1003. local RemoveUsertitleTable = {
  1004. "Name: Access Level:",
  1005. label = "RemoveUsertitleLabel",
  1006. }
  1007.  
  1008. changeRemoveUserPage:add(goBack, goBackAccessPage3, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  1009. changeRemoveUserPage:add("Remove Users", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
  1010. changeRemoveUserPage:add(RemoveUsertitleTable, nil, 8,30, 5,5, colors.black, colors.black, colors.brown)
  1011. yposAccess = 7
  1012. tableYPOSspot = 1
  1013. for key, value in ipairs(profileArray) do
  1014.  
  1015. local accessValueTable = {
  1016. value.access,
  1017. label = tostring(yposAccess),
  1018. }
  1019.  
  1020. local removeTable = {
  1021. "Remove",
  1022. label = tostring(yposAccess).."remove",
  1023. }
  1024.  
  1025. changeRemoveUserPage:add(value.name, nil, 3,19, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
  1026. changeRemoveUserPage:add(accessValueTable, nil, 25,26, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
  1027. -- changeRemoveUserPage:add(removeTable, function() removeUsers(key) end, 30,30, yposAccess,yposAccess, colors.black, colors.black, colors.red)
  1028. changeRemoveUserPage:add(removeTable, function() removeUsers(key) end, 30,35, yposAccess,yposAccess, colors.black, colors.black, colors.red)
  1029.  
  1030. yposAccess = yposAccess + 2
  1031. end
  1032. end
  1033.  
  1034. function goBackAccessPage3()
  1035. changeRemoveUserPage = nil
  1036. changeRemoveUserPageNotDrawn = true
  1037. changeRemoveUserPage = touchpointEdited.new(monitorSide)
  1038. accountPage = nil
  1039. accountPageNotDrawn = true
  1040. accountPage = touchpointEdited.new(monitorSide)
  1041. t = accountPage
  1042. end
  1043.  
  1044. function testPrint()
  1045. print("Testing debug")
  1046. end
  1047.  
  1048. function removeUsers(aPos)
  1049. print("Removing "..profileArray[aPos].name)
  1050. -- profileArray[aPos] = nil
  1051. table.remove(profileArray, aPos)
  1052.  
  1053. persistence.store(fileName, profileArray)
  1054. changeRemoveUserPage = nil
  1055. changeRemoveUserPageNotDrawn = true
  1056. changeRemoveUserPage = touchpointEdited.new(monitorSide)
  1057. t = changeRemoveUserPage
  1058. end
  1059.  
  1060.  
  1061.  
  1062.  
  1063. --***********************************************END OF REMOVE USER PAGE********************************************************************
  1064.  
  1065. --***********************************************START OF CHANGE ACCESS PERMISSIONS*******************************************************
  1066.  
  1067. function addAccessPermissionsPage()
  1068. local AccesstitleTable = {
  1069. "Name: Access Level:",
  1070. label = "AccesstitleLabel",
  1071. }
  1072.  
  1073. changeAccessPage:add(goBack, goBackAccessPage2, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  1074. changeAccessPage:add("Access Permissions", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
  1075. changeAccessPage:add(AccesstitleTable, nil, 8,30, 5,5, colors.black, colors.black, colors.brown)
  1076. yposAccess = 7
  1077. tableYPOSspot = 1
  1078. for key, value in ipairs(profileArray) do
  1079. local accessValueTable = {
  1080. value.access,
  1081. label = tostring(yposAccess),
  1082. }
  1083. local minusTable = {
  1084. "-",
  1085. label = tostring(yposAccess).."-",
  1086. }
  1087. local plusTable = {
  1088. "+",
  1089. label = tostring(yposAccess).."+",
  1090. }
  1091. changeAccessPage:add(value.name, nil, 3,19, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
  1092. changeAccessPage:add(accessValueTable, nil, 25,26, yposAccess,yposAccess, colors.black, colors.black, colors.lightGray)
  1093. if value.access > 1 then changeAccessPage:add(minusTable, function() accessChange("minus", key) end, 30,30, yposAccess,yposAccess, colors.black, colors.black, colors.cyan) end
  1094. if value.access < 3 then changeAccessPage:add(plusTable, function() accessChange("plus", key) end, 32,32, yposAccess,yposAccess, colors.black, colors.black, colors.cyan) end
  1095.  
  1096. yposAccess = yposAccess + 2
  1097. end
  1098. end
  1099.  
  1100. function goBackAccessPage2()
  1101. changeAccessPage = nil
  1102. changeAccessPageNotDrawn = true
  1103. changeAccessPage = touchpointEdited.new(monitorSide)
  1104. accountPage = nil
  1105. accountPageNotDrawn = true
  1106. accountPage = touchpointEdited.new(monitorSide)
  1107. t = accountPage
  1108. end
  1109.  
  1110. function accessChange(str, aPos)
  1111. if str == "plus" then
  1112. profileArray[aPos].access = profileArray[aPos].access + 1
  1113. elseif str == "minus" then
  1114. profileArray[aPos].access = profileArray[aPos].access - 1
  1115. end
  1116. persistence.store(fileName, profileArray)
  1117. changeAccessPage = nil
  1118. changeAccessPageNotDrawn = true
  1119. changeAccessPage = touchpointEdited.new(monitorSide)
  1120. t = changeAccessPage
  1121. end
  1122.  
  1123. --***********************************************END OF CHANGE ACCESS PERMISSIONS*********************************************************
  1124.  
  1125. --***********************************************START OF MYSTCRAFT PAGE******************************************************************
  1126.  
  1127. refreshPage = {
  1128. "R",
  1129. label = "refreshPageLabel",
  1130. }
  1131.  
  1132. function addMystcraftPage()
  1133. rednet.send(mystcraftTurtleID, "Get Names")
  1134. local id, msg = rednet.receive()
  1135. if id == mystcraftTurtleID then
  1136. mystNameTable = textutils.unserialize(msg)
  1137. mystcraftPage:add("Mystcraft Controls", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
  1138. mystcraftPage:add(goBack, goBackMain2, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  1139. mystcraftPage:add(refreshPage, refreshMyst, 38,38, 2,2, colors.black, colors.black, colors.cyan)
  1140. if (msg == "{}") then
  1141. mystcraftPage:add("There are no linking books!", nil, 5,33, 5,5, colors.black, colors.black, colors.lightGray)
  1142. else
  1143. yPosStart = 5
  1144. if #mystNameTable < 8 then
  1145. for i=1, #mystNameTable do
  1146. mystScreenXPos = ((20) - ((8 + #mystNameTable[i])/2))
  1147. mystcraftPage:add(mystNameTable[i], function() activateMyst(mystNameTable[i], i) end, math.floor(mystScreenXPos),math.floor((mystScreenXPos)+(9+#mystNameTable[i])), yPosStart,yPosStart, colors.black, colors.black, colors.cyan, colors.green)
  1148. yPosStart = yPosStart + 2
  1149. end
  1150. else
  1151. for i=1, 7 do
  1152. if (4+#mystNameTable[i]) > 20 then endYpos = 20 else endYpos = (4+#mystNameTable[i]) end
  1153. mystcraftPage:add(mystNameTable[i], function() activateMyst(mystNameTable[i], i) end, 3,endYpos, yPosStart,yPosStart, colors.black, colors.black, colors.cyan, colors.green)
  1154. yPosStart = yPosStart + 2
  1155. end
  1156. yPosStart = 5
  1157. for i=8, #mystNameTable do
  1158. if i < 16 then
  1159. if (23+#mystNameTable[i]) > 39 then endYpos = 39 else endYpos = (23+#mystNameTable[i]) end
  1160. mystcraftPage:add(mystNameTable[i], function() activateMyst(mystNameTable[i], i) end, 21,endYpos, yPosStart,yPosStart, colors.black, colors.black, colors.cyan, colors.green)
  1161. yPosStart = yPosStart + 2
  1162. end
  1163. end
  1164. end
  1165. end
  1166. end
  1167. end
  1168.  
  1169. function goBackMain2()
  1170. mystcraftPage = nil
  1171. mystcraftPageNotDrawn = true
  1172. mystcraftPage = touchpointEdited.new(monitorSide)
  1173. t = mainPage
  1174. end
  1175.  
  1176. function activateMyst(pageName, indexMyst)
  1177. mystcraftPage:toggleButton(pageName)
  1178. rednet.send(mystcraftTurtleID, indexMyst)
  1179. sleep(4)
  1180. mystcraftPage:toggleButton(pageName)
  1181. end
  1182.  
  1183. function refreshMyst()
  1184. mystcraftPage = nil
  1185. mystcraftPage = touchpointEdited.new(monitorSide)
  1186. t = mystcraftPage
  1187. addMystcraftPage()
  1188. end
  1189.  
  1190.  
  1191.  
  1192. --***********************************************END OF MYSTCRAFT PAGE*******************************************************************
  1193.  
  1194.  
  1195. --**********************************************START OF POWER INFORMATION***************************************************************
  1196. function addPowerPage()
  1197. rednet.send(tankComputerID, "getBiomassAmt")
  1198. local id, msg = rednet.receive()
  1199. if id == tankComputerID then
  1200. local tankData = textutils.unserialize(msg)
  1201. biomassAmt = tankData[1]
  1202. biomassTotal = tankData[2]
  1203. end
  1204.  
  1205. rednet.send(AEcomputerID, "getItemAmts")
  1206. local id, msg = rednet.receive()
  1207. if id == AEcomputerID then
  1208. local aeData = textutils.unserialize(msg)
  1209. sugarAmt = aeData[1]
  1210. netherStarAmt = aeData[2]
  1211. aeIsOn = aeData[3]
  1212. end
  1213.  
  1214. rednet.send(powerComputerID, "getPower")
  1215. local id, msg = rednet.receive()
  1216. if id == powerComputerID then
  1217. local powerData = textutils.unserialize(msg)
  1218. powerPercent = powerData[1]
  1219. powerTotal = powerData[2]
  1220. powerMax = powerData[3]
  1221. end
  1222.  
  1223. powerPage:add("Power Information", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
  1224. powerPage:add(goBack, goBackMain4, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  1225. powerPage:add(refreshPage, refreshPower, 38,38, 2,2, colors.black, colors.black, colors.cyan)
  1226.  
  1227. if aeIsOn then
  1228. local centeredTxt = math.floor(10-(#tostring(sugarAmt)/2))
  1229. powerPage:add(tostring(sugarAmt), nil, centeredTxt,centeredTxt+(#tostring(sugarAmt)+1), 17,17, colors.black, colors.black, colors.lightGray)
  1230. powerPage:add("sugarcane left", nil, 2,20, 18,18, colors.black, colors.black, colors.lightGray)
  1231. else
  1232. powerPage:add("AE is off", nil, 2,18, 17,17, colors.black, colors.black, colors.lightGray)
  1233. end
  1234.  
  1235. powerPage:add("Sugarcane Power", nil, 2,20, 5,5, colors.black, colors.black, colors.lime)
  1236. if biomassAmt ~= nil then
  1237. biomassPercent = ((biomassAmt/biomassTotal)*100)
  1238. biomassAmt = tostring(biomassAmt)
  1239. if biomassAmt:len() < 4 then biomassAmt = 0 end
  1240. biomassAmt = biomassAmt:sub(1, (biomassAmt:len()-3))
  1241. else
  1242. biomassAmt = 0
  1243. biomassPercent = 0
  1244. end
  1245.  
  1246. if powerPercent == nil then
  1247. powerPercent = 0.00
  1248. end
  1249.  
  1250. local biomassTable1 = {
  1251. " ",
  1252. label = "biomassLabel1",
  1253. }
  1254.  
  1255. local biomassTable2 = {
  1256. " ",
  1257. label = "biomassLabel2",
  1258. }
  1259.  
  1260. local biomassTable3 = {
  1261. " full ",
  1262. label = "biomassLabel3",
  1263. }
  1264.  
  1265. local biomassTable4 = {
  1266. " ",
  1267. label = "biomassLabel4",
  1268. }
  1269.  
  1270. local biomassTable5 = {
  1271. " ",
  1272. label = "biomassLabel5",
  1273. }
  1274.  
  1275. local edgeTable1 = {
  1276. "|",
  1277. label = "edgeLabel1",
  1278. }
  1279.  
  1280. local edgeTable2 = {
  1281. "|",
  1282. label = "edgeLabel2",
  1283. }
  1284.  
  1285. local edgeTable3 = {
  1286. "|",
  1287. label = "edgeLabel3",
  1288. }
  1289.  
  1290. local edgeTable4 = {
  1291. "|",
  1292. label = "edgeLabel4",
  1293. }
  1294.  
  1295. local edgeTable5 = {
  1296. "|",
  1297. label = "edgeLabel5",
  1298. }
  1299.  
  1300. local edgeTable6 = {
  1301. "|",
  1302. label = "edgeLabel6",
  1303. }
  1304.  
  1305. local edgeTable7 = {
  1306. "|",
  1307. label = "edgeLabel7",
  1308. }
  1309.  
  1310. local edgeTable8 = {
  1311. "|",
  1312. label = "edgeLabel8",
  1313. }
  1314.  
  1315. local edgeTable8 = {
  1316. "|",
  1317. label = "edgeLabel8",
  1318. }
  1319.  
  1320. local edgeTable10 = {
  1321. "|",
  1322. label = "edgeLabel10",
  1323. }
  1324.  
  1325. local edgeTable11 = {
  1326. "|",
  1327. label = "edgeLabel11",
  1328. }
  1329.  
  1330. local edgeTable12 = {
  1331. "|",
  1332. label = "edgeLabel12",
  1333. }
  1334.  
  1335. local edgeTable13 = {
  1336. "|",
  1337. label = "edgeLabel13",
  1338. }
  1339.  
  1340. local edgeTable9 = {
  1341. "'--------'",
  1342. label = "edgeLabel9",
  1343. }
  1344.  
  1345. powerPage:add(".________.", nil, 5,16, 8,8, colors.black, colors.black, colors.lightGray)
  1346.  
  1347. powerPage:add(edgeTable1, nil, 6,6, 9,9, colors.black, colors.black, colors.lightGray)
  1348. powerPage:add(edgeTable2, nil, 15,15, 9,9, colors.black, colors.black, colors.lightGray)
  1349. powerPage:add(edgeTable3, nil, 6,6, 10,10, colors.black, colors.black, colors.lightGray)
  1350. powerPage:add(edgeTable4, nil, 15,15, 10,10, colors.black, colors.black, colors.lightGray)
  1351. powerPage:add(edgeTable5, nil, 6,6, 11,11, colors.black, colors.black, colors.lightGray)
  1352. powerPage:add(edgeTable6, nil, 15,15, 11,11, colors.black, colors.black, colors.lightGray)
  1353. powerPage:add(edgeTable7, nil, 6,6, 12,12, colors.black, colors.black, colors.lightGray)
  1354. powerPage:add(edgeTable8, nil, 15,15, 12,12, colors.black, colors.black, colors.lightGray)
  1355. powerPage:add(edgeTable10, nil, 6,6, 13,13, colors.black, colors.black, colors.lightGray)
  1356. powerPage:add(edgeTable11, nil, 15,15, 13,13, colors.black, colors.black, colors.lightGray)
  1357. powerPage:add(edgeTable12, nil, 6,6, 14,14, colors.black, colors.black, colors.lightGray)
  1358. powerPage:add(edgeTable13, nil, 15,15, 14,14, colors.black, colors.black, colors.lightGray)
  1359.  
  1360. powerPage:add(edgeTable9, nil, 6,15, 15,15, colors.black, colors.black, colors.lightGray)
  1361.  
  1362. powerPage:add("Biomass: "..biomassAmt.."b", nil, 3,(3+tostring(biomassAmt):len()+11), 7,7, colors.black, colors.black, colors.lightGray)
  1363.  
  1364. if biomassPercent >= 92 then
  1365. powerPage:add(biomassTable1, nil, 7,14, 9,9, colors.black, colors.green, colors.green, colors.gray, true)
  1366. else
  1367. powerPage:add(biomassTable1, nil, 7,14, 9,9, colors.lightGray, colors.black, colors.gray, colors.green)
  1368. end
  1369.  
  1370. if biomassPercent >= 76 then
  1371. powerPage:add(biomassTable2, nil, 7,14, 10,10, colors.black, colors.green, colors.green, colors.gray, true)
  1372. else
  1373. powerPage:add(biomassTable2, nil, 7,14, 10,10, colors.black, colors.lightGray, colors.green, colors.gray, true)
  1374. end
  1375.  
  1376. biomassPercentFinal = (math.floor(biomassPercent*math.pow(10,2)+.5)/math.pow(10,2))
  1377. biomassPercent2 = string.format("%2.1f", tostring(biomassPercentFinal))
  1378. biomassPercent2 = biomassPercent2:sub(1, -2)
  1379. if biomassPercent >= 60 then
  1380. powerPage:add(" "..biomassPercent2.."% ", nil, 7,14, 11,11, colors.black, colors.green, colors.lightGray, colors.white, true)
  1381. else
  1382. powerPage:add(" "..biomassPercent2.."% ", nil, 7,14, 11,11, colors.black, colors.lightGray, colors.green, colors.gray, true)
  1383. end
  1384.  
  1385. if biomassPercent >= 44 then
  1386. powerPage:add(biomassTable3, nil, 7,14, 12,12, colors.black, colors.green, colors.lightGray, colors.white, true)
  1387. else
  1388. powerPage:add(biomassTable3, nil, 7,14, 12,12, colors.black, colors.lightGray, colors.green, colors.gray, true)
  1389. end
  1390.  
  1391. if biomassPercent >= 28 then
  1392. powerPage:add(biomassTable4, nil, 7,14, 13,13, colors.black, colors.green, colors.green, colors.gray, true)
  1393. else
  1394. powerPage:add(biomassTable4, nil, 7,14, 13,13, colors.black, colors.lightGray, colors.green, colors.gray, true)
  1395. end
  1396.  
  1397. if biomassPercent >= 12 then
  1398. powerPage:add(biomassTable5, nil, 7,14, 14,14, colors.black, colors.green, colors.green, colors.gray, true)
  1399. else
  1400. powerPage:add(biomassTable5, nil, 7,14, 14,14, colors.black, colors.lightGray, colors.green, colors.gray, true)
  1401. end
  1402.  
  1403. --************************************************END OF SUGARCANE/START OF POWER*************************************
  1404.  
  1405. powerPage:add("Energy Cells", nil, 21,38, 5,5, colors.black, colors.black, colors.red)
  1406.  
  1407. local powerEdgeTable1 = {
  1408. " ",
  1409. label = "powerEdgeLabel1",
  1410. }
  1411.  
  1412. local powerEdgeTable2 = {
  1413. " ",
  1414. label = "powerEdgeLabel2",
  1415. }
  1416.  
  1417. local powerEdgeTable3 = {
  1418. " ",
  1419. label = "powerEdgeLabel3",
  1420. }
  1421.  
  1422. local powerEdgeTable4 = {
  1423. " ",
  1424. label = "powerEdgeLabel4",
  1425. }
  1426.  
  1427. local powerEdgeTable5 = {
  1428. " ",
  1429. label = "powerEdgeLabel5",
  1430. }
  1431.  
  1432. local powerEdgeTable6 = {
  1433. " ",
  1434. label = "powerEdgeLabel6",
  1435. }
  1436.  
  1437. local powerEdgeTable7 = {
  1438. " ",
  1439. label = "powerEdgeLabel7",
  1440. }
  1441.  
  1442. local powerEdgeTable8 = {
  1443. " ",
  1444. label = "powerEdgeLabel8",
  1445. }
  1446.  
  1447. local powerEdgeTable9 = {
  1448. " ",
  1449. label = "powerEdgeLabel9",
  1450. }
  1451.  
  1452. local powerEdgeTable10 = {
  1453. " ",
  1454. label = "powerEdgeLabel10",
  1455. }
  1456.  
  1457. local powerEdgeTable11 = {
  1458. " ",
  1459. label = "powerEdgeLabel11",
  1460. }
  1461.  
  1462. local powerEdgeTable12 = {
  1463. " ",
  1464. label = "powerEdgeLabel12",
  1465. }
  1466.  
  1467. local powerEdgeTable13 = {
  1468. " ",
  1469. label = "powerEdgeLabel13",
  1470. }
  1471.  
  1472. local powerTable1 = {
  1473. " ",
  1474. label = "powerLabel1",
  1475. }
  1476.  
  1477. powerPercent2 = string.format("%4.1f", tostring(powerPercent))
  1478. powerAddonMid = string.rep(" ",(5-tostring(powerPercent2):len()))
  1479. local powerTable2 = {
  1480. " "..powerPercent2.."%"..powerAddonMid,
  1481. label = "powerLabel2",
  1482. }
  1483.  
  1484. local powerTable3 = {
  1485. " full ",
  1486. label = "powerLabel3",
  1487. }
  1488.  
  1489. local powerTable4 = {
  1490. " ",
  1491. label = "powerLabel4",
  1492. }
  1493.  
  1494. local powerTable5 = {
  1495. " ",
  1496. label = "powerLabel5",
  1497. }
  1498.  
  1499. local colorToUse
  1500. if powerTotal <= 400000 then
  1501. colorToUse = colors.combine(colors.white, colors.lightBlue, colors.white, colors.white, colors.lightBlue)
  1502. elseif powerTotal <= 2000000 then
  1503. colorToUse = colors.combine(colors.white, colors.lightGray, colors.white, colors.white, colors.white)
  1504. elseif powerTotal <= 10000000 then
  1505. colorToUse = colors.combine(colors.yellow, colors.white, colors.orange)
  1506. else
  1507. colorToUse = colors.cyan
  1508. end
  1509.  
  1510. powerPage:add(" ", nil, 26,32, 9,9, colorToUse)
  1511. powerPage:add(powerEdgeTable1, nil, 25,25, 9,9, colors.orange)
  1512. powerPage:add(powerEdgeTable2, nil, 33,33, 9,9, colors.orange)
  1513. powerPage:add(powerEdgeTable3, nil, 25,25, 10,10, colorToUse)
  1514. powerPage:add(powerEdgeTable4, nil, 33,33, 10,10, colorToUse)
  1515. powerPage:add(powerEdgeTable5, nil, 25,25, 11,11, colorToUse)
  1516. powerPage:add(powerEdgeTable6, nil, 33,33, 11,11, colorToUse)
  1517. powerPage:add(powerEdgeTable7, nil, 25,25, 12,12, colorToUse)
  1518. powerPage:add(powerEdgeTable8, nil, 33,33, 12,12, colorToUse)
  1519. powerPage:add(powerEdgeTable9, nil, 25,25, 13,13, colorToUse)
  1520. powerPage:add(powerEdgeTable10, nil, 33,33, 13,13, colorToUse)
  1521. powerPage:add(powerEdgeTable11, nil, 25,25, 14,14, colors.orange)
  1522. powerPage:add(powerEdgeTable12, nil, 33,33, 14,14, colors.orange)
  1523. powerPage:add(powerEdgeTable13, nil, 26,32, 14,14, colorToUse)
  1524.  
  1525. if powerPercent >= 95 then
  1526. powerPage:add(powerTable1, nil, 26,32, 10,10, colors.black, colors.red, colors.black, colors.black, true)
  1527. end
  1528.  
  1529. if powerPercent >= 65 then
  1530. powerPage:add(powerTable2, nil, 26,32, 11,11, colors.black, colors.red, colors.white, colors.white, true)
  1531. else
  1532. powerPage:add(powerTable2, nil, 26,32, 11,11, colors.black, colors.black, colors.lightGray)
  1533. end
  1534.  
  1535. if powerPercent >= 35 then
  1536. powerPage:add(powerTable3, nil, 26,32, 12,12, colors.black, colors.red, colors.white, colors.white, true)
  1537. else
  1538. powerPage:add(powerTable3, nil, 26,32, 12,12, colors.black, colors.black, colors.lightGray)
  1539. end
  1540.  
  1541. if powerPercent >= 5 then
  1542. powerPage:add(powerTable4, nil, 26,32, 13,13, colors.black, colors.red, colors.black, colors.black, true)
  1543. end
  1544.  
  1545. if powerTotal < 999 then
  1546. usePowerNormal = true
  1547. usePowerThousands = false
  1548. usePowerMillions = false
  1549. else
  1550. if powerTotal < 999500 then
  1551. powerTotal = tostring(powerTotal):sub(1, -4).."."..tostring(powerTotal):sub(-3,-3)
  1552. usePowerNormal = false
  1553. usePowerThousands = true
  1554. usePowerMillions = false
  1555. else
  1556. powerTotal = tostring(powerTotal):sub(1, -7).."."..tostring(powerTotal):sub(-6,-6)
  1557. usePowerNormal = false
  1558. usePowerThousands = false
  1559. usePowerMillions = true
  1560. end
  1561.  
  1562. end
  1563.  
  1564. if usePowerNormal then
  1565. powerAddon = " RF"
  1566. elseif usePowerThousands then
  1567. powerAddon = "k RF"
  1568. elseif usePowerMillions then
  1569. powerAddon = "m RF"
  1570. end
  1571.  
  1572. local centeredPowerTxt = math.floor(27-((#tostring(powerTotal)+(#tostring(powerAddon))/2)))
  1573. powerPage:add("Power: "..powerTotal..powerAddon, nil, centeredPowerTxt,centeredPowerTxt+(tostring(powerTotal):len()+8+powerAddon:len()), 7,7, colors.black, colors.black, colors.lightGray)
  1574.  
  1575. if aeIsOn then
  1576. local centeredTxt = math.floor(29-(#tostring(netherStarAmt)/2))
  1577. powerPage:add(tostring(netherStarAmt), nil, centeredTxt,centeredTxt+(#tostring(netherStarAmt)+1), 17,17, colors.black, colors.black, colors.lightGray)
  1578. powerPage:add("nether stars left", nil, 21,39, 18,18, colors.black, colors.black, colors.lightGray)
  1579. else
  1580. local aePowerTable = {
  1581. "AE is off",
  1582. label = "aepowerlabel",
  1583. }
  1584. powerPage:add(aePowerTable, nil, 25,36, 17,17, colors.black, colors.black, colors.lightGray)
  1585. end
  1586.  
  1587. end
  1588.  
  1589. function refreshPower()
  1590. powerPage = nil
  1591. powerPage = touchpointEdited.new(monitorSide)
  1592. t = powerPage
  1593. addPowerPage()
  1594. end
  1595.  
  1596. function goBackMain4()
  1597. powerPage = nil
  1598. powerPageNotDrawn = true
  1599. powerPage = touchpointEdited.new(monitorSide)
  1600. t = mainPage
  1601. end
  1602. --**********************************************END OF POWER INFORMATION***************************************************************
  1603.  
  1604.  
  1605. --**********************************************START OF ORE PROCESSING*****************************************************************
  1606. oreProcessingPage:add("NOT YET IMPLEMETED", nil, 10,30, 8,8, colors.black, colors.black, colors.red)
  1607. oreProcessingPage:add(goBack, goBackMain, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  1608. --**********************************************END OF ORE PROCESSING***************************************************************
  1609.  
  1610.  
  1611. --**********************************************START OF AE CONTROL*****************************************************************
  1612. function addAEpage()
  1613. rednet.send(AEcomputerID, "getAEData")
  1614. local id, msg = rednet.receive()
  1615. if id == AEcomputerID then
  1616. local AEdataTable = msg --textutils.unserialize(msg)
  1617. local AEon = AEdataTable[1]
  1618. local AEpercentBytes = AEdataTable[2]
  1619. local AEusedBytes = AEdataTable[3]
  1620. local AEtotalBytes = AEdataTable[4]
  1621. local AEpercentTypes = AEdataTable[5]
  1622. local AEusedTypes = AEdataTable[6]
  1623. local AEtotalTypes = AEdataTable[7]
  1624.  
  1625. aePage:add("Applied Energistics", nil, 10,30, 2,2, colors.black, colors.black, colors.brown)
  1626. aePage:add(goBack, goBackMain3, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  1627. aePage:add(refreshPage, refreshAE, 38,38, 2,2, colors.black, colors.black, colors.cyan)
  1628.  
  1629. aePage:add("The AE system is ", nil, 11,28, 5,5, colors.black, colors.black, colors.lightGray)
  1630. if AEon then
  1631. aePage:add("on", nil, 17,23, 6,6, colors.black, colors.black, colors.green)
  1632. aePage:add("Turn it off", changeAEPower, 13,25, 8,8, colors.black, colors.black, colors.cyan)
  1633.  
  1634. local median = (math.floor(((AEpercentBytes+AEpercentTypes)/2)*math.pow(10,2)+.5)/math.pow(10,2))
  1635. for i = 0,1 do
  1636. if tostring(AEpercentTypes):len() < 4 then AEpercentTypes = tostring(AEpercentTypes).."0" end
  1637. if tostring(AEpercentBytes):len() < 4 then AEpercentBytes = tostring(AEpercentBytes).."0" end
  1638. if tostring(median):len() < 4 then median = tostring(median).."0" end
  1639. end
  1640. aePage:add("The AE system is", nil, 9,30, 12,12, colors.black, colors.black, colors.lightGray)
  1641. aePage:add("about "..median.."% full", nil, 9,30, 13,13, colors.black, colors.black, colors.lightGray)
  1642.  
  1643.  
  1644. local bytesLen = 14+tostring(AEusedBytes):len()+tostring(AEtotalBytes):len()+2
  1645. local bytesString = "Bytes Used: "..AEusedBytes.."/"..AEtotalBytes
  1646. if bytesLen > 27 then bytesString = bytesString:sub(0,27) end
  1647. aePage:add(bytesString, nil, 2,bytesLen, 16,16, colors.black, colors.black, colors.lightGray)
  1648.  
  1649. local typesLen = 14+tostring(AEusedTypes):len()+tostring(AEtotalTypes):len()+2
  1650. local typesString = "Types Used: "..AEusedTypes.."/"..AEtotalTypes
  1651. if typesLen > 27 then typesString = typesString:sub(0,27) end
  1652. aePage:add(typesString, nil, 2,typesLen, 17,17, colors.black, colors.black, colors.lightGray)
  1653.  
  1654. aePage:add("("..AEpercentBytes.."%)", nil, 30,38, 16,16, colors.black, colors.black, colors.lightGray)
  1655. aePage:add("("..AEpercentTypes.."%)", nil, 30,38, 17,17, colors.black, colors.black, colors.lightGray)
  1656.  
  1657. else
  1658. aePage:add("off", nil, 17,23, 6,6, colors.black, colors.black, colors.red)
  1659. aePage:add("Turn it on", changeAEPower, 13,25, 8,8, colors.black, colors.black, colors.cyan)
  1660. end
  1661.  
  1662.  
  1663. end
  1664. end
  1665.  
  1666.  
  1667. function changeAEPower()
  1668. rednet.send(AEcomputerID, "changeAEPower")
  1669. aePage = nil
  1670. aePage = touchpointEdited.new(monitorSide)
  1671. addAEpage()
  1672. t = aePage
  1673. end
  1674.  
  1675. function refreshAE()
  1676. aePage = nil
  1677. aePage = touchpointEdited.new(monitorSide)
  1678. addAEpage()
  1679. t = aePage
  1680. end
  1681.  
  1682. function goBackMain3()
  1683. aePage = nil
  1684. aePageNotDrawn = true
  1685. aePage = touchpointEdited.new(monitorSide)
  1686. t = mainPage
  1687. end
  1688.  
  1689. --**********************************************END OF AE CONTROL***************************************************************
  1690.  
  1691.  
  1692. --**********************************************START OF NUCLEAR CONTROL*****************************************************************
  1693. nuclearControlPage:add("NOT YET IMPLEMETED", nil, 10,30, 8,8, colors.black, colors.black, colors.red)
  1694. nuclearControlPage:add(goBack, goBackMain, 2,3, 2,2, colors.black, colors.black, colors.cyan)
  1695. --**********************************************END OF NUCLEAR CONTROL***************************************************************
  1696.  
  1697.  
  1698. ---**********************************************************MAIN***************************************************************************
  1699. function checkPages()
  1700. if (currentUser ~= nil) then
  1701. if (t == mainPage) and (mainPageNotDrawn) then
  1702. print("initializing main page for "..currentUser.name)
  1703. addmainPage()
  1704. mainPageNotDrawn = false
  1705. elseif (t == accountPage) and (accountPageNotDrawn) then
  1706. print("initializing account page for "..currentUser.name)
  1707. addAccountPage()
  1708. accountPageNotDrawn = false
  1709. elseif(t == accountPage) and (not accountPageNotDrawn) then
  1710. local AnewPasswordTable = {
  1711. "Password: "..currentUser.password,
  1712. label = "accountPagePasswordLabel"
  1713. }
  1714. accountPage:rename("accountPagePasswordLabel", AnewPasswordTable)
  1715. local newAccessTable = {
  1716. "Access Level: "..currentUser.access,
  1717. label = "accountPageAccessLabel",
  1718. }
  1719. accountPage:rename("accountPageAccessLabel", newAccessTable)
  1720. elseif (t == changePasswordPage) and (changePasswordPageNotDrawn) then
  1721. print("initializing changePasswordPage for "..currentUser.name)
  1722. addChangePasswordPage()
  1723. changePasswordPageNotDrawn = false
  1724. elseif (t == changePasswordPage) and (not changePasswordPageNotDrawn) then
  1725. local newPasswordTable = {
  1726. "Your current password is: "..currentUser.password,
  1727. label = "changePasswordPageCurrentPasswordLabel",
  1728. }
  1729. changePasswordPage:rename("changePasswordPageCurrentPasswordLabel", newPasswordTable)
  1730. elseif (t==changeAccessPage) and (changeAccessPageNotDrawn) then
  1731. print("initializing changeAccessPage for "..currentUser.name)
  1732. addAccessPermissionsPage()
  1733. changeAccessPageNotDrawn = false
  1734. elseif (t==changeAddUserPage) and (changeAddUserPageNotDrawn) then
  1735. print("initializing AddUserPage for "..currentUser.name)
  1736. addAddUserPage()
  1737. changeAddUserPageNotDrawn = false
  1738. elseif (t==changeRemoveUserPage) and (changeRemoveUserPageNotDrawn) then
  1739. print("initializing RemoveUserPage for "..currentUser.name)
  1740. addRemoveUserPage()
  1741. changeRemoveUserPageNotDrawn = false
  1742. elseif (t==mystcraftPage) and (mystcraftPageNotDrawn) then
  1743. print("initializing mystcraftPage for "..currentUser.name)
  1744. addMystcraftPage()
  1745. mystcraftPageNotDrawn = false
  1746. elseif (t==aePage) and (aePageNotDrawn) then
  1747. print("initializing aePage for "..currentUser.name)
  1748. addAEpage()
  1749. aePageNotDrawn = false
  1750. elseif (t==powerPage) and (powerPageNotDrawn) then
  1751. print("initializing powerPage for "..currentUser.name)
  1752. addPowerPage()
  1753. powerPageNotDrawn = false
  1754. end
  1755. end
  1756. end
  1757.  
  1758. function callButton(name)
  1759. if t.buttonList[name].func ~= nil then
  1760. t.buttonList[name].func()
  1761. end
  1762. end
  1763.  
  1764. mainPageNotDrawn = true
  1765. accountPageNotDrawn = true
  1766. changePasswordPageNotDrawn = true
  1767. changeAccessPageNotDrawn = true
  1768. changeAddUserPageNotDrawn = true
  1769. changeRemoveUserPageNotDrawn = true
  1770. mystcraftPageNotDrawn = true
  1771. aePageNotDrawn = true
  1772. powerPageNotDrawn = true
  1773.  
  1774. -- t = mainPage
  1775. -- currentUser = profileArray[4]
  1776.  
  1777. t = loginPage
  1778.  
  1779.  
  1780. -- for i=1,#profileArray do
  1781. -- print(profileArray[i].name) --array(profile)
  1782. -- end
  1783.  
  1784. -- for key,value in ipairs(profileArray) do
  1785. -- print(key) --number
  1786. -- print(value.name) --array(profile)
  1787. -- end
  1788.  
  1789. while true do
  1790. checkPages()
  1791. t:draw()
  1792. local event = {t:handleEvents(os.pullEvent())}
  1793. if event[1] == "button_click" then
  1794. callButton(event[2])
  1795. end
  1796. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement