I'm currently making some small edits to Sebastian's dialogue but I'm not entirely sure what some of the coding means. I think some of it tells the game which portrait to use, I'll see something like this at the end of a sentence: #$s# #$e# #$1# etc... Do those letters in the middle coordinate with a specific frame in the portrait file and if so, is there a guide somewhere that tells which is which? I just want to make sure he's making the right face for each dialogue, like, if he says something nice I don't want him to be making an angry face. lol I haven't messed with any of these because I don't want to screw something up, I've only changed the dialogue itself.
For a guide, I'd really recommend Alpha_Omegasis' - "Stardew Valley Modding Guide": http://community.playstarbound.com/threads/modding-guide-feed-back-help-thread.107390/ It's the 2nd link on his post. It covers a lot of topics, but section 3 talks about NPC dialogue editing. And, has a pretty decent explanation covering what you're asking.