Port hex script to lua3.2