Ubidibity

init.lua

Apr 30th, 2025 (edited)
1,354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.78 KB | Gaming | 0 0
  1. -- Initialize turtle with standard programs.
  2. -- This script pulls all 'usual' turtle programs from Pastebin to set up a default turtle
  3. -- or update existing programs on older turtles.
  4.  
  5. -- Table of programs and their Pastebin codes, organized alphabetically
  6. local programs = {
  7.   ["anvildrop.lua"] = "mcrhqDy0",
  8.   ["borethrough.lua"] = "NcPPMjSp",
  9.   ["boxmining.lua"] = "9LGhh30Y",
  10.   ["clayminer.lua"] = "6mKBdMvD",
  11.   ["clearchunk.lua"] = "a1wCqTLT",
  12.   ["downramp.lua"] = "M5w7bYQ1",
  13.   ["floor.lua"] = "BmpxvsU0",
  14.   ["initupdate.lua"] = "ZDcrJian",
  15.   ["simp_tree.lua"] = "59cssnQ2",
  16.   ["stairsUp.lua"] = "8cAJAG4D",
  17.   ["stripmine.lua"] = "KftgQxmT"
  18. }
  19.  
  20. -- Function to update or download a program from Pastebin
  21. local function updateProgram(pastebinCode, programName)
  22.   print("Starting update process for " .. programName .. "...")
  23.   if fs.exists(programName) then
  24.     print("Deleting old version of " .. programName .. "...")
  25.     fs.delete(programName)
  26.     if not fs.exists(programName) then
  27.       print("Old version deleted successfully.")
  28.     else
  29.       error("Failed to delete old version of " .. programName)
  30.     end
  31.   else
  32.     print("No old version of " .. programName .. " found.")
  33.   end
  34.  
  35.   print("Downloading new version from Pastebin...")
  36.   local success = shell.run("pastebin", "get", pastebinCode, programName)
  37.   if success then
  38.     print("Successfully downloaded " .. programName .. " from Pastebin.")
  39.     print("Update complete! You can now run " .. programName .. ".")
  40.   else
  41.     error("Failed to download " .. programName .. " from Pastebin. Check the Pastebin code or internet connection.")
  42.   end
  43. end
  44.  
  45. -- Iterate through the programs table and update each program
  46. for programName, pastebinCode in pairs(programs) do
  47.   updateProgram(pastebinCode, programName)
  48. end
  49.  
  50.  
Advertisement