Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function refuelIfNeeded()
- local fuel = turtle.getFuelLevel();
- if fuel<160 then
- local prev_slot = turtle.getSelectedSlot();
- turtle.select(16);
- turtle.refuel(math.ceil(fuel/80));
- turtle.select(prev_slot);
- end
- end
- function checkFindSlot(item_name)
- if turtle.getItemCount()==0 or turtle.getItemDetail().name ~= item_name then
- for i=1,16,1 do
- turtle.select(i);
- if turtle.getItemCount()~=0 and turtle.getItemDetail().name == item_name then
- return true;
- end
- end
- error("no blocks found");
- end
- end
- function checkedPlace(item_name)
- checkFindSlot(item_name);
- turtle.placeDown();
- end
- function checkedForward()
- refuelIfNeeded();
- if turtle.getFuelLevel()==0 then error("failed to refuel") end
- turtle.forward();
- end
- function drawLine(n)
- for i = 1,n-1,1 do
- checkedPlace(BLOCK);
- checkedForward();
- end
- checkedPlace(BLOCK);
- end
- turtle.select(1);
- BLOCK = turtle.getItemDetail().name;
- print(BLOCK);
- SIZE = 5;
- for row_number = 1,SIZE,1 do
- drawLine(SIZE);
- if row_number==SIZE then break; end
- if row_number%2==1 then
- turtle.turnRight();
- checkedForward();
- turtle.turnRight();
- else
- turtle.turnLeft();
- checkedForward();
- turtle.turnLeft();
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement