Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sensor = peripheral.wrap("right")
- local rsSide = "back"
- local count = {}
- local specie = "Sheep"
- local min = 16
- function enableFeeder()
- rs.SetOutput(rsSide, false)
- print("Feeder enabled.")
- end
- function disableFeeder()
- rs.setOutput(rsSide, true)
- print("Feeder disabled.")
- end
- function reset()
- count=0
- end
- function add()
- count = count +1
- end
- function registerMob(id)
- if pcall(function() mob = sensor.getMobData(id) end) then
- local type = mob.name
- --print(type.." found.")
- if type==specie then
- add()
- end
- else
- print("error fetching fleeing animal.")
- end
- end
- while true do
- reset()
- for i,j in pairs(sensor.getMobIds()) do
- registerMob(j)
- end
- if count<min then
- print(specie.."s count : "..count.." < "..min)
- enableFeeder()
- else
- print(specie.."s count : "..count.." >= "..min)
- disableFeeder()
- end
- sleep(30)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement