Advertisement
Frekvens1

(CC) FrekSystem Part2

Nov 21st, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 30.98 KB | None | 0 0
  1. local oldPull = os.pullEvent;
  2. os.pullEvent = os.pullEventRaw;
  3.     -- FrekSystem Computer
  4.      
  5.     -- pastebin get e99GHzb9 disk/startup
  6.     -- pastebin get nW0L33Tp disk/ComputerSoftware
  7.    
  8. function powerRedstone()
  9.       local up = ""
  10.       local down = ""
  11.       local back = ""
  12.       local front = ""
  13.       local right = ""
  14.       local left = ""
  15.      
  16.       file = io.open("FrekSystem/Redstone/left", "r")
  17.       left = file:read()
  18.       file:close()
  19.      
  20.       file = io.open("FrekSystem/Redstone/right", "r")
  21.       right = file:read()
  22.       file:close()
  23.      
  24.       file = io.open("FrekSystem/Redstone/bottom", "r")
  25.       down = file:read()
  26.       file:close()
  27.      
  28.       file = io.open("FrekSystem/Redstone/top", "r")
  29.       up = file:read()
  30.       file:close()
  31.      
  32.       file = io.open("FrekSystem/Redstone/front", "r")
  33.       front = file:read()
  34.       file:close()
  35.      
  36.       file = io.open("FrekSystem/Redstone/back", "r")
  37.       back = file:read()
  38.       file:close()
  39.      
  40.     if left == "false" then
  41.         redstone.setOutput("left", false)
  42.     else
  43.         redstone.setOutput("left", true)
  44.     end
  45.     if right == "false" then
  46.         redstone.setOutput("right", false)
  47.     else
  48.         redstone.setOutput("right", true)
  49.     end
  50.     if down == "false" then
  51.         redstone.setOutput("bottom", false)
  52.     else
  53.         redstone.setOutput("bottom", true)
  54.     end
  55.     if up == "false" then
  56.         redstone.setOutput("top", false)
  57.     else
  58.         redstone.setOutput("top", true)
  59.     end
  60.     if back == "false" then
  61.         redstone.setOutput("back", false)
  62.     else
  63.         redstone.setOutput("back", true)
  64.     end
  65.     if front == "false" then
  66.         redstone.setOutput("front", false)
  67.     else
  68.         redstone.setOutput("front", true)
  69.     end
  70. end
  71.    
  72. function powered()
  73.     if fs.exists("FrekSystem/Redstone/CurrentSide") == true then
  74.        local variable = ""  
  75.        local selectedSide = ""
  76.           file = io.open("FrekSystem/Redstone/CurrentSide", "r")
  77.           selectedSide = file:read()
  78.           file:close()
  79.          
  80.           local path = "FrekSystem/Redstone/" .. selectedSide
  81.          
  82.           file = io.open(path, "r")
  83.           variable = file:read()
  84.           file:close()
  85.          
  86.           if variable == "true" then
  87.               if selectedSide == "left" then
  88.                  redstone.setOutput("left", true)
  89.               end
  90.               if selectedSide == "right" then
  91.                  redstone.setOutput("right", true)
  92.               end
  93.               if selectedSide == "top" then
  94.                  redstone.setOutput("top", true)
  95.               end
  96.               if selectedSide == "bottom" then
  97.                  redstone.setOutput("bottom", true)
  98.               end
  99.               if selectedSide == "back" then
  100.                  redstone.setOutput("back", true)
  101.               end
  102.               if selectedSide == "front" then
  103.                  redstone.setOutput("front", true)
  104.               end
  105.           else
  106.               if selectedSide == "left" then
  107.                  redstone.setOutput("left", false)
  108.               end
  109.               if selectedSide == "right" then
  110.                  redstone.setOutput("right", false)
  111.               end
  112.               if selectedSide == "top" then
  113.                  redstone.setOutput("top", false)
  114.               end
  115.               if selectedSide == "bottom" then
  116.                  redstone.setOutput("bottom", false)
  117.               end
  118.               if selectedSide == "back" then
  119.                  redstone.setOutput("back", false)
  120.               end
  121.               if selectedSide == "front" then
  122.                  redstone.setOutput("front", false)
  123.               end
  124.           end
  125.     end
  126. end
  127.    
  128. function fixBugs()
  129.    fs.makeDir("FrekSystem/UserData")
  130.    fs.makeDir("FrekSystem/Redstone")
  131.    if fs.exists("FrekSystem/Redstone/left") then
  132.    else
  133.        file = io.open("FrekSystem/Redstone/left", "w")
  134.        file:write(false)
  135.        file:close()
  136.    end
  137.    if fs.exists("FrekSystem/Redstone/right") then
  138.    else
  139.        file = io.open("FrekSystem/Redstone/right", "w")
  140.        file:write(false)
  141.        file:close()
  142.    end
  143.    if fs.exists("FrekSystem/Redstone/top") then
  144.    else
  145.        file = io.open("FrekSystem/Redstone/top", "w")
  146.        file:write(false)
  147.        file:close()
  148.    end
  149.    if fs.exists("FrekSystem/Redstone/back") then
  150.    else
  151.        file = io.open("FrekSystem/Redstone/back", "w")
  152.        file:write(false)
  153.        file:close()
  154.    end
  155.    if fs.exists("FrekSystem/Redstone/front") then
  156.    else
  157.        file = io.open("FrekSystem/Redstone/front", "w")
  158.        file:write(false)
  159.        file:close()
  160.    end
  161.    if fs.exists("FrekSystem/Redstone/bottom") then
  162.    else
  163.        file = io.open("FrekSystem/Redstone/bottom", "w")
  164.        file:write(false)
  165.        file:close()
  166.    end
  167. end
  168.  
  169. function redstones()
  170.    local selectedSide = ""
  171.    local variable = ""
  172.  
  173.    file = io.open("FrekSystem/Redstone/CurrentSide", "r")
  174.    selectedSide = file:read()
  175.    file:close()
  176.    local path = "FrekSystem/Redstone/" .. selectedSide
  177.    
  178.    file = io.open(path, "r")
  179.    variable = file:read()
  180.    file:close()
  181.          
  182.    if fs.exists(path) == true then
  183.           local variable = ""
  184.           file = io.open(path, "r")
  185.           variable = file:read()
  186.           file:close()
  187.             if variable == "false" then
  188.                 file = io.open(path, "w")
  189.                 file:write("true")
  190.                 file:close()
  191.             else
  192.                file = io.open(path, "w")
  193.                file:write(false)
  194.                file:close()
  195.             end
  196.     else
  197.          fs.makeDir("FrekSystem/Redstone")
  198.          file = io.open(path, "w")
  199.          file:write(false)
  200.          file:close()
  201.     end
  202.     file = io.open(path, "r")
  203.     variable = file:read()
  204.     file:close()
  205.     print("Redstone side '" .. selectedSide .. "' is now set to: " .. variable)
  206.     CommandHandler()
  207. end
  208.  
  209. function CommandHandler()
  210.    powerRedstone()
  211.    local command = ""
  212.    local usedCommand = ""
  213.    write("Command: ")
  214.    command = read()
  215.    usedCommand = "Used Command: " .. command
  216.    term.clear()
  217.    term.setCursorPos(1,1)
  218.    print("[-------------------------------------------------]")
  219.    print("[-               FrekSystem V.1.0.0              -]")
  220.    print("[-------------------------------------------------]")
  221.    if command == "help" then
  222.       print("help - shows this")
  223.       print("computer - shows a list of computer commands")
  224.       print("return - returns you to normal computer")
  225.       print("user - shows a list of user commands")
  226.       print("programs - shows a list of all programs")
  227.       print("redstone - shows a list of redstone commands")
  228.       Screen()
  229.    elseif command == "redstone.left" then
  230.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  231.       file:write("left")
  232.       file:close()
  233.       redstones()
  234.    elseif command == "redstone.right" then
  235.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  236.       file:write("right")
  237.       file:close()
  238.       redstones()
  239.    elseif command == "redstone.back" then
  240.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  241.       file:write("back")
  242.       file:close()
  243.       redstones()
  244.    elseif command == "redstone.down" then
  245.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  246.       file:write("bottom")
  247.       file:close()
  248.       redstones()
  249.    elseif command == "redstone.up" then
  250.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  251.       file:write("top")
  252.       file:close()
  253.       redstones()
  254.    elseif command == "redstone.front" then
  255.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  256.       file:write("front")
  257.       file:close()
  258.       redstones()
  259.    elseif command == "redstone.l" then
  260.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  261.       file:write("left")
  262.       file:close()
  263.       redstones()
  264.    elseif command == "redstone.r" then
  265.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  266.       file:write("right")
  267.       file:close()
  268.       redstones()
  269.    elseif command == "redstone.b" then
  270.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  271.       file:write("back")
  272.       file:close()
  273.       redstones()
  274.    elseif command == "redstone.d" then
  275.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  276.       file:write("bottom")
  277.       file:close()
  278.       redstones()
  279.    elseif command == "redstone.u" then
  280.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  281.       file:write("top")
  282.       file:close()
  283.       redstones()
  284.    elseif command == "redstone.f" then
  285.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  286.       file:write("front")
  287.       file:close()
  288.       redstones()
  289.    elseif command == "redstone.allon" then
  290.       file = io.open("FrekSystem/Redstone/left", "w")
  291.       file:write("true")
  292.       file:close()
  293.      
  294.       file = io.open("FrekSystem/Redstone/right", "w")
  295.       file:write("true")
  296.       file:close()
  297.      
  298.       file = io.open("FrekSystem/Redstone/bottom", "w")
  299.       file:write("true")
  300.       file:close()
  301.      
  302.       file = io.open("FrekSystem/Redstone/top", "w")
  303.       file:write("true")
  304.       file:close()
  305.      
  306.       file = io.open("FrekSystem/Redstone/front", "w")
  307.       file:write("true")
  308.       file:close()
  309.      
  310.       file = io.open("FrekSystem/Redstone/back", "w")
  311.       file:write("true")
  312.       file:close()
  313.      
  314.       redstone.setOutput("back", true)
  315.       redstone.setOutput("front", true)
  316.       redstone.setOutput("top", true)
  317.       redstone.setOutput("bottom", true)
  318.       redstone.setOutput("left", true)
  319.       redstone.setOutput("right", true)
  320.      
  321.       CommandHandler()
  322.    elseif command == "redstone.alloff" then
  323.       file = io.open("FrekSystem/Redstone/left", "w")
  324.       file:write("false")
  325.       file:close()
  326.      
  327.       file = io.open("FrekSystem/Redstone/right", "w")
  328.       file:write("false")
  329.       file:close()
  330.      
  331.       file = io.open("FrekSystem/Redstone/bottom", "w")
  332.       file:write("false")
  333.       file:close()
  334.      
  335.       file = io.open("FrekSystem/Redstone/top", "w")
  336.       file:write("false")
  337.       file:close()
  338.      
  339.       file = io.open("FrekSystem/Redstone/front", "w")
  340.       file:write("false")
  341.       file:close()
  342.      
  343.       file = io.open("FrekSystem/Redstone/back", "w")
  344.       file:write("false")
  345.       file:close()
  346.      
  347.       redstone.setOutput("back", false)
  348.       redstone.setOutput("front", false)
  349.       redstone.setOutput("top", false)
  350.       redstone.setOutput("bottom", false)
  351.       redstone.setOutput("left", false)
  352.       redstone.setOutput("right", false)
  353.      
  354.       CommandHandler()
  355.    elseif command == "redstone.online" then
  356.       print("Online redstone outputs:")
  357.       local up = ""
  358.       local down = ""
  359.       local back = ""
  360.       local front = ""
  361.       local right = ""
  362.       local left = ""
  363.      
  364.       file = io.open("FrekSystem/Redstone/left", "r")
  365.       left = file:read()
  366.       file:close()
  367.      
  368.       file = io.open("FrekSystem/Redstone/right", "r")
  369.       right = file:read()
  370.       file:close()
  371.      
  372.       file = io.open("FrekSystem/Redstone/bottom", "r")
  373.       down = file:read()
  374.       file:close()
  375.      
  376.       file = io.open("FrekSystem/Redstone/top", "r")
  377.       up = file:read()
  378.       file:close()
  379.      
  380.       file = io.open("FrekSystem/Redstone/front", "r")
  381.       front = file:read()
  382.       file:close()
  383.      
  384.       file = io.open("FrekSystem/Redstone/back", "r")
  385.       back = file:read()
  386.       file:close()
  387.      
  388.       if up == "true" then
  389.          print("- Redstone output 'up' is powered")
  390.       end
  391.      
  392.       if down == "true" then
  393.          print("- Redstone output 'down' is powered")
  394.       end
  395.      
  396.       if front == "true" then
  397.          print("- Redstone output 'front' is powered")
  398.       end
  399.      
  400.       if back == "true" then
  401.          print("- Redstone output 'back' is powered")
  402.       end
  403.      
  404.       if right == "true" then
  405.          print("- Redstone output 'right' is powered")
  406.       end
  407.      
  408.       if left == "true" then
  409.          print("- Redstone output 'left' is powered")
  410.       end
  411.      
  412.       if left == "false" and right == "false" and down == "false" and up == "false" and front == "false" and back == "false" then
  413.       print("- No redstone outputs are powered!")
  414.       end
  415.      
  416.       if left == "true" and right == "true" and down == "true" and up == "true" and front == "true" and back == "true" then
  417.       print("- All the redstone outputs are powered!")
  418.       end
  419.       print("[-------------------------------------------------]")
  420.       CommandHandler()
  421.    elseif command == "redstone.an" then
  422.       file = io.open("FrekSystem/Redstone/left", "w")
  423.       file:write("true")
  424.       file:close()
  425.      
  426.       file = io.open("FrekSystem/Redstone/right", "w")
  427.       file:write("true")
  428.       file:close()
  429.      
  430.       file = io.open("FrekSystem/Redstone/bottom", "w")
  431.       file:write("true")
  432.       file:close()
  433.      
  434.       file = io.open("FrekSystem/Redstone/top", "w")
  435.       file:write("true")
  436.       file:close()
  437.      
  438.       file = io.open("FrekSystem/Redstone/front", "w")
  439.       file:write("true")
  440.       file:close()
  441.      
  442.       file = io.open("FrekSystem/Redstone/back", "w")
  443.       file:write("true")
  444.       file:close()
  445.      
  446.       redstone.setOutput("back", true)
  447.       redstone.setOutput("front", true)
  448.       redstone.setOutput("top", true)
  449.       redstone.setOutput("bottom", true)
  450.       redstone.setOutput("left", true)
  451.       redstone.setOutput("right", true)
  452.      
  453.       CommandHandler()
  454.    elseif command == "redstone.af" then
  455.       file = io.open("FrekSystem/Redstone/left", "w")
  456.       file:write("false")
  457.       file:close()
  458.      
  459.       file = io.open("FrekSystem/Redstone/right", "w")
  460.       file:write("false")
  461.       file:close()
  462.      
  463.       file = io.open("FrekSystem/Redstone/bottom", "w")
  464.       file:write("false")
  465.       file:close()
  466.      
  467.       file = io.open("FrekSystem/Redstone/top", "w")
  468.       file:write("false")
  469.       file:close()
  470.      
  471.       file = io.open("FrekSystem/Redstone/front", "w")
  472.       file:write("false")
  473.       file:close()
  474.      
  475.       file = io.open("FrekSystem/Redstone/back", "w")
  476.       file:write("false")
  477.       file:close()
  478.      
  479.       redstone.setOutput("back", false)
  480.       redstone.setOutput("front", false)
  481.       redstone.setOutput("top", false)
  482.       redstone.setOutput("bottom", false)
  483.       redstone.setOutput("left", false)
  484.       redstone.setOutput("right", false)
  485.      
  486.       CommandHandler()
  487.    elseif command == "redstone.o" then
  488.       print("Online redstone outputs:")
  489.       local up = ""
  490.       local down = ""
  491.       local back = ""
  492.       local front = ""
  493.       local right = ""
  494.       local left = ""
  495.      
  496.       file = io.open("FrekSystem/Redstone/left", "r")
  497.       left = file:read()
  498.       file:close()
  499.      
  500.       file = io.open("FrekSystem/Redstone/right", "r")
  501.       right = file:read()
  502.       file:close()
  503.      
  504.       file = io.open("FrekSystem/Redstone/bottom", "r")
  505.       down = file:read()
  506.       file:close()
  507.      
  508.       file = io.open("FrekSystem/Redstone/top", "r")
  509.       up = file:read()
  510.       file:close()
  511.      
  512.       file = io.open("FrekSystem/Redstone/front", "r")
  513.       front = file:read()
  514.       file:close()
  515.      
  516.       file = io.open("FrekSystem/Redstone/back", "r")
  517.       back = file:read()
  518.       file:close()
  519.      
  520.       if up == "true" then
  521.          print("- Redstone output 'up' is powered")
  522.       end
  523.      
  524.       if down == "true" then
  525.          print("- Redstone output 'down' is powered")
  526.       end
  527.      
  528.       if front == "true" then
  529.          print("- Redstone output 'front' is powered")
  530.       end
  531.      
  532.       if back == "true" then
  533.          print("- Redstone output 'back' is powered")
  534.       end
  535.      
  536.       if right == "true" then
  537.          print("- Redstone output 'right' is powered")
  538.       end
  539.      
  540.       if left == "true" then
  541.          print("- Redstone output 'left' is powered")
  542.       end
  543.      
  544.       if left == "false" and right == "false" and down == "false" and up == "false" and front == "false" and back == "false" then
  545.       print("- No redstone outputs are powered!")
  546.       end
  547.      
  548.       if left == "true" and right == "true" and down == "true" and up == "true" and front == "true" and back == "true" then
  549.       print("- All the redstone outputs are powered!")
  550.       end
  551.       print("[-------------------------------------------------]")
  552.       CommandHandler()
  553.       -- copy
  554.    elseif command == "rs.left" then
  555.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  556.       file:write("left")
  557.       file:close()
  558.       redstones()
  559.    elseif command == "rs.right" then
  560.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  561.       file:write("right")
  562.       file:close()
  563.       redstones()
  564.    elseif command == "rs.back" then
  565.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  566.       file:write("back")
  567.       file:close()
  568.       redstones()
  569.    elseif command == "rs.down" then
  570.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  571.       file:write("bottom")
  572.       file:close()
  573.       redstones()
  574.    elseif command == "rs.up" then
  575.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  576.       file:write("top")
  577.       file:close()
  578.       redstones()
  579.    elseif command == "rs.front" then
  580.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  581.       file:write("front")
  582.       file:close()
  583.       redstones()
  584.    elseif command == "rs.l" then
  585.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  586.       file:write("left")
  587.       file:close()
  588.       redstones()
  589.    elseif command == "rs.r" then
  590.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  591.       file:write("right")
  592.       file:close()
  593.       redstones()
  594.    elseif command == "rs.b" then
  595.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  596.       file:write("back")
  597.       file:close()
  598.       redstones()
  599.    elseif command == "rs.d" then
  600.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  601.       file:write("bottom")
  602.       file:close()
  603.       redstones()
  604.    elseif command == "rs.u" then
  605.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  606.       file:write("top")
  607.       file:close()
  608.       redstones()
  609.    elseif command == "rs.f" then
  610.       file = io.open("FrekSystem/Redstone/CurrentSide", "w")
  611.       file:write("front")
  612.       file:close()
  613.       redstones()
  614.    elseif command == "rs.allon" then
  615.       file = io.open("FrekSystem/Redstone/left", "w")
  616.       file:write("true")
  617.       file:close()
  618.      
  619.       file = io.open("FrekSystem/Redstone/right", "w")
  620.       file:write("true")
  621.       file:close()
  622.      
  623.       file = io.open("FrekSystem/Redstone/bottom", "w")
  624.       file:write("true")
  625.       file:close()
  626.      
  627.       file = io.open("FrekSystem/Redstone/top", "w")
  628.       file:write("true")
  629.       file:close()
  630.      
  631.       file = io.open("FrekSystem/Redstone/front", "w")
  632.       file:write("true")
  633.       file:close()
  634.      
  635.       file = io.open("FrekSystem/Redstone/back", "w")
  636.       file:write("true")
  637.       file:close()
  638.      
  639.       redstone.setOutput("back", true)
  640.       redstone.setOutput("front", true)
  641.       redstone.setOutput("top", true)
  642.       redstone.setOutput("bottom", true)
  643.       redstone.setOutput("left", true)
  644.       redstone.setOutput("right", true)
  645.      
  646.       CommandHandler()
  647.    elseif command == "rs.alloff" then
  648.       file = io.open("FrekSystem/Redstone/left", "w")
  649.       file:write("false")
  650.       file:close()
  651.      
  652.       file = io.open("FrekSystem/Redstone/right", "w")
  653.       file:write("false")
  654.       file:close()
  655.      
  656.       file = io.open("FrekSystem/Redstone/bottom", "w")
  657.       file:write("false")
  658.       file:close()
  659.      
  660.       file = io.open("FrekSystem/Redstone/top", "w")
  661.       file:write("false")
  662.       file:close()
  663.      
  664.       file = io.open("FrekSystem/Redstone/front", "w")
  665.       file:write("false")
  666.       file:close()
  667.      
  668.       file = io.open("FrekSystem/Redstone/back", "w")
  669.       file:write("false")
  670.       file:close()
  671.      
  672.       redstone.setOutput("back", false)
  673.       redstone.setOutput("front", false)
  674.       redstone.setOutput("top", false)
  675.       redstone.setOutput("bottom", false)
  676.       redstone.setOutput("left", false)
  677.       redstone.setOutput("right", false)
  678.      
  679.       CommandHandler()
  680.    elseif command == "rs.online" then
  681.       print("Online redstone outputs:")
  682.       local up = ""
  683.       local down = ""
  684.       local back = ""
  685.       local front = ""
  686.       local right = ""
  687.       local left = ""
  688.      
  689.       file = io.open("FrekSystem/Redstone/left", "r")
  690.       left = file:read()
  691.       file:close()
  692.      
  693.       file = io.open("FrekSystem/Redstone/right", "r")
  694.       right = file:read()
  695.       file:close()
  696.      
  697.       file = io.open("FrekSystem/Redstone/bottom", "r")
  698.       down = file:read()
  699.       file:close()
  700.      
  701.       file = io.open("FrekSystem/Redstone/top", "r")
  702.       up = file:read()
  703.       file:close()
  704.      
  705.       file = io.open("FrekSystem/Redstone/front", "r")
  706.       front = file:read()
  707.       file:close()
  708.      
  709.       file = io.open("FrekSystem/Redstone/back", "r")
  710.       back = file:read()
  711.       file:close()
  712.      
  713.       if up == "true" then
  714.          print("- Redstone output 'up' is powered")
  715.       end
  716.      
  717.       if down == "true" then
  718.          print("- Redstone output 'down' is powered")
  719.       end
  720.      
  721.       if front == "true" then
  722.          print("- Redstone output 'front' is powered")
  723.       end
  724.      
  725.       if back == "true" then
  726.          print("- Redstone output 'back' is powered")
  727.       end
  728.      
  729.       if right == "true" then
  730.          print("- Redstone output 'right' is powered")
  731.       end
  732.      
  733.       if left == "true" then
  734.          print("- Redstone output 'left' is powered")
  735.       end
  736.      
  737.       if left == "false" and right == "false" and down == "false" and up == "false" and front == "false" and back == "false" then
  738.       print("- No redstone outputs are powered!")
  739.       end
  740.      
  741.       if left == "true" and right == "true" and down == "true" and up == "true" and front == "true" and back == "true" then
  742.       print("- All the redstone outputs are powered!")
  743.       end
  744.       print("[-------------------------------------------------]")
  745.       CommandHandler()
  746.    elseif command == "rs.an" then
  747.       file = io.open("FrekSystem/Redstone/left", "w")
  748.       file:write("true")
  749.       file:close()
  750.      
  751.       file = io.open("FrekSystem/Redstone/right", "w")
  752.       file:write("true")
  753.       file:close()
  754.      
  755.       file = io.open("FrekSystem/Redstone/bottom", "w")
  756.       file:write("true")
  757.       file:close()
  758.      
  759.       file = io.open("FrekSystem/Redstone/top", "w")
  760.       file:write("true")
  761.       file:close()
  762.      
  763.       file = io.open("FrekSystem/Redstone/front", "w")
  764.       file:write("true")
  765.       file:close()
  766.      
  767.       file = io.open("FrekSystem/Redstone/back", "w")
  768.       file:write("true")
  769.       file:close()
  770.      
  771.       redstone.setOutput("back", true)
  772.       redstone.setOutput("front", true)
  773.       redstone.setOutput("top", true)
  774.       redstone.setOutput("bottom", true)
  775.       redstone.setOutput("left", true)
  776.       redstone.setOutput("right", true)
  777.      
  778.       CommandHandler()
  779.    elseif command == "rs.af" then
  780.       file = io.open("FrekSystem/Redstone/left", "w")
  781.       file:write("false")
  782.       file:close()
  783.      
  784.       file = io.open("FrekSystem/Redstone/right", "w")
  785.       file:write("false")
  786.       file:close()
  787.      
  788.       file = io.open("FrekSystem/Redstone/bottom", "w")
  789.       file:write("false")
  790.       file:close()
  791.      
  792.       file = io.open("FrekSystem/Redstone/top", "w")
  793.       file:write("false")
  794.       file:close()
  795.      
  796.       file = io.open("FrekSystem/Redstone/front", "w")
  797.       file:write("false")
  798.       file:close()
  799.      
  800.       file = io.open("FrekSystem/Redstone/back", "w")
  801.       file:write("false")
  802.       file:close()
  803.      
  804.       redstone.setOutput("back", false)
  805.       redstone.setOutput("front", false)
  806.       redstone.setOutput("top", false)
  807.       redstone.setOutput("bottom", false)
  808.       redstone.setOutput("left", false)
  809.       redstone.setOutput("right", false)
  810.      
  811.       CommandHandler()
  812.    elseif command == "rs.o" then
  813.       print("Online redstone outputs:")
  814.       local up = ""
  815.       local down = ""
  816.       local back = ""
  817.       local front = ""
  818.       local right = ""
  819.       local left = ""
  820.      
  821.       file = io.open("FrekSystem/Redstone/left", "r")
  822.       left = file:read()
  823.       file:close()
  824.      
  825.       file = io.open("FrekSystem/Redstone/right", "r")
  826.       right = file:read()
  827.       file:close()
  828.      
  829.       file = io.open("FrekSystem/Redstone/bottom", "r")
  830.       down = file:read()
  831.       file:close()
  832.      
  833.       file = io.open("FrekSystem/Redstone/top", "r")
  834.       up = file:read()
  835.       file:close()
  836.      
  837.       file = io.open("FrekSystem/Redstone/front", "r")
  838.       front = file:read()
  839.       file:close()
  840.      
  841.       file = io.open("FrekSystem/Redstone/back", "r")
  842.       back = file:read()
  843.       file:close()
  844.      
  845.       if up == "true" then
  846.          print("- Redstone output 'up' is powered")
  847.       end
  848.      
  849.       if down == "true" then
  850.          print("- Redstone output 'down' is powered")
  851.       end
  852.      
  853.       if front == "true" then
  854.          print("- Redstone output 'front' is powered")
  855.       end
  856.      
  857.       if back == "true" then
  858.          print("- Redstone output 'back' is powered")
  859.       end
  860.      
  861.       if right == "true" then
  862.          print("- Redstone output 'right' is powered")
  863.       end
  864.      
  865.       if left == "true" then
  866.          print("- Redstone output 'left' is powered")
  867.       end
  868.      
  869.       if left == "false" and right == "false" and down == "false" and up == "false" and front == "false" and back == "false" then
  870.       print("- No redstone outputs are powered!")
  871.       end
  872.      
  873.       if left == "true" and right == "true" and down == "true" and up == "true" and front == "true" and back == "true" then
  874.       print("- All the redstone outputs are powered!")
  875.       end
  876.       print("[-------------------------------------------------]")
  877.       CommandHandler()
  878.    elseif command == "rs.adv.clock" then
  879.       print("It worked! :D")
  880.       for i in string.gmatch(command, ".") do
  881.       print(i)
  882.       end
  883.       CommandHandler()
  884.    elseif command == "redstone3" then
  885.       print("rs.adv.editcircut {Name} - Edit a redstone timer!")
  886.       print("rs.adv.runcircut {Name} - Run a redstone timer!")
  887.       print("rs.adv.clock {Seconds} {l/r} - Redstone clock")
  888.       print("[-------------------------------------------------]")
  889.       print("[-                  Page 3 of 3                  -]")
  890.       print("[-------------------------------------------------]")
  891.       CommandHandler()
  892.    elseif command == "redstone2" then
  893.       print("rs.left / l - On/Off redstone output 'left'")
  894.       print("rs.right / r - On/Off redstone output 'right'")
  895.       print("rs.down / d- On/Off redstone output 'under'")
  896.       print("rs.up / u - On/Off redstone output 'above'")
  897.       print("rs.back / b - On/Off redstone output 'behind'")
  898.       print("rs.front / f - On/Off redstone output 'front'")
  899.       print("rs.allon / an - On/Off redstone outputs on")
  900.       print("rs.alloff / af-turns all redstone outputs off")
  901.       print("rs.online / o - shows all redstone outputs")
  902.       print("[-------------------------------------------------]")
  903.       print("[- Page 2 of 3 Type 'redstone3' to see next page -]")
  904.       print("[-------------------------------------------------]")
  905.       CommandHandler()
  906.    elseif command == "redstone" then
  907.       print("redstone.left / l - On/Off redstone output 'left'")
  908.       print("redstone.right / r - On/Off redstone output 'right'")
  909.       print("redstone.down / d- On/Off redstone output 'under'")
  910.       print("redstone.up / u - On/Off redstone output 'above'")
  911.       print("redstone.back / b - On/Off redstone output 'behind'")
  912.       print("redstone.front / f - On/Off redstone output 'front'")
  913.       print("redstone.allon / an - On/Off redstone outputs on")
  914.       print("redstone.alloff / af-turns all redstone outputs off")
  915.       print("redstone.online / o - shows all redstone outputs")
  916.       print("[-------------------------------------------------]")
  917.       print("[- Page 1 of 3 Type 'redstone2' to see next page -]")
  918.       print("[-------------------------------------------------]")
  919.       CommandHandler()
  920.    elseif command == "notepad.sh" then
  921.       term.clear()
  922.       term.setCursorPos(1,1)
  923.       shell.run("FrekSystem/Programs/Notepad")
  924.    elseif command == "programs" then
  925.       print("notepad.sh  - opens the system notepad")
  926.       CommandHandler()
  927.    elseif command == "user.changeusername" then
  928.       print("Please type your new Username: ")
  929.       local Username = ""
  930.       Username = read()
  931.       if Username == "" then
  932.          print("[Error] Username can't be blank!")
  933.       else
  934.          print("New Username: ", Username)
  935.          
  936.       end
  937.    elseif command == "user" then
  938.       print("user.changeusername - Changes the Username")
  939.       print("user.changepassword - Changes the Password")
  940.       print("[-------------------------------------------------]")
  941.       CommandHandler()
  942.    elseif command == "return" then
  943.       term.clear()
  944.       term.setCursorPos(1,1)
  945.       print("To start the operating system again:")
  946.       print("Use 'reboot' or 'startup'")
  947.       print("[-------------------------------------------------]")
  948.    elseif command == "computer" then
  949.        print("computer.shutdown - turns off the computer")
  950.        print("computer.restart - restarts computer")
  951.        print("computer.lock - locks your computer")
  952.        print("[-------------------------------------------------]")
  953.        print("cp.shutdown - turns off the computer")
  954.        print("cp.restart - restarts computer")
  955.        print("cp.lock - locks your computer")
  956.        print("[-------------------------------------------------]")
  957.        CommandHandler()
  958.    elseif command == "computer.shutdown" then
  959.       os.shutdown()
  960.    elseif command == "computer.restart" then
  961.       os.reboot()
  962.    elseif command == "computer.lock" then
  963.       term.clear()
  964.       term.setCursorPos(1,1)
  965.       Login()
  966.    elseif command == "cp.shutdown" then
  967.       os.shutdown()
  968.    elseif command == "cp.restart" then
  969.       os.reboot()
  970.    elseif command == "cp.lock" then
  971.       term.clear()
  972.       term.setCursorPos(1,1)
  973.       Login()
  974.    else
  975.       print("Unknown Command: ", command)
  976.       CommandHandler()
  977.    end
  978. end
  979.  
  980. function Screen()
  981.    print("[-------------------------------------------------]")
  982.    print("[-            Type 'help' for commands           -]")
  983.    print("[-------------------------------------------------]")
  984.    CommandHandler()
  985. end    
  986.  
  987. function giveGreeting()
  988.     if fs.exists("FrekSystem/UserData/Username") then
  989.        fs.makeDir("FrekSystem/Redstone")
  990.        local Username = ""
  991.      
  992.        file = io.open("FrekSystem/UserData/Username", "r")
  993.        Username = file:read()
  994.        file:close()
  995.        print("[-------------------------------------------------]")
  996.        print("[-               FrekSystem V.1.0.0              -]")
  997.        print("[-------------------------------------------------]")
  998.        print("[- Welcome back ", Username, "!")
  999.        term.setCursorPos(50,4)
  1000.        print("-]")
  1001.        fixBugs()
  1002.        Screen()
  1003.    else
  1004.        print("[Error] Failed to load system!")
  1005.    end
  1006. end
  1007.      
  1008. function Login()
  1009.    if fs.exists("FrekSystem/UserData/Password") then
  1010.           local Password = ""
  1011.           local TypedPassword = ""
  1012.           file = io.open("FrekSystem/UserData/Password", "r")
  1013.           Password = file:read()
  1014.           file:close()
  1015.           print("[-------------------------------------------------]")
  1016.           print("[-         Booting up FrekSystem v.1.0.0         -]")
  1017.           print("[-------------------------------------------------]")
  1018.           print("[-           Please type your password           -]")
  1019.           print("[-------------------------------------------------]")
  1020.           write("[- Passsword: ")
  1021.           TypedPassword = read("*")
  1022.           if TypedPassword == Password then
  1023.               term.clear()
  1024.               term.setCursorPos(1,1)
  1025.               giveGreeting()
  1026.            else
  1027.               print("[Error] Wrong Password!")
  1028.               sleep(2)
  1029.               os.reboot()
  1030.            end
  1031.    else
  1032.        print("[Error] Failed to load system!")
  1033.    end
  1034. end
  1035.      
  1036. term.clear()
  1037. term.setCursorPos(1,1)
  1038. Login()
  1039. os.pullEvent = oldPull
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement