Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("userInput.lua")
- os.loadAPI("buildSupport.lua")
- os.loadAPI("predictSupport.lua")
- -- type dictates what part of the building is being made. type == 1 gets the cost of the floor and support pillars
- -- type == 2 gets the cost of the walls, and type 3 gets the ceiling
- function blockCost(length, width, height, type)
- if type == 1 then
- return (width * length) + (height * 4)
- end
- if type == 2 then
- return (2 * (height * (width - 2))) + (2 * (height * (length - 2)))
- end
- if type == 3 then
- return (width * length)
- end
- end
- function countItemInInventory(itemName)
- local totalCount = 0
- -- Iterate over all slots in the turtle's inventory
- for slot = 1, 16 do
- local itemDetail = turtle.getItemDetail(slot)
- -- If there's an item in the slot and it matches the specified item name, add to the total count
- if itemDetail and itemDetail.name == itemName then
- totalCount = totalCount + itemDetail.count
- end
- end
- return totalCount
- end
- function returnDown(height, floors, blockname, blockname2)
- turtle.back()
- height = height + 1
- for i = 1, floors do
- for j = 1, height do
- turtle.down()
- end
- end
- turtle.turnLeft()
- concretecount = countItemInInventory(blockname)
- concreteneeded = 276 - concretecount
- concretemod = concreteneeded % 64
- for i = 1, math.floor(concreteneeded/64) do
- turtle.suck(64)
- end
- turtle.suck(concretemod)
- if countItemInInventory(blockname) < 276 then
- print("OUT OF CONCRETE")
- os.exit(1)
- end
- turtle.turnLeft()
- turtle.turnLeft()
- glasscount = countItemInInventory(blockname2)
- glassneeded = 280 - glasscount
- glassmod = glassneeded % 64
- for i = 1, math.floor(glassneeded/64) do
- turtle.suck(64)
- end
- turtle.suck(glassmod)
- if countItemInInventory(blockname2) < 280 then
- print("OUT OF GLASS")
- os.exit(1)
- end
- turtle.turnLeft()
- for i = 1, floors do
- for j = 1, height do
- turtle.up()
- end
- end
- turtle.forward()
- end
- function predictReturnDown(length, width, height, floors)
- tcost = 0
- width = width - 1
- height = height + 1
- for i = 1, width do
- tcost = tcost + 1
- end
- for i = 1, length do
- tcost = tcost + 1
- end
- for i = 1, floors do
- for j = 1, height do
- tcost = tcost + 1
- end
- end
- tcost = tcost + 1
- return tcost
- end
- blockname = "minecraft:black_concrete"
- blockname2 = "minecraft:black_stained_glass_pane"
- choice = 2
- choice2 = 1
- choice3 = 1
- bcost = 0
- bcost2 = 0
- fcost = 0
- floors = 1
- length = 16
- width = 16
- height = 5
- floors = tonumber(userInput.getUserInput("How Many Floors to Make?"))
- for i = 1, floors do
- bcost = bcost + blockCost(length, width, height, 1)
- if choice == 2 then
- bcost2 = bcost2 + blockCost(length, width, height, 2)
- else
- bcost = bcost + blockCost(length, width, height, 2)
- end
- predictSupport.predictFullBuild(length, width, height)
- end
- if choice3 == 0 then
- bcost = bcost + blockCost(length, width, height, 3)
- predictSupport.predictFloor(length, width)
- end
- fcost = fcost + predictSupport.getCost()
- while choice2 ~= 0 and choice2 ~= 1 do
- print("Return Drone to Start After Build?")
- choice2 = tonumber(userInput.getUserInput("Type 0 for Yes, 1 for No"))
- end
- if choice2 == 0 then
- fcost = fcost + predictReturnDown(length, width, height, floors)
- end
- while turtle.getFuelLevel() < fcost do
- print("Turtle Fuel Level Too Low for Build!")
- print("Fuel Needed" .. fcost)
- print("Current Fuel" .. turtle.getFuelLevel())
- print("Please Input Fuel")
- userInput.getUserInput("Press Enter to Continue")
- os.loadAPI("turtleRefuel.lua")
- end
- for j = 1, floors do
- print(choice)
- if choice == 0 then
- print("False 1")
- buildSupport.fullBuild(length, width, height)
- elseif choice == 1 and blockname ~= nil then
- print("False 2")
- buildSupport.fullBuildBlock(length, width, height, blockname)
- elseif choice == 2 and blockname ~= nil and blockname2 ~= nil then
- print("true")
- buildSupport.fullBuildBlocks(length, width, height, blockname, blockname2)
- end
- returnDown(height, j, blockname, blockname2)
- end
- returnDown(height, floors)
Add Comment
Please, Sign In to add comment