Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ae = peripheral.wrap("bottom")
- local bubble = peripheral.wrap("front")
- local dir = "up"
- local head = "left"
- local body = "right"
- local placer = {[body]=peripheral.wrap(body),[head]=peripheral.wrap(head)}
- local sandID = 88
- local skullID = 397
- local function stockUp()
- ae.pullItem(dir,1,64)
- ae.pullItem(dir,2,64)
- local item = ae.getStackInSlot(1)
- if not item or item.id ~= sandID then
- print("Error: Wrong item in interface")
- return false
- end
- local nSand = ae.pushItemIntoSlot(dir,1,4,1)
- while nSand < 4 do
- nSand = nSand + ae.pushItemIntoSlot(dir,1,4-nSand,1)
- end
- local nSkull = ae.pushItemIntoSlot(dir,2,3,2)
- while nSkull < 3 do
- nSkull = nSkull + ae.pushItemIntoSlot(dir,2,3-nSkull,2)
- end
- if turtle.getItemCount(1) == 4 and turtle.getItemCount(2) == 3 then do return true end
- else return false end
- end
- local function pulse(dir)
- rs.setOutput(dir,true)
- sleep(0.1)
- rs.setOutput(dir,false)
- end
- local function bodyCount()
- return turtle.getItemCount(1) > 0 or turtle.getItemCount(2) > 1
- end
- local function headCount()
- --return turtle.getItemCount(2) > 0
- -- bug: the last wither skull gets placed but never leaves the turtles inventory
- sleep(1.2)
- return false
- end
- local CountItem = {[body]=bodyCount, [head]=headCount}
- local function place(dir)
- -- rs.setOutput(dir,true)
- while not bubble.isActivate() do
- bubble.setActivate(true)
- end
- placer[dir].setActivate(true)
- sleep(0.1)
- while CountItem[dir]() do
- sleep(0.1)
- end
- -- rs.setOutput(dir,false)
- placer[dir].setActivate(false)
- end
- local it = 0
- while true do
- print("Iteration "..it)
- if not stockUp() then break end
- place(body)
- place(head)
- sleep(10)
- it = it + 1
- end
Advertisement
Add Comment
Please, Sign In to add comment