TS-1682 lua plugin compile breaks on FreeBSD.

add a static_cast to fix this "warning: comparison between signed and
unsigned integer expressions"