Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --getting started and resetting some shit
- term.clear()
- turtle.select(1)
- --declaring globals maybe!?
- --Initialise functions
- function turtRefuel(amount) --function to refuel
- turtle.select(16)
- if turtle.refuel(0) == true then
- if amount < 64 then
- turtle.refuel(amount)
- else
- turtle.refuel(64)
- end
- else
- print("This item cannot be used to refuel!\n")
- end
- end
- function yesNo() --function to get user to answer yes/no
- tmp = ""
- term.write("Are you ready? (y/n): ")
- tmp = io.read()
- while true do
- if (string.lower(tmp) == "y") or (string.lower(tmp) == "yes") then
- term.clear()
- break
- elseif (string.lower(tmp) == "n") or (string.lower(tmp) == "no") then
- print("\nOkay, byebye...\n")
- os.sleep(1)
- print(".")
- os.sleep(1)
- term.write(".")
- os.sleep(1)
- term.write(".")
- os.reboot()
- else
- print("\nI didn't understand that\n")
- term.write("Are you ready? (y/n): ")
- tmp = io.read()
- end
- end
- end
- function nth(n) --Nth triangle shit cus math library sucks ass
- if (n == 0) then
- return 1
- else
- return ((n * (n + 1)) / 2)
- end
- end
- function initCheckBuckets() -- to check if there are 15 buckets to start and disperse them equally
- trip = 0
- for i=1,15 do
- nameItem = turtle.getItemDetail(i)
- if nameItem ~= nil then
- if (nameItem["name"] == "minecraft:bucket") and (nameItem["count"] == 1) then
- trip = trip + 1
- end
- end
- end
- if trip == 15 then
- --continue out of this function
- else
- nameItem = turtle.getItemDetail(1)
- if (nameItem["name"] == "minecraft:bucket") and (nameItem["count"] ~= 15) then --determines if there's the right amount of buckets in the first slot
- print("Buckets are present in slot 1 but not 15!!!\n\nTurtle will now restart, fix ur shit")
- yesNo()
- os.reboot()
- else
- for i=2,15 do
- nameItem = turtle.getItemDetail(i)
- if nameItem ~= nil then
- print("Something is obstructing the buckets to be equally dispearsed!!!\n\nTurtle will now restart, fix ur shit")
- yesNo()
- os.reboot()
- end
- end
- nameItem = turtle.getItemDetail(1)
- bucketCount = nameItem["count"]
- if (bucketCount == 15) then -- for loop that equally spreads out the 15 buckets excluding the last slot reserved for fuel
- turtle.select(1)
- for i=2,bucketCount do
- turtle.transferTo(i, 1)
- end
- end
- end
- end
- end
- function refillPoop()
- print("NEED MORE SHIT\n")
- for i=1, 15 do
- turtle.select(i)
- nameItem = {}
- nameItem = turtle.getItemDetail()
- if (nameItem ~= nil) then
- if nameItem["name"] == "minecraft:bucket" then
- turtle.drop()
- turtle.suck()
- end
- else
- print("Slot is empty\n")
- end
- end
- end
- function rePoop(xPaced, zPaced, yPaced, direction)
- print("Returning for more shite :)\n")
- if yPaced == 0 then --if its on the top layer
- if direction == 1 then -- if its travelling/facing away
- if zPaced == 0 then -- if turtle on the same Z axis as home point
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- refillPoop()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- return
- else -- if turtle is away from home points Z axis
- turtle.turnLeft()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- refillPoop()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- turtle.turnRight()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnLeft()
- return
- end
- else -- if its travelling/facing towards homepoint
- if xPaced == 0 then -- if turtle on the same X axis as home point
- turtle.turnRight()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnLeft()
- refillPoop()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnRight()
- return
- else -- if turtle is away from home points X axis
- turtle.turnRight()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- refillPoop()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- turtle.turnRight()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnRight()
- return
- end
- end
- else --if its below the top layer
- if direction == 1 then -- if its travelling/facing away
- if zPaced == 0 then -- if turtle on the same Z axis as home point
- for i=1,yPaced do
- turtle.up()
- end
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- refillPoop()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- for i=1,yPaced do
- turtle.down()
- end
- return
- else -- if turtle is away from home points Z axis
- for i=1,yPaced do
- turtle.up()
- end
- turtle.turnLeft()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- refillPoop()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- turtle.turnRight()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnLeft()
- for i=1,yPaced do
- turtle.down()
- end
- return
- end
- else -- if its travelling/facing towards homepoint
- if xPaced == 0 then -- if turtle on the same X axis as home point
- for i=1,yPaced do
- turtle.up()
- end
- turtle.turnRight()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnLeft()
- refillPoop()
- turtle.turnLeft()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnRight()
- for i=1,yPaced do
- turtle.down()
- end
- return
- else -- if turtle is away from home points X axis
- for i=1,yPaced do
- turtle.up()
- end
- turtle.turnRight()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- refillPoop()
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1,xPaced do
- turtle.forward()
- end
- turtle.turnRight()
- for i=1,zPaced do
- turtle.forward()
- end
- turtle.turnRight()
- for i=1,yPaced do
- turtle.down()
- end
- return
- end
- end
- end
- end
- function poopin()
- if turtle.detectDown() == false then
- turtle.placeDown()
- return true
- end
- return false
- end
- -- ################################
- -- ########### STARTING ###########
- -- ################################
- term.setCursorPos(1, 1)
- print("============ TableSidePoop ============\n")
- print("This program will fill a hole with \ncomplete shite... literally\n\n")
- os.sleep(3)
- --disclaimer/EULA type beat
- print("Please insert 15 empty buckets into slot 1 :)")
- yesNo()
- term.clear()
- term.setCursorPos(1, 1)
- initCheckBuckets()
- print("The dumpy turtle will need to be facing the direction of the hole to fill and placed above the hole not on the block on the walls of the hole\n")
- os.sleep(2)
- print("A tank of some sort should be placed to its back and a chest to dump excess shit\n")
- os.sleep(2)
- print("The dumpy turtle should also be on the left corner of the hole to fill")
- os.sleep(2)
- yesNo()
- --getting dims
- term.setCursorPos(1,1)
- print("What dimensions would you like to fill?\n")
- os.sleep(1)
- term.write("Length: ")
- x = math.floor(math.abs(tonumber(io.read()) or x))
- term.write("Width: ")
- z = math.floor(math.abs(tonumber(io.read()) or z))
- term.write("Depth: ")
- y = math.floor(math.abs(tonumber(io.read()) or y))
- --print(x,z,y)
- os.sleep(1)
- --get fuel needed for complete operation
- area = (x * z) * y --get area
- maxBack = (x + z) * y --get max perimeter and times needed to get back
- fuelNeeded = area + maxBack + nth(y) --adds all together and nth triangle shit of y cus it will need to go up multiple times init remember why this is right you shithead
- -- add a EULA/NOTICE type beat for how many buckets of liquid will be needed
- term.clear()
- term.setCursorPos(1,1)
- print(string.format("The amount of liquid needed to complete this job is going to be: %d buckets\n", area))
- os.sleep(1)
- print("make sure to have enough before continuing...")
- os.sleep(1)
- yesNo()
- term.clear()
- term.setCursorPos(1,1)
- print("\namount of fuel needed to complete \nthis order of shite:", fuelNeeded)
- os.sleep(3)
- --check if already enough fuel
- tmp= fuelNeeded
- fuelLevel = turtle.getFuelLevel()
- if fuelLevel > tmp then
- print("\nThere's already enough fuel to get to shittin'\n\n")
- else
- --start refuelling
- turtle.select(16)
- term.clear()
- term.setCursorPos(1, 1)
- print("Starting Refueling process...\n")
- i=0
- while fuelLevel <= tmp do
- i = i + 1
- if tmp < 64 then
- turtRefuel(tmp)
- else
- turtRefuel(tmp)
- tmp = tmp - 64
- end
- fuelLevel = turtle.getFuelLevel()
- term.clear()
- term.setCursorPos(1, 1)
- print("Starting Refueling process...\n")
- print(string.format("Fuel still needed!"))
- if i == 1 then
- print(".")
- else if i == 2 then
- print("..")
- else if i == 3 then
- print("...")
- i = 0
- end
- end
- end
- end
- term.clear()
- term.setCursorPos(1, 1)
- print("Refueling Complete, dumping access fuel if any...\n")
- -- drop remainging fuel if any is present in inv (IN FUTURE MAKE THIS DUMP INTO AN INV OR SMTH)
- turtle.select(16)
- if turtle.refuel(0) == true then
- turtle.turnLeft()
- turtle.drop(64)
- turtle.turnRight()
- end
- turtle.select(1)
- end
- --fill the first wave of buckets
- turtle.turnLeft()
- turtle.turnLeft()
- for i=1, 15 do
- turtle.select(i)
- itemNamed = {}
- itemNamed = turtle.getItemDetail()
- if (itemNamed ~= nil) then
- if itemNamed["name"] == "minecraft:bucket" then
- turtle.drop()
- turtle.suck()
- end
- else
- print("Slot is empty\n")
- end
- end
- turtle.select(1)
- turtle.turnLeft()
- turtle.turnLeft()
- --movement phases debug
- term.clear()
- term.setCursorPos(1, 1)
- print("Starting movement phase!!!\n")
- tmpY = y-1
- placed = 1
- for i3=1,y do -- go to lowest layer first then up more layer first
- xPaced = 0 --amount of blocks moved to use to return etc
- zPaced = 0
- yPaced = 0
- tmpSlot = 1
- if y > 1 then
- for i4=1,tmpY do
- turtle.down()
- yPaced = yPaced + 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- end
- end
- for i=1,z do --Iterate over the width
- if placed == 16 then -- this sees the last block has been placed so trigger the rePoop function to refill the buckets and return to the same spot to continue
- rePoop(xPaced, zPaced, yPaced, math.fmod(i, 2))
- placed = 1
- turtle.select(placed)
- poopin()
- placed = placed + 1
- else -- this places the block then iterates placed by one to move the slot along
- turtle.select(placed)
- poopin()
- placed = placed + 1
- end
- for i2=1,x-1 do --Iterate over the length
- turtle.forward()
- --place place function here
- if placed == 16 then -- this sees the last block has been placed so trigger the rePoop function to refill the buckets and return to the same spot to continue
- if math.fmod(i, 2) == 1 then --Decided whether travelling forwards or backwards
- xPaced = xPaced + 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- else
- xPaced = xPaced - 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- end
- rePoop(xPaced, zPaced, yPaced, math.fmod(i, 2))
- placed = 1
- turtle.select(placed)
- poopin()
- placed = placed + 1
- else -- this places the block then iterates placed by one to move the slot along
- turtle.select(placed)
- poopin()
- placed = placed + 1
- if math.fmod(i, 2) == 1 then --Decided whether travelling forwards or backwards
- xPaced = xPaced + 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- else
- xPaced = xPaced - 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- end
- end
- end
- if math.fmod(i, 2) == 1 then --Decided whether to turn left or right
- if i ~= z then
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- zPaced = zPaced + 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- end
- else
- if i ~= z then
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- zPaced = zPaced + 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- end
- end
- end
- --start return to home point
- if math.fmod(z, 2) == 1 then --if the turtle finished the y axis away from the starting point
- turtle.turnLeft()
- for p=1,z-1 do
- turtle.forward()
- zPaced = zPaced - 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- end
- turtle.turnLeft()
- for p=1,x-1 do
- turtle.forward()
- xPaced = xPaced - 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- end
- turtle.turnLeft()
- turtle.turnLeft()
- else --if the turtle finished the y axis on line with the starting point
- turtle.turnRight()
- for p=1,z-1 do
- turtle.forward()
- zPaced = zPaced - 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- end
- turtle.turnRight()
- end
- --raises it back to home point layer
- if y > 1 then
- for i4=1,tmpY do
- turtle.up()
- yPaced = yPaced - 1
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- end
- end
- print(string.format("[%d,%d,%d] %d\n",xPaced,zPaced,yPaced,placed))
- --remove 1 from y access
- tmpY = tmpY-1
- end
- --dumping left over inv
- term.clear()
- term.setCursorPos(1,1)
- i=0
- turtle.turnLeft()
- for finish_it=1,16 do
- turtle.select(finish_it)
- turtle.drop(64)
- i=i+1
- term.clear()
- term.setCursorPos(1, 1)
- print("Cleaning up...\nDumping excess shit into chest!")
- if i == 1 then
- print(".")
- else if i == 2 then
- print("..")
- else if i == 3 then
- print("...")
- i = 0
- end
- end
- end
- end
- turtle.turnRight()
- os.sleep(1)
- term.clear()
- term.setCursorPos(1,1)
- print("\n\n\n\n\n=======================================\n========== FINISHED SHITTIN' ==========\n=======================================\n\n\n\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement