Advertisement
orangeskj

Untitled

Jun 26th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.91 KB | None | 0 0
  1. print("Bem vindos");
  2.  
  3. function Set (list)
  4. local set = {}
  5. for _, l in ipairs(list) do set[l] = true end
  6. return set
  7. end
  8.  
  9. local useless = Set {"minecraft:stone", "minecraft:dirt", "minecraft:gravel", "minecraft:cobblestone", "minecraft:flowing_lava", "minecraft:water"}
  10. local run = Set {"minecraft:flowing_lava", "minecraft:water"}
  11. hFile = fs.open("valores", "r")
  12. y = hFile.readLine()
  13. hFile.close()
  14. x = 0
  15. z= 0
  16. f= 0
  17. fugir = 0
  18.  
  19. function start()
  20. ficheiro = fs.open("direcao", "r")
  21. sentido = ficheiro.readLine()
  22. ficheiro.close()
  23. print(sentido)
  24.  
  25.  
  26. end
  27.  
  28. local function isempty(s)
  29. return s == nil or s == ''
  30. end
  31.  
  32. function direcao(where)
  33. txt = fs.open("direcao", "w")
  34. txt.write(where)
  35. txt.close()
  36. end
  37.  
  38.  
  39. function escrever()
  40. hFile = fs.open("valores", "w")
  41. y = y + 1
  42. hFile.write(y)
  43. hFile.close()
  44. end
  45.  
  46.  
  47.  
  48. function inventario()
  49. for i=16,1,-1
  50. do
  51.  
  52. turtle.select(i)
  53.  
  54. local dataInv = turtle.getItemDetail()
  55.  
  56. if dataInv then
  57. print(dataInv.name)
  58. if useless[dataInv.name] then
  59. print("useless")
  60. turtle.drop(dataInv.count)
  61. sleep(0.5)
  62. end
  63.  
  64. end
  65. end
  66. end
  67.  
  68. function minar()
  69. local success, data = turtle.inspect()
  70. print(data.name)
  71. local success, dataDown = turtle.inspectDown()
  72. local success, dataUp = turtle.inspectUp()
  73.  
  74. if data.name == "minecraft:flowing_lava" or data.name =="minecraft:water" then
  75. fugir = 1
  76. print("run!!!")
  77. end
  78.  
  79. if not useless[data.name] and not isempty(data.name) then
  80. direcao(0)
  81. turtle.dig()
  82. x = 0
  83.  
  84. elseif x == 1 then
  85. turtle.turnLeft()
  86. local success, data4 = turtle.inspect()
  87. print(useless[data4.name])
  88. print(data4.name)
  89. direcao(2)
  90.  
  91. if not useless[data4.name] and not isempty(data4.name) then
  92. print("yup")
  93. turtle.dig()
  94. x = 0
  95. turtle.turnRight()
  96. else
  97. turtle.turnRight()
  98. end
  99.  
  100.  
  101. elseif x == 2 then
  102. print(x)
  103. turtle.turnRight()
  104. direcao(3)
  105.  
  106. local success, data2 = turtle.inspect()
  107. if not useless[data2.name] and not isempty(data2.name) then
  108. print("yuxxxxxp")
  109. turtle.dig()
  110. print(x)
  111. x = 0
  112. turtle.turnLeft()
  113.  
  114. end
  115.  
  116. elseif not useless[dataUp.name] and not isempty(dataUp.name) then
  117. print(x)
  118. turtle.digUp()
  119. turtle.turnLeft()
  120. direcao(1)
  121. x = 0
  122.  
  123.  
  124. elseif not useless[dataDown.name] and not isempty(dataDown.name) then
  125. print(x)
  126. turtle.turnLeft()
  127. direcao(0)
  128. turtle.digDown()
  129. x = 0
  130. print(x)
  131. inventario()
  132.  
  133. elseif x == 5 then
  134. print(x)
  135. turtle.turnLeft()
  136. direcao(1)
  137. turtle.dig()
  138. turtle.forward()
  139. escrever()
  140. x = 0
  141. f = 1 + f
  142.  
  143.  
  144. else
  145. print("sou else")
  146.  
  147. end
  148. end
  149. function trabalho()
  150. while f < 2 and fugir == 0 do
  151. minar()
  152. x = 1 + x
  153.  
  154. end
  155. end
  156. minar()
  157. trabalho()
  158.  
  159. turtle.turnLeft()
  160. turtle.turnLeft()
  161.  
  162. while y > z do
  163. turtle.forward()
  164. z = 1+z
  165. end
  166. hFile = fs.open("valores", "w")
  167. y = 0
  168. hFile.write(y)
  169. hFile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement