Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local version = 0.3
- -- Constants for the update process
- local pastebinCode = "gQV6Jvhv" -- Replace with your actual Pastebin code
- local scriptName = "jakeExcavate"
- -- Function to download and update from Pastebin
- function updateFromPastebin()
- local response = http.get("https://pastebin.com/raw/" .. pastebinCode)
- if response then
- local scriptContent = response.readAll()
- response.close()
- local file = fs.open(scriptName, "w")
- file.write(scriptContent)
- file.close()
- print(scriptName.. " - Update downloaded. Restarting script...")
- os.sleep(1) -- Short pause before reboot
- os.reboot()
- else
- print("Failed to check for updates.")
- end
- end
- -- Function to check for new updates and apply them
- function checkForUpdates()
- local response = http.get("https://pastebin.com/raw/" .. pastebinCode)
- if response then
- local scriptContent = response.readAll()
- response.close()
- -- Check if the first line in the updated file contains a new version number
- local remoteVersion = tonumber(string.match(scriptContent, "%-%- Version: (%d+%.%d+)"))
- if remoteVersion and remoteVersion > version then
- print(scriptName.. " - New version found: " .. remoteVersion)
- updateFromPastebin()
- else
- print(scriptName.. " - Running the latest version.")
- end
- else
- print("Failed to connect to Pastebin for update check.")
- end
- end
- -- Main script execution
- local args = {...} -- Capture command-line arguments
- if #args > 0 and args[1] == "-update" then
- print("Update flag detected. Checking for updates...")
- checkForUpdates()
- return -- Exit after updating
- end
- -- THE MAIN FUNCTION --
- -- Prompt for dimensions
- print("Enter the length:")
- local length = tonumber(read())
- print("Enter the width:")
- local width = tonumber(read())
- print("Enter the depth:")
- local depth = tonumber(read())
- -- Function to check and mine block
- function mineBlock()
- turtle.dig()
- if turtle.detectUp() then
- turtle.digUp()
- end
- if turtle.detectDown() then
- turtle.digDown()
- end
- end
- -- Function to handle the mining in one layer
- function mineLayer()
- for w = 1, width do
- for l = 1, length - 1 do
- mineBlock()
- turtle.forward()
- end
- if w < width then
- mineBlock()
- if w % 2 == 1 then
- turtle.turnLeft() -- Turning left instead of right
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnRight() -- Adjusting to ensure proper alignment
- turtle.forward()
- turtle.turnRight()
- end
- end
- end
- end
- -- Main mining function
- function mainMining()
- for d = 1, depth do
- mineLayer()
- if d < depth then
- if d % 2 == 1 then -- Adjust turn based on odd/even layer
- turtle.turnLeft() -- Adjusting for leftward movement
- else
- turtle.turnRight()
- end
- turtle.down() -- Move down to next layer
- if (d < depth) then
- if d % 2 == 1 then
- turtle.turnLeft() -- Continue leftward movement on next layer
- else
- turtle.turnRight()
- end
- end
- end
- end
- end
- -- Start the mining operation
- mainMining()
- print("Mining complete!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement