this is a basic, rather stupid way of doing it but i'm still full after boxing day meal cool

Code:
alias calc.color.codes { 
  var %size.before.strip $len($2-)
  var %size.after.strip $len($strip($2-,c))
  var %codes.before.kick $1 
  var %codes.used $calc($calc(%size.before.strip - %size.after.strip)/2)
  if (%codes.used > %codes.before.kick) { 
    echo -s kicked for using %codes.used
  }
}


usage:
/calc.color.codes <allowed color codes> text
EG:
/calc.color.codes 5 $1-

more of a tutorial than an actual script but after a huge meal i can't be bothered to script more, but you get the idea smile