creating a lua program for character simulation in a dynamic environment