Detect lua5.2 and improve the script