Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --EN:
- --This programs fills border of specified area
- --with material
- --CZ:
- --Tenhle program vyplni okraj zadane
- --oblasti 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: BorderArea <x> <y>")
- 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 BuildRowX()
- local i = 1
- while i <= X do
- CheckForAll()
- turtle.placeDown()
- if i ~= X then
- shell.run("/rom/programs/turtle/go forward")
- end
- i = i + 1
- end
- end
- local function BuildRowY()
- local i = 1
- while i <= Y do
- CheckForAll()
- turtle.placeDown()
- if i ~= Y then
- shell.run("/rom/programs/turtle/go forward")
- end
- i = i + 1
- end
- end
- --
- --Code -------------------------------------------
- --
- turtle.select(1)
- BuildRowX()
- shell.run("/rom/programs/turtle/go right")
- BuildRowY()
- shell.run("/rom/programs/turtle/go right")
- BuildRowX()
- shell.run("/rom/programs/turtle/go right")
- BuildRowY()
- shell.run("/rom/programs/turtle/go right")
- print("All done!")
Advertisement
Add Comment
Please, Sign In to add comment