Ported the lua script engine