Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- box = peripheral.wrap("right")
- tArgs = { ... }
- if #tArgs[] ~= 4 or string.lower(tArgs[4]) ~= "n" or string.lower(tArgs[4]) ~= "e" or string.lower(tArgs[4]) ~= "s" or string.lower(tArgs[4]) ~= "w" then
- print("Usage: <X Coord> <Y Coord> <Z Coord> <Facing direction>")
- else
- xcoord = tArgs[1]
- ycoord = tArgs[2]
- zcoord = tArgs[3]
- facing = targs[4]
- while true do
- event1, player, message = os.pullEvent("chat")
- if string.sub(string.lower(message), 1, 7) == "forward" then
- for i =1, tonumber(string.sub(message, 9))
- if turtle.forward() then
- if facing == "2" then
- zcoord = zcoord - 1
- elseif facing == "3" then
- xcoord = xcoord + 1
- elseif facing == "0" then
- zcoord = zcoord + 1
- elseif facing == "1" then
- xcoord = xcoord - 1
- end
- else
- box.say("Can't move forward")
- end
- end
- elseif string.sub(string.lower(message), 1, 8) == "backward" then
- for i =1, tonumber(string.sub(message, 10))
- if turtle.back() then
- if facing == "2" then
- zcoord = zcoord + 1
- elseif facing == "3" then
- xcoord = xcoord - 1
- elseif facing == "0" then
- zcoord = zcoord - 1
- elseif facing == "1" then
- xcoord = xcoord + 1
- end
- else
- box.say("Can't move backward")
- end
- end
- elseif string.sub(string.lower(message), 1, 2) == "up" then
- for i =1, tonumber(string.sub(message, 4))
- if turtle.up() then
- ycoord = ycoord + 1
- else
- box.say("Can't move up")
- end
- end
- elseif string.sub(string.lower(message), 1, 4) == "down" then
- for i =1, tonumber(string.sub(message, 6))
- if turtle.up() then
- ycoord = ycoord - 1
- else
- box.say("Can't move down")
- end
- end
- elseif string.sub(string.lower(message), 1, 4) == "mine" then
- turtle.dig()
- elseif string.sub(string.lower(message), 1, 6) == "mineup" then
- turtle.digUp()
- elseif string.sub(string.lower(message), 1, 8) == "minedown" then
- turtle.digDown()
- elseif string.sub(string.lower(message), 1, 6) == "refuel" then
- turtle.select(1)
- turtle.refuel(tonumber(string.sub(message, 8)))
- elseif string.sub(string.lower(message), 1, 4) == "suck" then
- turtle.suck()
- turtle.suckUp()
- turtle.suckDown()
- elseif string.sub(string.lower(message), 1, 4) == "sign" then
- turtle.select(2)
- turtle.place(string.sub(message, 6))
- turtle.select(1)
- elseif string.sub(string.lower(message), 1, 5) == "place" then
- turtle.select(3)
- turtle.place()
- turtle.select(1)
- elseif string.sub(string.lower(message), 1, 5) == "fuel?" then
- box.say(turtle.getFuelLevel())
- elseif string.sub(string.lower(message), 1, 7) == "coords?" then
- box.say("X:" .. xcoord .. " Y:" .. ycoord .. " Z:" .. zcoord .. " F:" .. facing)
- end
- sleep(1)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment