Advertisement
civilwargeeky

dynamoControlWizard

Jun 16th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.12 KB | None | 0 0
  1. --Wizard for making dynamoControls!
  2. --Made by civilwargeeky
  3. local enginesFile = "dynamoEngines"
  4. local peripheralsFile = "dynamoBatteries"
  5. local apiFile = "civilsMenuAPI"
  6.  
  7. if not fs.exists(apiFile) then
  8.   print("Getting menu API")
  9.   shell.run("pastebin get E4TJ2uCR "..apiFile)
  10. end
  11. local menu = {}
  12. os.run(menu, apiFile) --Loads the API
  13.  
  14. local tArgs, onlyUpdate = {...}
  15. if tArgs[1] == "update" then
  16.   onlyUpdate = true
  17. end
  18.  
  19.  
  20. local function home()
  21.   term.setCursorPos(1,1)
  22.   term.clear()
  23. end
  24.  
  25. if not onlyUpdate then
  26.   home()
  27.   print("Welcome to the dynamo control file creation wizard!")
  28.   print("This will guide you to making config files\n")
  29.   --Stage 1, Engines
  30.   local basicSides = {"top", "bottom", "front", "back", "left", "right"}
  31.   print("To start, we will register the engines")
  32.   local file = fs.open(enginesFile,"w")
  33.   local engines = 0
  34.   while true do
  35.     engines = engines + 1
  36.     local rf, side, data, isColored
  37.     print("New Engine "..tostring(engines).."\n")
  38.     print("How much power per tick does this engine produce?")
  39.     print("Or type 'quit' to end the engine section")
  40.     rf = read()
  41.     if rf:sub(1,1):lower() == "q" then break end
  42.     _, side = menu.menu("What side should is the output on?", "", basicSides)
  43.     local _, check = menu.menu("Is the output basic or colored?", "", {"Basic", "Colored"})
  44.     isColored = check == "Colored"
  45.     if not isColored then
  46.       local tab = {}
  47.       for i=15,1,-1 do table.insert(tab, i) end
  48.       _, data = menu.menu("What strength should the output be?", "", tab, false, nil, "center", ">>>> "," <<<<")
  49.     else
  50.       data = 1
  51.       print("Colored not supported yet :(")
  52.     end
  53.     home()
  54.     file.write(rf..",\""..side.."\","..data..","..tostring(isColored).."\n")
  55.   end
  56.   file.close()
  57.  
  58.   home()
  59.   print("Now for the Energy Cells")
  60.   print("Assuming you are using TE ones, this could work for other mods, though\n")
  61.   sleep(2)
  62.   local periphSides = peripheral.getNames()
  63.   table.insert(periphSides,"Quit")
  64.   local file = fs.open(peripheralsFile, "w")
  65.   local periphs = 0
  66.   while true do
  67.     periphs = periphs + 1
  68.     local side
  69.     local rm
  70.     rm, side = menu.menu("New Cell "..tostring(periphs), "Select which side/peripheral the cell is on, or select quit to quit", periphSides)
  71.     if rm == #periphSides then
  72.       break
  73.     else
  74.       table.remove(periphSides,rm)
  75.     end
  76.     file.write("\""..side.."\"")
  77.   end
  78.   file.close()
  79. end
  80.  
  81. home()
  82. local fileName = "dynamoControl.lua"
  83. local should = menu.menu("","Thank you for using the Dynamo Control Station Wizard!\nWould you like to install dynamoControl?",{"Yes","No"},nil, nil, "center")
  84. if should == 1 then
  85.   if fs.exists(fileName) then
  86.     shell.run("rm "..fileName)
  87.   end
  88.   shell.run("pastebin get 6gUUv3Ng "..fileName)
  89.   local shouldAgain = menu.menu("Done","Would you like to replace startup and reboot?",{"Yes","No"},nil, nil, "center")
  90.   if shouldAgain == 1 then
  91.     if fs.exists("startup") then
  92.       shell.run("rm startup")
  93.     end
  94.     local file = fs.open("startup","w")
  95.     file.write("shell.run('"..fileName.."')")
  96.     file.close()
  97.     shell.run("reboot")
  98.   end
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement