Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --09.10.2021, mining software 2.1_CC.
- --переменные
- local mode = 11
- local button = 11
- local call = ""
- local comeback = 2
- local t = turtle
- -- проверка топлива
- function checkFuel(dist)
- local fuel = t.getFuelLevel()
- return fuel-dist
- end
- function readKey(from, to)
- local k = -1
- while k < from or k > to do --ожидание выбора
- while call ~= "key" do
- call, k = os.pullEvent()
- end
- end
- while call ~= "key_up" do
- call, _ = os.pullEvent()
- end
- return k
- end
- -- основной цикл
- print (" _____________________________________")
- print ("| Mining software for CC v 2.1.0 |")
- print ("| By marko_rus (marko_ru) |")
- print ("| (C) MCInc All rights reserved! |")
- print ("|_____________________________________|")
- print ("Should the robot come back? \n1 - no \n2 - yes")
- comeback = readKey(49, 50)-48
- print ("Select mode: \n1 - tunnel \n2 - ladder \n3 - room (In developement!!!)")
- mode = readKey(49, 51)
- ----------------------------------------------------------------------------------
- if mode == 49 then --тоннель
- print("1 - 1x1 \n2 - 1x2 \n3 - 3x3")
- button = readKey(49, 51)
- write("Input distance: ")
- local d = read()
- local x = 0
- d = d+0
- if checkFuel(d*comeback) >= 0 and button ~= 51 then
- if button == 49 then --1x1
- while x < d do
- t.dig()
- t.forward()
- x = x + 1
- end
- end
- if button == 50 then --1x2
- while x < d do
- t.dig()
- t.forward()
- t.digUp()
- x = x + 1
- end
- end
- else if button ~= 51 then print("Not enough fuel. Need " .. checkFuel(d*comeback) .. " more to go. Please refuel.") end end
- if button == 51 and checkFuel(d*3*comeback) >= 0 then --3x3
- local bool = true
- while x < d do
- t.dig()
- t.forward()
- t.digDown()
- t.digUp()
- if bool then t.turnLeft()
- else t.turnRight() end
- t.dig()
- t.forward()
- t.digDown()
- t.digUp()
- t.dig()
- t.forward()
- t.digDown()
- t.digUp()
- if bool then t.turnRight()
- else t.turnLeft() end
- x = x + 1
- if bool then bool = false
- else bool = true end
- end
- else if button == 51 then print("Not enough fuel. Need " .. checkFuel(d*3*comeback) .. " more to go. Please refuel.") end end
- if comeback == 2 then
- t.turnRight()
- t.turnRight()
- x = 0
- while x < d do
- t.dig()
- t.forward()
- x = x + 1
- end
- end
- end
- ----------------------------------------------------------------------------------
- if mode == 50 then --лестница
- print("Input distance: ")
- local d = read()
- if checkFuel(d*comeback) >= 0 then
- local x = 0
- d = d+0
- while x < d do
- t.dig()
- t.forward()
- t.digUp()
- t.digDown()
- t.down()
- x = x + 1
- end
- x = 0
- if comeback == 2 then
- t.turnRight()
- t.turnRight()
- while x < d do
- t.up()
- t.forward()
- x = x + 1
- end
- end
- else print("Not enough fuel. Need " .. checkFuel(d*2*comeback) .. " more to go. Please refuel.")
- end
- end
- ----------------------------------------------------------------------------------
- if mode == 51 then --комната
- print("Input x: ")
- local x = read() - 1
- print("Input y: ")
- local y = read() + 0
- print("Input z: ")
- local z = read() - 1
- local rX =0
- local rY =0
- local rZ =0
- -- передвижение по Z
- while true do
- -- передвижение по X
- if rX == 0 then
- while rX < x do
- t.dig()
- t.forward()
- rX = rX + 1
- end
- else
- t.turnLeft()
- t.turnLeft()
- while rX > 0 do
- t.dig()
- t.forward()
- rX = rX - 1
- end
- t.turnLeft()
- t.turnLeft()
- end
- -- передвижение по Y
- if rY + 1 < y and rZ % 2 == 0 then
- t.digUp()
- t.up()
- rY = rY + 1
- else if rY - 1> 0 and rZ % 2 == 1 and rz ~= 0 then
- t.digDown()
- t.Down()
- rY = rY - 1
- else
- break
- end
- end
- end
- end
- ----------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement