Cast variables to their own type, and print warning info if no corresponding lua callback function instead of crash

1) cast variables to their own type; 
2) print warning info if no corresponding lua callback function instead of crash;