Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function GetItemCount()
- local ItemCount = 0;
- for i = 1, math.huge do
- local Success, Result = pcall(function()
- return turtle.getItemCount(i)
- end)
- ItemCount = ItemCount + (Success and Result or 0)
- if not Success then
- break;
- end
- end
- return ItemCount;
- end
- local function left(times)
- times = times or 1
- for _ = 1, times do
- turtle.turnLeft()
- end
- end
- local function right(times)
- times = times or 1
- for _ = 1, times do
- turtle.turnRight()
- end
- end
- local Blocks = GetItemCount();
- local Settings = {
- LavaCheck = false
- }
- local Output = string.format("Placing %d blocks, Approximate time: ~%.2f seconds", Blocks, Blocks * .85)
- print(Output)
- local function Bridge()
- local function GetMostOwnedItem()
- local Items, Slot = 0, 0;
- for i = 1, math.huge do
- local Success, Result = pcall(function()
- return turtle.getItemCount(i)
- end)
- if not Success then
- break;
- end
- if Result > Items then
- Items = Result
- Slot = i
- end
- end
- return Slot;
- end
- local function Place()
- if not turtle.detectDown() then
- if turtle.getItemCount(turtle.getSelectedSlot()) == 0 and #GetItemCount() > 0 then
- turtle.select(GetMostOwnedItem())
- end
- turtle.placeDown()
- end
- end
- local function MoveAndPlace(Steps)
- Steps = Steps or 1;
- for _ = 1, Steps do
- turtle.forward()
- Place()
- end
- end
- local function IsLava()
- local _, Data = turtle.inspect()
- return Data.name == "minecraft:lava"
- end
- local function Main()
- MoveAndPlace()
- if turtle.detect() then
- turtle.dig()
- end
- if turtle.detectUp() then
- turtle.digUp()
- end
- -- Check it's sides to see if there is any lava
- if Settings.LavaCheck then
- right()
- if IsLava() then
- turtle.place()
- end
- left(2)
- if IsLava() then
- turtle.place()
- end
- right()
- end
- end
- -- Keep building until the turtle runs out of items
- while GetItemCount() ~= 0 do
- Main()
- end
- end
- print("Do you wanna check for lava? (Y/N)")
- Settings.LavaCheck = string.lower(read()) == "y" and true or false
- print("LavaCheck:",Settings.LavaCheck)
- Bridge()
- print("Finished making bridge!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement