SHOW:
|
|
- or go back to the newest paste.
| 1 | - | local sensor = peripheral.wrap("right")
|
| 1 | + | local sensor = peripheral.wrap("top")
|
| 2 | local rsSide = "back" | |
| 3 | local count = {}
| |
| 4 | local specie = "Sheep" | |
| 5 | local min = 16 | |
| 6 | ||
| 7 | function enableFeeder() | |
| 8 | - | rs.SetOutput(rsSide, false) |
| 8 | + | rs.setOutput(rsSide, false) |
| 9 | print("Feeder enabled.")
| |
| 10 | end | |
| 11 | ||
| 12 | function disableFeeder() | |
| 13 | rs.setOutput(rsSide, true) | |
| 14 | print("Feeder disabled.")
| |
| 15 | end | |
| 16 | ||
| 17 | function reset() | |
| 18 | count=0 | |
| 19 | end | |
| 20 | ||
| 21 | function add() | |
| 22 | count = count +1 | |
| 23 | end | |
| 24 | ||
| 25 | function registerMob(id) | |
| 26 | if pcall(function() mob = sensor.getMobData(id) end) then | |
| 27 | local type = mob.name | |
| 28 | --print(type.." found.") | |
| 29 | if type==specie then | |
| 30 | add() | |
| 31 | end | |
| 32 | else | |
| 33 | print("error fetching fleeing animal.")
| |
| 34 | end | |
| 35 | end | |
| 36 | ||
| 37 | disableFeeder() | |
| 38 | - | reset() |
| 38 | + | |
| 39 | - | for i,j in pairs(sensor.getMobIds()) do |
| 39 | + | if not rs.getInput("bottom") then
|
| 40 | - | registerMob(j) |
| 40 | + | print("Forced! Slaughterhouse must be running. Feeder enabled.")
|
| 41 | rs.setOutput(rsSide, false) | |
| 42 | - | if count<min then |
| 42 | + | |
| 43 | - | print(specie.."s count : "..count.." < "..min) |
| 43 | + | reset() |
| 44 | - | enableFeeder() |
| 44 | + | for i,j in pairs(sensor.getMobIds()) do |
| 45 | registerMob(j) | |
| 46 | - | print(specie.."s count : "..count.." >= "..min) |
| 46 | + | |
| 47 | - | disableFeeder() |
| 47 | + | if count<min then |
| 48 | print(specie.."s count : "..count.." < "..min) | |
| 49 | enableFeeder() | |
| 50 | else | |
| 51 | print(specie.."s count : "..count.." >= "..min) | |
| 52 | disableFeeder() | |
| 53 | end | |
| 54 | end | |
| 55 | sleep(30) | |
| 56 | end |