Advertisement
Chaos_Cash

printer

Aug 22nd, 2024 (edited)
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. function startup()
  2. rednet.open("top")
  3. turtleId = 638
  4. end
  5.  
  6.  
  7.  
  8. function getPos()
  9. 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"})
  10.  
  11. timer = os.startTimer(1)
  12. repeat
  13. info1,info2,info3,info4 = os.pullEvent()
  14. until (info1 == "rednet_message" and info2 == turtleId) or (info1 == "timer" and info2 == timer)
  15. curPos = info3
  16. end
  17.  
  18.  
  19.  
  20. function main()
  21. blocks = {}
  22. fileName = "bridgePart" .. math.random(1,6)
  23. for x=1,18 do
  24. blocks[x] = {}
  25.  
  26. for z=1,16 do
  27. file = fs.open(fileName .. "/" .. "[" .. x .. "]" .. "[" .. z .. "]","r")
  28. blocks[x][z] = {}
  29.  
  30. for y=1,55 do
  31. blocks[x][z][y] = file.readLine()
  32. end
  33.  
  34. file.close()
  35. end
  36.  
  37. end
  38.  
  39. y = 0
  40. x = 0
  41. z = 0
  42. continue = true
  43. while y < 55 and continue do
  44. y=y+1
  45.  
  46. while x < 18 and continue do
  47. x=x+1
  48.  
  49. while z < 16 and continue do
  50. z=z+1
  51. if tonumber(blocks[x][z][y]) ~= 0 then
  52. continue = false
  53. end
  54. end
  55.  
  56. end
  57.  
  58. end
  59. minY = y
  60.  
  61.  
  62.  
  63. for x=1,18 do
  64.  
  65. for z=1,16 do
  66.  
  67. for y=1,55-minY do
  68. blocks[x][z][y] = blocks[x][z][y+minY]
  69. end
  70.  
  71. end
  72.  
  73. end
  74.  
  75.  
  76.  
  77. --getPos()
  78. curPos = "up"
  79. if curPos ~= "error" and curPos ~= nil then
  80.  
  81. if curPos == "up" then
  82. for x=1,18 do
  83.  
  84. for z=1,16 do
  85. 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\")"})
  86. end
  87.  
  88. end
  89. for x=1,10 do
  90. for z=1,10 do
  91. repeat
  92. info1,info2,info3,info4 = os.pullEvent()
  93. until (info1 == "rednet_message" and info3 == "done2")
  94. print(x.." "..z)
  95. end
  96. end
  97. sleep(3)
  98.  
  99. end
  100.  
  101.  
  102.  
  103. print(1)
  104. for x=1,18 do
  105.  
  106. for z=1,16 do
  107. 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\")"})
  108. end
  109.  
  110. end
  111.  
  112. for x=1,18 do
  113.  
  114. for z=1,16 do
  115. rednet.send((turtleId+x-1)+((z-1)*18),blocks[x][z])
  116. --print(type(blocks[x][z]))
  117. end
  118.  
  119. end
  120.  
  121.  
  122. for x=1,18 do
  123. for z=1,16 do
  124. repeat
  125. info1,info2,info3,info4 = os.pullEvent()
  126. until (info1 == "rednet_message" and info3 == "done2")
  127. info3 = nil
  128. end
  129. end
  130.  
  131. elseif curPos == "error" then
  132. print("error in positioning")
  133. else
  134. print("error, turtle couldnt be reached")
  135. end
  136. end
  137.  
  138. startup()
  139. main()
  140.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement