Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function goUp()
- while not turtle.up() do turtle.digUp() end
- end
- local function goDown()
- while not turtle.down() do turtle.digDown() end
- end
- --rednet.open("right")
- turtleId = os.getComputerLabel()
- function loadPos()
- handle = fs.open("enderMine/savedPosition", "r")
- readFile = handle.readLine()
- if readFile ~= nil then
- position = textutils.unserialize(readFile)
- end
- handle.close()
- end
- local function moveForward()
- while not turtle.forward() do turtle.dig()
- end
- end
- function sendBroadcast(message)
- -- rednet.open("right")
- -- rednet.broadcast("["..turtleId.."] "..message)
- end
- -------
- print("finding pos")
- loadPos()
- print("pos found")
- if position["status"] == "on" then
- print("status: on")
- if position["enderchest"] == "no" then
- wait = 1
- shell.run("mine", position["currY"], "on", "manual")
- else
- shell.run("mine", position["currY"], "on")
- end
- end
- --sendBroadcast("Standing by")
- print("enderMiner "..turtleId..", standing by")
- print("")
- print("Usage:")
- print("mine [current y] [-] [manual(optional)]")
- print("")
- print("Noice blocks: slot 1-3, put 1 cobble in slot 4")
- print("Enderchest in slot 16")
- while true do
- event, sid, mes, dis = os.pullEvent()
- wait = 0
- if mes == "new" then
- turtle.select(5)
- turtle.digUp()
- for i = 1, 16 do moveForward() end
- turtle.placeUp()
- wait = 1
- shell.run("mine", position["currY"])
- elseif mes == "download" then
- wait = 1
- --sendBroadcast("Updating")
- shell.run("download")
- elseif mes == "pastebin" then
- event, sid, file, dis = os.pullEvent("rednet_message")
- dl = textutils.unserialize(file)
- wait = 1
- -- sendBroadcast("Downloading "..dl["placement"])
- shell.run("pastebin", "get", dl["fileName"], dl["placement"])
- elseif mes == "go up" then
- event, sid, surface, dis = os.pullEvent("rednet_message")
- wait = 1
- --sendBroadcast("Going to y level "..surface)
- while position["currY"] < tonumber(surface) do goUp() end
- while position["currY"] > tonumber(surface) do goDown() end
- elseif event == "key" and sid == 28 then
- turtle.select(5)
- turtle.digUp()
- for i = 1, 16 do moveForward() end
- turtle.placeUp()
- wait = 1
- shell.run("mine", position["currY"])
- end
- end
- print("done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement