Advertisement
dadragon84

dynamoControlWizard

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