Floyd-Steinberg : Indexed color?

I’m having a hard time working out how to convert the 2 color Floyd-Steinberg algol into an X color algorithm. (indexed?)

I see the calculation would have to be from this line:

var rc = (cc<127?0:255);

Which at the moment is choosing between black and white based on the greyscale value.

So I need to adjust this to find which color of several the pixel should be. I’ve had a think, and I think a LUT would be fastest?

newCol = greyscaleReduced[currentPixelGreyscale];

Is that it? Do I need to adjust the error diffusion in some way?

function floydSteinberg8(sb, w, h){
  for(var i=0; i<h-1; i++)
    for(var j=0; j<w; j++){
      var ci = i*w+j;
      var cc = sb[ci];
          var rc = (cc<127?0:255); // This one changed to 
          var rc = lockedGreyscale[cc];// this one
      var err = cc-rc;
      sb[ci] = rc;
      sb[ci+1] += (err*7)>>4;
      sb[ci+w-1] += (err*3)>>4;
      sb[ci+w] += (err*5)>>4;
      sb[ci+w+1] += (err*1)>>4;

EDIT: I’ve been adjusting my code - is this algorithm ok? I think the weighing of the pixel brightness in indexedGreyscale might be off? So that’s it - just a LUT for the tutuapp brightness!? (The program needs the Play button pressing, Dithering, and to turn color off)