Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function startup() -- actully fuking works a damn miricale dont fuck with
- size = {0,0,0} -- x,y,z
- --print("Enter Size of area(x)")
- --size[1] = io.read() + 0
- --print("Enter Size of area(z)")
- --size[3] = io.read() + 0
- --coord = startCoord
- dir = 1
- justTurned = false
- selectSlot = 1
- row = 1
- length = 20 --size[3]
- maxRow = 20 --size[1]
- map = {} -- map[row((z)][length(x)]
- i = 1
- g = 0 -- g is last i position
- n = 1
- map = {} -- create the matrix
- for q=1,20 do
- map[q] = {} -- create a new row
- for j=1,20 do
- map[q][j] = 0
- --print(map[q][j])
- end
- end
- i = 1 -- i is now x position in one row
- n = 1
- print("flag 1")
- while row <= maxRow do -- set dig points on table
- if i == 1 then-- if the first block in a row
- if (row%2) ~= 0 then-- if row is odd set for dig
- map[row][i] = 1
- g = i
- i = i+1
- else -- if the row isnt odd move over two blocks and set dig point
- i = i+2
- map[row][i] = 1
- g = i
- i = i+1
- end
- else -- if not first block
- if (i <= length) then-- if less than lenght
- if (i == g+4) then -- if 4 blocks over from last dig point
- map[row][i] = 1
- g = i
- end
- i = i+1
- else -- if over lenght go top next row
- i = 1
- row = row+1
- end
- end
- end
- for q=1,20 do
- for j=1,20 do
- print(map[q][j])
- end
- print("cut")
- end
- end
- function master() -- master function, should work
- while coord[1] <= size[1] do
- while coord[3] <= size[3] and coord[3] >= 0 do
- while cheackSlot() == false do
- selectSlot = selectSlot + 1
- if selectSlot == 15
- getItems()
- end
- end
- if (map[coord[1]][coord[3]] == 1) then
- turtle.putDown()
- end
- turtle.dig()
- turtle.forward()
- coord[3] = coord[3] + (1 * dir)
- justTurned = false
- end
- if coord[3] > size[3] then
- turtle.turnRight()
- coord[1] = coord[1] + 1
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- justTurned = true
- dir = -1
- else
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- coord[1] = coord[1] + 1
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- justTurned = true
- dir = 1
- end
- cheackFuel
- --if cheackInv() == false or coord[1] = size[1] then
- -- getItems()
- --end
- end
- function getItems -- todo, can only be called on surface
- tempCoord = coord
- if coord[1] != 0 then
- if dir == -1 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- end
- while coord[1] < 0 do
- turtle.dig()
- turtle.forward()
- end
- turtle.turnLeft()
- while coord[3] < 0 do
- turtle.dig()
- turtle.forward()
- end
- while selectSlot < 16 do
- turtle.suck()
- turtle.select(selectSlot)
- selectSlot = selectSlot + 1
- end
- while cheakFuel() == false do
- print("need fuel")
- turtle.select(16)
- turtle.refuel(turtle.getItemCount(16))
- selectSlot = 1
- if tempCoord[1] >= size[1] and tempCoord[3] >= size[3] then
- return true
- else
- return false
- turtle.turnleft()
- while coord[3] < tempCoord[3] do
- turtle.dig()
- turtle.forward()
- end
- turtle.turnLeft()
- while coord[1] < tempCoord[1] do
- turtle.dig()
- turtle.forward()
- end
- end
- end
- function cheackInv() -- todo
- selectSlot = 1
- emptySlots = 0
- slot = turtle.getSlot
- while selectSlot < 16 do
- if turtle.getItemCount(selectSlot) == 0 then
- emptySlots = emptySlots + 1
- end
- selectSlot = selectSlot + 1
- end
- if emptySlots >=11 then
- return true
- end
- return false
- end
- function cheackSlot() -- cheaks if slot is empty, should work
- if turtle.getItemCount(selectSlot) == 0 then
- return false
- else
- return true
- end
- end
- function cheackFuel() -- cheakcfuel/refuels if needed, should work, can only be called on surface
- refuel()
- if turtle.getFuelLevel() < 2000 then
- getItems()
- end
- end
- function refuel() -- refuels turtle, should work
- slot = turtle.getSlot
- turtle.selct(4)
- fuelNeeded = 20000 - turtle.getFuelLevel
- (fuelNeeded/80) = coalToTake
- if coalToTake >= turtle.getItemCount then
- coalToTake = turtle.getItemCount - 1
- end
- turtle.refuel(coalToTake)
- turtle.select(slot)
- end
- function dig() -- digs a vertical shaft, should work
- if coord[2] = size[2] then
- dirDig = -1
- mine()
- max = 0
- else
- dirDig = 1
- mine()
- max = size[2]
- end
- while coord[2] ~= max do
- mine()
- if dirDig = 1 then
- turtle.digDown
- turtle.down
- coord[2] = coord[2] + 1
- else
- turtle.digUp
- turtle.up
- coord[2] = coord[2] - 1
- end
- end
- mine()
- end
- function compare() -- dig if not 1 of 4 ingnored blocks, should work
- if turtle.compareTo(1) == false and turtle.compareTo(2) == false and turtle.compareTo(3) == false and turtle.compareTo(4) == false then
- turtle.dig
- end
- end
- function mine() -- does some digging bby, should work
- turtle.compare
- turtle.turnLeft
- turtle.compare
- turtle.turnLeft
- turtle.compare
- turtle.turnLeft
- turtle.compare
- turtle.turnleft
- end
- startup()
- print(map)
- --master()
- --getItems()
- print("done")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement