Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --pastebin get C2ZjmfV1 ninja
- --shell.run("ninja rup")
- local tArgs = { ... }
- local sOutput = tArgs[1]
- local filename = shell.getRunningProgram()
- local function fixSide(aSide)
- if aSide == nil then
- aSide = ""
- end
- aSide = string.lower(aSide)
- if aSide == "top" or aSide == "t" or aSide == "up" or aSide == "u"then
- aSide = "t"
- elseif aSide == "front" or aSide == "f" then
- aSide = "f"
- elseif aSide == "bottom" or aSide == "b" or aSide == "down" or aSide == "d" then
- aSide = "b"
- elseif aSide == "none" or aSide == "n" then
- aSide = "n"
- elseif aSide == "rtop" or aSide == "rt" or aSide == "rup" or aSide == "ru"then
- aSide = "rt"
- elseif aSide == "rfront" or aSide == "rf" then
- aSide = "rf"
- elseif aSide == "rbottom" or aSide == "rb" or aSide == "rdown" or aSide == "rd" then
- aSide = "rd"
- elseif aSide == "rright" or aSide == "rr" then
- aSide = "rr"
- elseif aSide == "rleft" or aSide == "rl" then
- aSide = "rl"
- elseif aSide == "rback" or aSide == "rbk" then
- aSide = "rb"
- else
- aSide = nil
- end
- return aSide
- end
- sOutput = fixSide(sOutput)
- if sOutput == nil then
- print( "Usage: " .. filename .. " <output side> " )
- print( "Side values are Top, Bottom, Front, and None" )
- print( "The turtle will attack the front and push into the output side." )
- print( "None can be specified if the turtle is expected to deal with items moving on their own." )
- return
- end
- local function isEmpty()
- local bFull = true
- local nTotalItems = 0
- for n=1,16 do
- local nCount = turtle.getItemCount(n)
- if nCount == 0 then
- bFull = false
- end
- nTotalItems = nTotalItems + nCount
- end
- if nCount == 0 then
- print( "No more Items to drop." )
- return true
- end
- return false
- end
- local function flashSide(aSide)
- --print("Flash " .. aSide .. " On ")
- redstone.setOutput(aSide, true)
- sleep(0.2)
- --print("Flash " .. aSide .. " Off ")
- redstone.setOutput(aSide, false)
- sleep(0.2)
- end
- local function unload()
- if sOutput == "n" then
- return
- end
- print( "Unloading items..." )
- for n=1,16 do
- --unloaded = unloaded + turtle.getItemCount(n)
- if (turtle.getItemCount(n) > 0) then
- turtle.select(n)
- if sOutput == "t" then
- turtle.dropUp()
- elseif sOutput == "f" then
- turtle.drop()
- elseif sOutput == "b" then
- turtle.dropDown()
- elseif sOutput == "rt" then
- flashSide("top")
- elseif sOutput == "rd" then
- flashSide("bottom")
- elseif sOutput == "rf" then
- flashSide("front")
- elseif sOutput == "rb" then
- flashSide("back")
- elseif sOutput == "rl" then
- flashSide("left")
- elseif sOutput == "rf" then
- flashSide("right")
- end
- end
- end
- turtle.select(1)
- end
- local function load()
- print( "Loading items..." )
- for n=1,16 do
- --unloaded = unloaded + turtle.getItemCount(n)
- if (turtle.getItemCount(n) == 0) then
- turtle.select(n)
- res = turtle.suck()
- if res == false then
- print( "No more Items to get." )
- return false
- end
- sleep(60)
- end
- end
- return true
- end
- local function displaySide(aSide)
- if aSide == nil then
- aSide = ""
- end
- aSide = string.lower(aSide)
- if aSide == "t" then
- aSide = "top"
- elseif aSide == "f" then
- aSide = "front"
- elseif aSide == "b" then
- aSide = "bottom"
- elseif aSide == "n" then
- aSide = "none"
- elseif aSide == "rt" then
- aSide = "redstone pulse top"
- elseif aSide == "rf" then
- aSide = "redstone pulse front"
- elseif aSide == "rd" then
- aSide = "redstone pulse down"
- elseif aSide == "rr" then
- aSide = "redstone pulse right"
- elseif aSide == "rl" then
- aSide = "redstone pulse left"
- elseif aSide == "rb" then
- aSide = "redstone pulse back"
- else
- aSide = "unknown (" .. aSide .. ")"
- end
- return aSide
- end
- print( "Attacking from " .. displaySide("f") .. " sending loot to " .. displaySide(sOutput) .. " with a delay of " .. 0.1 .. " seconds." )
- --print("Left: " .. peripheral.getType("left"))
- --print("Right: " .. peripheral.getType("right"))
- local xp
- if peripheral.getType("left") == "xp" then
- xp = peripheral.wrap("left")
- elseif peripheral.getType("right") == "xp" then
- xp = peripheral.wrap("right")
- end
- if xp ~= nil then
- xp.setAutoCollect(true)
- end
- while true do
- turtle.attack()
- turtle.suck()
- --xp.collect()
- unload()
- sleep(0.1)
- end
Advertisement
Add Comment
Please, Sign In to add comment