Hello, I've written a little function to count child mobs using OpenPeripheral sensor.
A sensor has to be attached directly to the computer as a peripheral (of course you can tweak it to be more complex)

Function:


function detectChildMobs(sensorSide)

  local p = peripheral.wrap(sensorSide)
  local mobIdsTable = p.getMobIds()
  local childMobs = 0

  for i=1, #mobIdsTable do
  
	local mobId = mobIdsTable[i]
	if(p.getMobData(mobId)["living"]["isChild"]) then
	  childMobs = childMobs + 1
	end
  
  end

  return childMobs
	
end

Example usage:

Let's say I have a sensor on top of a computer in a middle of a 5x5 field.




I could use the function like so:


local cMobs = detectChildMobs("top")

if(cMobs > 0) then
	print("There are " .. cMobs .. " child mobs")
else
	print("There are no child mobs")
end