Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --EN:
- --This program will fill specified area with material
- --It puts the materia underneath the turtle
- --CZ:
- --Tenhle program vyplni danou oblast materialem
- print("Info: Fuel place only in the last slot")
- print(" Material place anywhere except the last slot")
- --
- --Input ------------------------------------------
- --
- local tArgs = { ... }
- if #tArgs ~= 2 then
- print("Usage: Fill <forward> <right>")
- return
- end
- --
- --Main variables ---------------------------------
- --
- local nSelected = 1
- local X = tonumber(tArgs[1])
- local Y = tonumber(tArgs[2])
- --
- --Methods ----------------------------------------
- --
- local function CheckForAll()
- --material
- local bCheck = true
- while bCheck do
- bCheck = false
- if turtle.getItemCount(nSelected) == 0 then
- nSelected = nSelected + 1
- turtle.select(nSelected)
- bCheck = true
- end
- if nSelected == 16 then
- bCheck = false
- nSelected = 1
- turtle.select(nSelected)
- print("Out of material, fill me Im waiting...")
- while turtle.getItemCount(1) == 0 do
- os.sleep(1)
- end
- print("Thanks!")
- end
- end
- --fuel
- if turtle.getFuelLevel() == 0 then
- turtle.select(16)
- local bFirst = true
- while turtle.refuel(1) == false do
- if bFirst then
- print("Out of fuel, waiting...")
- end
- os.sleep(1)
- bFirst = false
- end
- print("Thanks!")
- turtle.select(nSelected)
- end
- end
- local function FillLine()
- local x = 1
- while x <= X do
- CheckForAll()
- turtle.placeDown()
- if x ~= X then
- shell.run("/rom/programs/turtle/go forward")
- end
- x = x + 1
- end
- end
- --
- --Code -------------------------------------------
- --
- turtle.select(1)
- local invertedLine = false
- local y = 1
- while y <= Y do
- FillLine()
- if y ~= Y then
- if invertedLine then
- CheckForAll()
- shell.run("/rom/programs/turtle/go left forward left")
- invertedLine = false
- else
- CheckForAll()
- shell.run("/rom/programs/turtle/go right forward right")
- invertedLine = true
- end
- end
- y = y + 1
- end
- --Return
- if invertedLine then
- shell.run("/rom/programs/turtle/go right")
- for n=1, (Y - 1) do
- CheckForAll()
- shell.run("/rom/programs/turtle/go forward")
- end
- shell.run("/rom/programs/turtle/go right")
- else
- shell.run("/rom/programs/turtle/go left")
- for n=1, (Y - 1) do
- CheckForAll()
- shell.run("/rom/programs/turtle/go forward")
- end
- shell.run("/rom/programs/turtle/go left")
- for n=1, (X - 1) do
- CheckForAll()
- shell.run("/rom/programs/turtle/go forward")
- end
- shell.run("/rom/programs/turtle/go left 2")
- end
- print("All done!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement