cadergator10

AutoInstaller

Aug 27th, 2021 (edited)
129
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component = require("component")
  2. local term = require("term")
  3. local io = require("io")
  4. local ser = require("serialization")
  5.  
  6. local tableToFileCode = "YEKvExYp"
  7. local singleCode = "QxnRYA3B"
  8. local multiCode = "sHfsrt2M"
  9. local program = "ctrl.lua"
  10. local tableToFileName = "tableToFile.lua"
  11. local settingFileName = "doorSettings.txt"
  12.  
  13. local settingData = {}
  14. local randomNameArray = {"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m"}
  15.  
  16. local function save(table, location)
  17.   --saves a table to a file
  18.   local tableFile = assert(io.open(location, "w"))
  19.   tableFile:write(ser.serialize(table))
  20.   tableFile:close()
  21. end
  22.  
  23. term.clear()
  24. print("What kind of door do you want? 1 for single door, 2 for multidoor")
  25. local text = term.read()
  26. if(tonumber(text) == 1) then
  27.    term.clear()
  28.    os.execute("pastebin get -f " .. singleCode .. " " .. program)
  29.     print("ONLY ENTER NUMBERS FOR ALL THE SETTINGS! NO WORDS")
  30.     print("Door Type? 0= doorcontrol. 1=redstone. 2=bundled. 3=rolldoor")
  31.     text = term.read()
  32.     settingData["doorType"] = tonumber(text)  
  33.     if(tonumber(text) == 1) then
  34.         print("What side? 0=bottom, 1=top, 2=back, 3=front, 4=right, 5=right")
  35.         text = term.read()
  36.         settingData["redSide"] = tonumber(text)
  37.         print("No need for redColor! The settings you inputted dont require it :)")
  38.         settingData["redColor"] = 0
  39.     elseif(tonumber(text) == 2) then
  40.         print("What side? 0=bottom, 1=top, 2=back, 3=front, 4=right, 5=right")
  41.         text = term.read()
  42.         settingData["redSide"] = tonumber(text)
  43.         print("What color. Use the Color API wiki provided in discord, and enter the NUMBER")
  44.         text = term.read()
  45.         settingData["redColor"] = tonumber(text)
  46.     else
  47.         print("No need for redSide or redColor! The settings you inputted dont require it :)")
  48.         settingData["redSide"] = 0
  49.         settingData["redColor"] = 0
  50.     end
  51.     print("Should the door be toggleable, or not? 0 for auto close and 1 for toggleable")
  52.     text = term.read()
  53.     settingData["toggle"] = tonumber(text)
  54.     if(tonumber(text) == 0) then
  55.         print("How long should the door stay open in seconds?")
  56.         text = term.read()
  57.         settingData["delay"] = tonumber(text)
  58.     else
  59.         print("No need to change delay! Previous setting doesnt require it :)")
  60.         settingData["delay"] = 0
  61.     end
  62.     print("What should be read? 0 = level; 1 = armory level; 2 = MTF;")
  63.     print("3 = GOI; 4 = Security; 5 = Department; 6 = Intercom; 7 = Staff")
  64.     text = term.read()
  65.     settingData["cardRead"] = tonumber(text)
  66.     if(tonumber(text) <= 1 or tonumber(text) == 5) then
  67.         print("Access Level of what should be read?")
  68.         print("if level or armory level, enter the level that it should be.")
  69.         print("if department: 1=SD, 2=ScD, 3=MD, 4=E&T, 5=O5")
  70.         text = term.read()
  71.         settingData["accessLevel"] = tonumber(text)
  72.     else
  73.         print("No need to set access level. This mode doesnt require it :)")
  74.         settingData["accessLevel"] = 0
  75.     end
  76.     print("Installing table to file: ")
  77.     os.execute("pastebin get -f " .. tableToFileCode .. " " .. tableToFileName)
  78.     term.clear()
  79.     save(settingData,settingFileName)
  80.     print("All done! You can remove internet card now. Run " .. program .. " now to start door!")
  81. elseif(tonumber(text) == 2) then
  82.    term.clear()
  83.    os.execute("pastebin get -f " .. multiCode .. " " .. program)
  84.    print("Read the text carefully. Some of the inputs REQUIRE NUMBERS ONLY! Some require text.")
  85.    print("The redSide is always 2, or back of the computer.")
  86.    print("How many different doors are there?")
  87.    local num = tonumber(term.read())
  88.    for i=1, num, 1 do
  89.         term.clear()
  90.         print("Door # " .. i .. " is being edited:")
  91.        
  92.         print("Magnetic card reader address? TEXT")
  93.         text = term.read()
  94.         settingData[randomNameArray[i]] = {}
  95.         settingData[randomNameArray[i]]["reader"] = text:sub(1,-2)
  96.         print("Door Type? 0= doorcontrol. 2=bundled. 3=rolldoor. NEVER USE 1! NUMBER ONLY")
  97.         text = term.read()
  98.         settingData[randomNameArray[i]]["doorType"] = tonumber(text)
  99.         if(tonumber(text) == 2) then
  100.             print("What color. Use the Color API wiki provided in discord, and enter the NUMBER")
  101.             text = term.read()
  102.             settingData[randomNameArray[i]]["redColor"] = tonumber(text)
  103.             print("No need to input anything for door address. The setting doesnt require it :)")
  104.             settingData[randomNameArray[i]]["doorAddress"] = ""
  105.         else
  106.             print("No need to input anything for redColor. The setting doesnt require it :)")
  107.             settingData[randomNameArray[i]]["redColor"] = 0
  108.             print("What is the address for the doorcontrol/rolldoor block? text is fine.")
  109.             text = term.read()
  110.             settingData[randomNameArray[i]]["doorAddress"] = text:sub(1,-2)
  111.         end
  112.        
  113.         print("Should the door be toggleable, or not? 0 for auto close and 1 for toggleable")
  114.         text = term.read()
  115.         settingData[randomNameArray[i]]["toggle"] = tonumber(text)
  116.         if(tonumber(text) == 0) then
  117.             print("How long should the door stay open in seconds? NUMBER ONLY")
  118.             text = term.read()
  119.             settingData[randomNameArray[i]]["delay"] = tonumber(text)
  120.         else
  121.             print("No need to change delay! Previous setting doesnt require it :)")
  122.             settingData[randomNameArray[i]]["delay"] = 0
  123.         end      
  124.         print("What should be read? 0 = level; 1 = armory level; 2 = MTF;")
  125.         print("3 = GOI; 4 = Security; 5 = Department; 6 = Intercom; 7 = Staff")
  126.         text = term.read()
  127.         settingData[randomNameArray[i]]["cardRead"] = tonumber(text)
  128.         if(tonumber(text) <= 1 or tonumber(text) == 5) then
  129.             print("Access Level of what should be read? NUMBER ONLY")
  130.             print("if level or armory level, enter the level that it should be.")
  131.             print("if department: 1=SD, 2=ScD, 3=MD, 4=E&T, 5=O5")
  132.             text = term.read()
  133.             settingData[randomNameArray[i]]["accessLevel"] = tonumber(text)
  134.         else
  135.             print("No need to set access level. This mode doesnt require it :)")
  136.             settingData[randomNameArray[i]]["accessLevel"] = 0
  137.         end
  138.    end
  139.    print("Installing table to file: ")
  140.     os.execute("pastebin get -f " .. tableToFileCode .. " " .. tableToFileName)
  141.     term.clear()
  142.     save(settingData,settingFileName)
  143.     print("All done! You can remove internet card now. Run " .. program .. " now to start door!")
  144. else
  145.    term.clear()  
  146.    print("Not an answer:" .. text)
  147. end
RAW Paste Data