Lua: add do_menu() wrapper. Also fix potential NULL pointer dereference