Raytrace materials - how bad can it be?

Thanks, but should we replace something in this code to get it working?
I got “map” undefined when running the script on max 2014.
Thanks