Add input callback in lua and error handling in loading scripts