You can do this without do any coding.
Use the effect IMMUNE: critical on the creature wearing adamantine armour and they won't take any critical damage. See the following example, the critical damage (green dice) is ignored because the target had the IMMUNE: critical effect:
https://www.fantasygrounds.com/forum...chmentid=30244