Find a library.
OpenSCAD bundles MCAD, and it has screws.
https://github.com/openscad/MCAD/blob/master/screw.scad
BOSL2 also has screws.
https://github.com/revarbat/BOSL2/wiki/screws.scad
There's also a number of Google hits.
https://www.google.com/search?q=openscad+screw