Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --command program created by Marech
- local args = { ... }
- function display(message)
- print(message)
- end
- function help()
- print("Help :")
- print("left or l : turnLeft")
- print("right or t : turnRight")
- print("back or b : back")
- print("go or g : goForward")
- print("up or u : up")
- print("dig or i : dig")
- print("down or d : down")
- print("help or h : help")
- print("quit or q : exit")
- end
- function dig()
- while not turtle.forward() do
- refuel()
- turtle.attack()
- turtle.dig()
- end
- end
- function refuel()
- if turtle.getFuelLevel() ~= "unlimited" and turtle.getFuelLevel() < 1 then
- turtle.select(1)
- if not turtle.refuel(0) then
- print('Need fuel in slot 1')
- end
- turtle.refuel(1)
- end
- end
- continue = true
- local peripheralConnected = peripheral.getType("right")
- if (peripheralConnected == "modem") then
- isWirelessTurtle = true
- rednet.open("right")
- end
- peripheralConnected = peripheral.getType("left")
- if (peripheralConnected == "modem") then
- isWirelessTurtle = true
- rednet.open("left")
- end
- if #args == 1 then
- if args[1] == "off" or args[1] == "offline" then
- isWirelessTurtle = false
- end
- end
- print()
- print("Waiting for commands")
- print()
- while continue do
- refuel()
- if isWirelessTurtle then
- id,command = rednet.receive()
- print("Wireless Command " .. command)
- else
- print("Command ?")
- command = read()
- end
- number = string.match(command,"%d+")
- if command == "left" or command == "l" then
- turtle.turnLeft()
- elseif command == "right" or command == "r" then
- turtle.turnRight()
- elseif string.find(command, "tunneling") then
- shell.run(command)
- elseif string.find(command, "up") or string.find(command, "u") then
- if number ~= nil then
- for i=0, number-1 do
- turtle.digUp()
- turtle.up()
- end
- else
- turtle.up()
- end
- elseif string.find(command, "down") or string.find(command, "d") then
- if number ~= nil then
- for i=0, number-1 do
- turtle.digDown()
- turtle.down()
- end
- else
- turtle.down()
- end
- elseif string.find(command, "go") or string.find(command, "g") then
- if number ~= nil then
- for i=0, number-1 do
- turtle.forward()
- end
- else
- turtle.forward()
- end
- elseif string.find(command, "back") or string.find(command, "b") then
- if number ~= nil then
- for i=0, number-1 do
- turtle.back()
- end
- else
- turtle.back()
- end
- elseif string.find(command, "i") or string.find(command,"dig") then
- if number ~= nil then
- for i=0, number-1 do
- dig()
- end
- else
- dig()
- end
- elseif string.find(command, "t") or string.find(command,"attack") then
- turtle.attack()
- elseif command == "off" or command == "f" then
- isWirelessTurtle = false
- elseif command == "on" or command == "o" then
- isWirelessTurtle = true
- elseif command == "help" or command == "h" then
- help()
- elseif command == "exit" or command == "quit" or command == "q" then
- continue = false
- print("bye")
- else
- help()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment