Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("Bem vindos");
- function Set (list)
- local set = {}
- for _, l in ipairs(list) do set[l] = true end
- return set
- end
- local useless = Set {"minecraft:stone", "minecraft:dirt", "minecraft:gravel", "minecraft:cobblestone", "minecraft:flowing_lava", "minecraft:water"}
- local run = Set {"minecraft:flowing_lava", "minecraft:water"}
- hFile = fs.open("valores", "r")
- y = hFile.readLine()
- hFile.close()
- x = 0
- z= 0
- f= 0
- fugir = 0
- function start()
- ficheiro = fs.open("direcao", "r")
- sentido = ficheiro.readLine()
- ficheiro.close()
- print(sentido)
- end
- local function isempty(s)
- return s == nil or s == ''
- end
- function direcao(where)
- txt = fs.open("direcao", "w")
- txt.write(where)
- txt.close()
- end
- function escrever()
- hFile = fs.open("valores", "w")
- y = y + 1
- hFile.write(y)
- hFile.close()
- end
- function inventario()
- for i=16,1,-1
- do
- turtle.select(i)
- local dataInv = turtle.getItemDetail()
- if dataInv then
- print(dataInv.name)
- if useless[dataInv.name] then
- print("useless")
- turtle.drop(dataInv.count)
- sleep(0.5)
- end
- end
- end
- end
- function minar()
- local success, data = turtle.inspect()
- print(data.name)
- local success, dataDown = turtle.inspectDown()
- local success, dataUp = turtle.inspectUp()
- if data.name == "minecraft:flowing_lava" or data.name =="minecraft:water" then
- fugir = 1
- print("run!!!")
- end
- if not useless[data.name] and not isempty(data.name) then
- direcao(0)
- turtle.dig()
- x = 0
- elseif x == 1 then
- turtle.turnLeft()
- local success, data4 = turtle.inspect()
- print(useless[data4.name])
- print(data4.name)
- direcao(2)
- if not useless[data4.name] and not isempty(data4.name) then
- print("yup")
- turtle.dig()
- x = 0
- turtle.turnRight()
- else
- turtle.turnRight()
- end
- elseif x == 2 then
- print(x)
- turtle.turnRight()
- direcao(3)
- local success, data2 = turtle.inspect()
- if not useless[data2.name] and not isempty(data2.name) then
- print("yuxxxxxp")
- turtle.dig()
- print(x)
- x = 0
- turtle.turnLeft()
- end
- elseif not useless[dataUp.name] and not isempty(dataUp.name) then
- print(x)
- turtle.digUp()
- turtle.turnLeft()
- direcao(1)
- x = 0
- elseif not useless[dataDown.name] and not isempty(dataDown.name) then
- print(x)
- turtle.turnLeft()
- direcao(0)
- turtle.digDown()
- x = 0
- print(x)
- inventario()
- elseif x == 5 then
- print(x)
- turtle.turnLeft()
- direcao(1)
- turtle.dig()
- turtle.forward()
- escrever()
- x = 0
- f = 1 + f
- else
- print("sou else")
- end
- end
- function trabalho()
- while f < 2 and fugir == 0 do
- minar()
- x = 1 + x
- end
- end
- minar()
- trabalho()
- turtle.turnLeft()
- turtle.turnLeft()
- while y > z do
- turtle.forward()
- z = 1+z
- end
- hFile = fs.open("valores", "w")
- y = 0
- hFile.write(y)
- hFile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement