Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local barrelSide = "front"
- local isBarrel = false -- Barrel placed
- local updateDelay = 2 -- Time before next check
- ------------------------------------
- function barrStats()
- t = peripheral.wrap(barrelSide)
- if t ~= nil then
- isBarrel = true
- value = 0 max = 0
- ti = t.getTankInfo(barrelSide)
- if isBarrel then
- for i,j in pairs(ti) do
- for name,data in pairs(j) do
- if name=="capacity" then
- max = data
- elseif name=="amount"
- then value = data
- end
- end
- end
- end
- s = "Barrel: "..value.."/"..max..
- print(s)
- if value == max then
- return true
- else
- return false
- end
- end
- end
- ------------------------------------
- function turtleCollect()
- turtle.select(1) -- just in case
- turtle.dig() -- grab block in front (typically barrel)
- -- turn around, move forward, and place item (barrel)
- turtle.turnRight()
- turtle.turnRight()
- turtle.forward()
- turtle.place()
- -- turn around, move forward to original position. Change
- -- back to first inventory slot, drop item (token)
- turtle.turnLeft()
- turtle.turnLeft()
- turtle.forward()
- end
- ------------------------------------
- function barrelCheck()
- if barrStats() then
- print("Container full!")
- print("Turtle working")
- return true
- else
- print("Not full!")
- return false
- end
- end
- ------------------------------------
- function main()
- while true do
- barrelFull = barrelCheck()
- while barrelFull do
- turtleCollect()
- end -- end while
- end -- end while
- end --end main()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement