Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ extrude - KazeNoTachi ]]--
- --[[http://pastebin.com/1sR4CKT4]]--
- name= os.getComputerLabel()
- tArgs= { ... }
- height = tArgs[1]
- tempMatSlot= 0
- --tempMatSlot = tArgs[2] or 15
- function openRednet()
- local listOfSides = rs.getSides()
- local listofPossibles = {}
- local counter1 = 0
- while true do
- counter1 = counter1 +1
- if peripheral.isPresent(tostring(listOfSides[counter1])) and peripheral.getType(listOfSides[counter1]) == "modem" then
- table.insert(listofPossibles,tostring(listOfSides[counter1]))
- end
- if counter1 == 6 and table.maxn(listofPossibles) == 0 then
- print("no wifi present")
- return nil
- end
- if counter1 == 6 and table.maxn(listofPossibles) ~= 0 then
- rednet.open(listofPossibles[1])
- return listofPossibles[1]
- end
- end
- end
- function message(mess)
- modemOn = openRednet()
- if modemOn == nil then
- print("localonly: "..mess)
- else
- rednet.broadcast(name..": "..mess)
- print("network: "..mess)
- end
- end
- function init( ... )
- checkfuel()
- message(name.." is Booting up...\n")
- --write(tempMatSlot.." "..height)
- end
- function checkfuel()
- if turtle.getFuelLevel() <10 then
- turtle.select(16)
- while turtle.refuel(1) ==false do
- sleep(5)
- end
- end
- --rednet.broadcast(name.." Refuelled: "..turtle.getFuelLevel())
- end
- function checkInv()
- if checkInv2()==false then
- message(name.." needs more Materials")
- end
- while checkInv2()==false do
- sleep(5)
- end
- end
- function checkInv2()
- for slot=1,14 do
- if turtle.getItemCount(slot)>0 then
- turtle.select(slot)
- return true
- end
- end
- return false
- end
- function buildcheck()
- partOfTemp=false
- selected=turtle.getSelectedSlot()
- turtle.select(15)
- if turtle.compareDown() then
- partOfTemp = true
- end
- turtle.select(selected)
- return partOfTemp
- end
- function checkForNextBlock()
- direction={}
- direction[1]=false
- direction[2]=false
- direction[3]=false
- checkfuel()
- if turtle.forward() then
- direction[2]=buildcheck()
- turtle.back()
- if direction[2]==true then
- return "forward"
- --write(" nextblock found right")
- end
- end
- turtle.turnRight()
- if turtle.forward() then
- direction[1]=buildcheck()
- turtle.back()
- turtle.turnLeft()
- if direction[1]==true then
- return "right"
- --write(" nextblock found right")
- end
- end
- turtle.turnLeft()
- if turtle.forward() then
- direction[3]=buildcheck()
- turtle.back()
- turtle.turnRight()
- if direction[3]==true then
- return "left"
- --write(" nextblock found right")
- end
- end
- message("No direct route found - Checking for diagonals")
- return checkFordiag()
- end
- function checkFordiag()
- direction={}
- direction[1]=false
- direction[2]=false
- checkfuel()
- if turtle.forward() then
- turtle.turnRight()
- if turtle.forward() then
- direction[1]=buildcheck()
- turtle.back()
- turtle.turnLeft()
- if direction[1]==true then
- turtle.back()
- return "diagright"
- --write(" nextblock found right")
- end
- end
- turtle.turnLeft()
- if turtle.forward() then
- direction[2]=buildcheck()
- turtle.back()
- turtle.turnRight()
- if direction[2]==true then
- turtle.back()
- return "diagleft"
- --write(" nextblock found right")
- end
- end
- turtle.turnRight()
- turtle.back()
- end
- return "none"
- end
- function buildMove(direction)
- message(direction)
- direction=direction or "none"
- checkfuel()
- --turtle.select(15)
- for i=1,height do
- checkInv()
- turtle.up()
- turtle.placeDown()
- end
- if direction=="forward" then
- turtle.forward()
- end
- if direction=="right" then
- turtle.turnRight()
- turtle.forward()
- end
- if direction=="left" then
- turtle.turnLeft()
- turtle.forward()
- end
- if direction=="diagright" then
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- end
- if direction=="diagleft" then
- turtle.forward()
- turtle.turnLeft()
- turtle.forward()
- end
- if direction=="none" then
- --rednet.broadcast(name..": I'm Done!")
- return false
- else
- while turtle.down() do end
- return true
- end
- end
- init()
- message(name.." is Building...\n")
- while buildMove(checkForNextBlock()) == true do
- end
- for i=1,10 do
- turtle.turnRight()
- end
- message("\n"..name.. " is Completed.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement