View difference between Paste ID: 3B0kPRcW and yKTte0ia
SHOW: | | - or go back to the newest paste.
1-
targetNumber = 50
1+
targetNumber = 100
2
3
os.loadAPI("ocs/apis/sensor")
4
chickenSensor = sensor.wrap("top")
5
6
chickenCount = 0
7
8
function count()
9
  while true do
10
    local targets = chickenSensor.getTargets()
11
    --print(textutils.serialise(targets))
12
    chickenCount = 0
13
    for key,value in pairs(targets) do 
14
      chickenCount = chickenCount + 1
15
    end
16
    for i=1,16 do
17
      turtle.select(i)
18
      turtle.drop(64)
19
    end
20
    sleep(10)
21
    print(chickenCount)
22
  end
23
end
24
25
26
function kill()
27
  while true do
28
    if chickenCount>targetNumber then
29
      turtle.attack()
30
    
31-
      sleep(0.5)
31+
      sleep(1)
32
    else
33-
      sleep(0.5)
33+
      sleep(1)
34
    end
35
  end    
36
end
37
38
parallel.waitForAll(count,kill)