Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local iSlot = 1
- local bDebug = false
- local function printUsage()
- print("Wall <Distance> <hight>")
- end
- local function refuel()
- local slotSelX,slotSelY = 1,1
- print("use [Up Dwon Left Right] keys to seleft fuel slot")
- print([[Press "r" refuel or "c" to continue]])
- while true do
- local e,e1,e2,e3 = os.pullEvent()
- if e == "key" then
- if e1 == 200 then -- up turtle.select(e1-1) local slotSelX = 1 local slotSelY = 1
- slotSelY = slotSelY -1
- if slotSelY < 1 then
- slotSelY = 4
- end
- elseif e1 == 208 then -- down
- slotSelY = slotSelY +1
- if slotSelY > 4 then
- slotSelY = 1
- end
- elseif e1 == 203 then -- left
- slotSelX = slotSelX -1
- if slotSelX < 1 then
- slotSelX = 4
- end
- elseif e1 == 205 then -- right
- slotSelX = slotSelX +1
- if slotSelX > 4 then
- slotSelX = 1
- end
- elseif e1 == 19 then -- r
- turtle.refuel(1)
- elseif e1 == 46 then -- c
- break
- end
- end
- turtle.select(slotSelX+(slotSelY*4)-4)
- end
- return
- end
- local function funtUP()
- while not turtle.up() do
- if turtle.getFuelLevel() > 1 then
- sleep(1)
- else
- print("Turtle fuel Levle : "..turtle.getFuelLevel())
- refuel()
- end
- end
- end
- local function funtForward()
- while not turtle.forward() do
- if turtle.getFuelLevel() > 1 then
- sleep(1)
- else
- print("Turtle fuel Levle : "..turtle.getFuelLevel())
- refuel()
- end
- end
- end
- local function checkFor()
- for i = 16,1,-1 do
- local iTotal = turtle.getItemCount(i)
- if bDebug then
- write(tostring(iTotal).." ")
- end
- if iTotal > 0 then
- iSlot = i
- turtle.select(iSlot)
- turtle.placeDown()
- return true
- end
- end
- return false
- end
- local function fplace()
- local found = false
- turtle.select(iSlot)
- if turtle.getItemCount(iSlot) > 0 then
- turtle.placeDown()
- return true
- else
- if not checkFor() then
- print([[No Items in turtle fill turtle and press "c" to continue]])
- while true do
- local e,e1 = os.pullEvent("char")
- if e == "char" and e1 == "c" then
- if checkFor() then
- return
- else
- print("\nNo blocks added")
- end
- end
- end
- else
- return
- end
- end
- end
- local function buildWall(inputlength,inputhight)
- funtUP()
- fplace()
- for p = 1,inputhight do
- for x = 1,inputlength-1 do
- funtForward()
- fplace()
- end
- if p ~= inputhight then
- funtUP()
- fplace()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- end
- end
- if #tArgs == 3 then
- if tArgs[3] == "test" then
- bDebug = true
- end
- table.remove(tArgs,3)
- end
- if #tArgs ~= 2 then
- printUsage()
- else
- local iDistance,iHight = tonumber(tArgs[1]),tonumber(tArgs[2])
- if iDistance == nil or iHight == nil then
- printUsage()
- else
- print("Turtle fuel Levle : "..turtle.getFuelLevel())
- buildWall(iDistance,iHight)
- print("\nFinished wall")
- end
- end
Add Comment
Please, Sign In to add comment