Advertisement
iMajesticButter

potionDispenserNodeInstaller

Feb 15th, 2022 (edited)
1,246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.97 KB | None | 0 0
  1. local paste = "vb20x1J9"
  2.  
  3. local startup = "startup"
  4. local config = "item"
  5.  
  6. term.clear()
  7. term.setCursorPos(1, 1)
  8.  
  9. print("--- Potion Dispenser Node Installer ---")
  10. print("Enter the item name of this node")
  11. print("Enter nothing to skip configuration")
  12.  
  13. local configData = read()
  14.  
  15. -- delete old startup file
  16. term.clear()
  17. print("Checking for old startup file")
  18. if(fs.exists(startup)) then
  19.     print("Old startup file found, deleting...")
  20.     fs.delete(startup)
  21. end
  22.  
  23. -- download new startup file
  24. term.clear()
  25. print("Downloading Node Program")
  26. shell.run("pastebin", "get", paste, startup)
  27.  
  28. -- set config
  29. if configData ~= "" then
  30.     term.clear()
  31.     print("Creating configuration file: " .. config .. " with data: " .. configData)
  32.  
  33.     local file = fs.open(config, "w")
  34.     if file then
  35.         file.writeLine(configData)
  36.         file.close()
  37.     else
  38.         print("ERROR: could not create config file: " .. config)
  39.     end
  40. end
  41.  
  42. print("Rebooting")
  43. os.reboot()
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement