Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function startup()
- rednet.open("top")
- turtleId = 638
- end
- function getPos()
- rednet.send(turtleId,{["action"]="doThis",["doThis"]="if redstone.getInput(\"left\") then rednet.send(22,\"down\") elseif redstone.getInput(\"front\") then rednet.send(22,\"up\") else rednet.send(22,\"error\") end"})
- timer = os.startTimer(1)
- repeat
- info1,info2,info3,info4 = os.pullEvent()
- until (info1 == "rednet_message" and info2 == turtleId) or (info1 == "timer" and info2 == timer)
- curPos = info3
- end
- function main()
- blocks = {}
- fileName = "bridgePart" .. math.random(1,6)
- for x=1,18 do
- blocks[x] = {}
- for z=1,16 do
- file = fs.open(fileName .. "/" .. "[" .. x .. "]" .. "[" .. z .. "]","r")
- blocks[x][z] = {}
- for y=1,55 do
- blocks[x][z][y] = file.readLine()
- end
- file.close()
- end
- end
- y = 0
- x = 0
- z = 0
- continue = true
- while y < 55 and continue do
- y=y+1
- while x < 18 and continue do
- x=x+1
- while z < 16 and continue do
- z=z+1
- if tonumber(blocks[x][z][y]) ~= 0 then
- continue = false
- end
- end
- end
- end
- minY = y
- for x=1,18 do
- for z=1,16 do
- for y=1,55-minY do
- blocks[x][z][y] = blocks[x][z][y+minY]
- end
- end
- end
- --getPos()
- curPos = "up"
- if curPos ~= "error" and curPos ~= nil then
- if curPos == "up" then
- for x=1,18 do
- for z=1,16 do
- rednet.send((turtleId+x-1)+((z-1)*18),{["action"]="doThis",["doThis"]="for i=1," .. 55-minY .. " do turtle.down() end print(1) rednet.send(22,\"done2\")"})
- end
- end
- for x=1,10 do
- for z=1,10 do
- repeat
- info1,info2,info3,info4 = os.pullEvent()
- until (info1 == "rednet_message" and info3 == "done2")
- print(x.." "..z)
- end
- end
- sleep(3)
- end
- print(1)
- for x=1,18 do
- for z=1,16 do
- rednet.send((turtleId+x-1)+((z-1)*18),{["action"]="doThis",["doThis"]="info1=nil while info1~=\"rednet_message\" do info1,info2,info3,info4 = os.pullEvent() end if turtle.getFuelLevel() < 1000 then turtle.select(10) turtle.refuel(4) turtle.select(6) turtle.refuel(4) turtle.select(7) turtle.refuel(4) end for i=1," .. 55-minY .. " do turtle.up() if type(tonumber(info3[i+1])) == \"number\" and tonumber(info3[i+1]) ~= 0 then turtle.select(tonumber(info3[i+1])) turtle.placeDown() end print(info3[i+1]) end turtle.select(2) turtle.placeDown() info3=nil rednet.send(22,\"done2\")"})
- end
- end
- for x=1,18 do
- for z=1,16 do
- rednet.send((turtleId+x-1)+((z-1)*18),blocks[x][z])
- --print(type(blocks[x][z]))
- end
- end
- for x=1,18 do
- for z=1,16 do
- repeat
- info1,info2,info3,info4 = os.pullEvent()
- until (info1 == "rednet_message" and info3 == "done2")
- info3 = nil
- end
- end
- elseif curPos == "error" then
- print("error in positioning")
- else
- print("error, turtle couldnt be reached")
- end
- end
- startup()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement