Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hilbert = "a"
- for i=1,7,1 do
- new_seq = " "
- for j=0,string.len(hilbert),1 do
- char = string.sub(hilbert, j, j)
- if char == "a" then
- new_seq = new_seq.."-bF+aFa+Fb-"
- elseif char == "b" then
- new_seq = new_seq.."+aF-bFb-Fa+"
- else
- print(char)
- new_seq = new_seq..char
- end
- end
- hilbert = new_seq
- end
- print(hilbert)
- int place = 0;
- while(place < string.len(hilbert)) do
- if turtle.getFuelLevel() <= place then
- slot = findFuel()
- if slot == nil then
- returnHome(place)
- break
- else
- turtle.select(slot)
- turtle.refuel()
- end
- else
- instr = string.sub(hilbert,place,place)
- if instr == "F" then
- turtle.dig()
- turtle.forward()
- turtle.digDown()
- elseif instr == "+" then
- turtle.turnRight()
- elseif instr == "-" then
- turtle.turnLeft()
- end
- place = place+1
- if invFull() then
- returnHome(place)
- emptyInv()
- place=0
- end
- end
- function returnHome(plc)
- turtle.turnLeft()
- turtle.turnLeft()
- while plc > 0 do
- findFuel()
- chr = string.sub(hilbert,plc,plc)
- if chr = "F" then
- turtle.forward()
- elseif chr = "+" then
- turtle.turnRight()
- elseif chr = "-" then
- turtle.turnLeft()
- end
- plc = plc-1
- end
- function findFuel()
- for slot=0,16,1 do
- turtle.select(slot)
- if turtle.refuel() then
- return slot
- end
- end
- return nil
- end
- function emptyInv()
- findFuel()
- for i=0,16,1 do
- turtle.select(i)
- turtle.dropDown(64)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement