Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Brain = require("/turtleBrain"):new()
- local Terminal = require("/terminal"):new()
- local NetLib = require("/netLib"):new()
- local Params = {
- Width = nil,
- Height = nil,
- Depth = nil,
- StartDepth = nil,
- StartX = nil,
- NumTurtles = nil,
- }
- function writeHeader()
- Terminal:reset()
- Terminal:display(0,
- "&c"..Terminal:makeSeperator("="),
- " &dTurtle - Fleet Master ~",
- "&c"..Terminal:makeSeperator("="),
- ""
- )
- end
- function main()
- Params = {
- Width = nil,
- Height = nil,
- Depth = nil,
- StartDepth = nil,
- StartX = nil,
- NumTurtles = nil,
- }
- repeat
- writeHeader()
- Terminal:print("(not including this one)")
- Params.NumTurtles = Terminal:promptNum("How many turtles are in the fleet?")
- writeHeader()
- Params.Width = Terminal:promptNum("Input block width:")
- Params.Height = Terminal:promptNum("Input block height:")
- Params.Depth = Terminal:promptNum("Input block depth:")
- writeHeader()
- Params.StartDepth = Terminal:promptNum("Input start depth offset: (leave blank for none)") or 0
- Params.StartX = Terminal:promptNum("Input start x offset: (leave blank for none)") or 0
- writeHeader()
- term.setCursorPos(1,5)
- for name,val in pairs(Params) do
- Terminal:print(" "..tostring(name).." - &c"..tostring(val))
- end
- Terminal:print()
- until Terminal:promptConf("Continue with these parameters?",true)
- writeHeader()
- Params.NumTurtles = Params.NumTurtles + 1 -- add this turtle to the total
- local total = Params.Width
- local placedTurts = 0
- local div = math.ceil(Params.Width/Params.NumTurtles)
- local i = 0
- Brain:forceUp()
- Brain:turnRight()
- local packet = {}
- total = total - div -- account for this turtle
- while total > 0 do
- total = total - div
- if total < div then
- Brain:forceForward(div-total)
- else
- Brain:forceForward(div)
- end
- Brain:turnLeft()
- turtle.select(1 + i)
- turtle.placeDown()
- os.sleep(1)
- -- start fleet turtle
- peripheral.call("bottom","turnOn")
- local isOn = peripheral.call("bottom","isOn")
- print("On?:",tostring(isOn))
- rednet.open("left")
- os.sleep(1)
- local id = peripheral.call("bottom","getID")
- os.sleep(2)
- packet = NetLib:compilePacket("MINE",div,Params.Height,Params.Depth,Params.StartDepth,div*i,1)
- rednet.send(id,packet)
- rednet.close()
- Brain:turnRight()
- i = i + 1
- end
- Brain:turnToFace(Brain.Dir.W)
- Brain:forceForward(Params.Width-div) -- -2 bc there is never a turtle on the last block
- Brain:turnToFace(Brain.Dir.N)
- Brain:forceDown()
- shell.run("OS/Programs/Turtle/mine.lua "..div.." "..Params.Height.." "..Params.Depth.." "..Params.StartDepth.." ".."0".." "..1)
- end
- main()
- -- OS/Programs/Turtle/mine.lua 2 2 4 0 0 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement