You could instead make reactions that destroy a chunk of soap and replace it with a new item made out of a version of soap that has a given color. Thus not requiring any lua. And you should still be able to do this in a way that preserves the animal type description. Follow the example of tanning a hide (which destroys skin, makes leather, and still has it labeled as the correct type of leather).
So:
[REACTION:DYE_SOAP_G]
[NAME:dye soap green]
[BUILDING:SOAP_MAKER:CUSTOM_G]
[REAGENT:A:1:NONE:NONE:NONE:NONE][REACTION_CLASS:SOAP] **need to make a reaction class for soap, and also a DYE_SOAP_MAT line in the soap material definition, one for each color, specifying the new materials for each color, and then add all of those to the first two entries in b_detail_plan_default.txt. Repeat this for every variant of soap, if you want people to be able to re-dye them later. Or only include for original soap, if dyeing is a one-time-deal.
[HAS_MATERIAL_REACTION_PRODUCT:DYE_SOAP_MAT]
[REAGENT:B:1:BOULDER:NONE:INORGANIC:OLIVINE]
[PRODUCT:100:1:BAR:NONE:GET_MATERIAL_FROM_REAGENT:soap:DYE_SOAP_MAT] <--not 100% sure that "soap" here is correct, would have to test it, but you get the idea.
[PRODUCT_DIMENSION:150]
[SKILL:DYEING] <--i don't remember the actual tag for this