Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Turtle Disassemble
- --input paramaters
- --1 range
- local function printUsage()
- print( "Usages:" )
- print( "Disassemble <distance>" )
- end
- --array of items dugup
- local items = {}
- local tArgs = { ... }
- local slots = {}
- local activeslot = 1
- --fills the slot array with junk data
- for i=1,16 do
- for j=1, 4 do
- slots[(i..':'..j)] =64
- end
- end
- if #tArgs < 1 then
- printUsage()
- return
- end
- --fuction to find the item we just dug up
- local function checkItem(row, i)
- a=turtle.getItemDetail()
- items[row..i]=a
- print(row..i)
- print(items[row..i].name)
- end
- --post dig, find the item added to the turtles inventory
- local function findItem(row, i)
- for k=1,activeslot+1 do
- --function only worked with these statements unnessted in an if statement
- --no fucking idea why
- space = turtle.getItemSpace(k)
- -- print(space)
- spaceleft = slots[(k..':'..1)]
- -- print(spaceleft)
- --if this metric changed we know that slot added an item to it
- if (space==spaceleft-1) then
- turtle.select(k)
- slots[(k..':'..1)]=slots[(k..':'..1)]-1
- checkItem(row,i)
- turtle.select(1)
- if (k==activeslot+1)then
- activeslot=activeslot+1
- --overflow check for slot 17 here
- end
- end
- end
- end
- --main dig loop
- i=0
- local items = {}
- tArgs[1]=tArgs[1]+0
- while i<tArgs[1] do
- while(not turtle.forward()) do
- --if the selected slot is full on space, move the selected slot up
- turtle.dig()
- findItem('F',i)
- --step 1 find the slot that took in the item
- -- if (foo -1 == turtle.getItemSpace(activeslot)) then
- -- checkItem(f, i)
- -- else
- -- activeslot = activeslot+1
- -- turtle.select(activeslot)
- -- checkItem(f, i)
- -- end
- os.sleep(1)
- end
- turtle.digUp()
- findItem('U',i)
- turtle.digDown()
- findItem('D',i)
- i=i+1
- end
- file = fs.open("output.txt","w")
- row1=""
- row2=""
- row3=""
- for(i=0, i<tArgs[1]) do
- row1=row1..items['U'..i]..', '
- row2=row2..items['F'..i]..', '
- row3=row3..items['D'..i]..', '
- end
- file.write(row1)
- file.write(row2)
- file.write(row3)
- turtle.turnLeft()
- turtle.turnLeft()
- while i>1 do
- while (not turtle.forward()) do
- turtle.dig()
- os.sleep(1)
- end
- i = i-1
- end
Add Comment
Please, Sign In to add comment