Another test was the Chat UI. Can we take the focus from the game and put it on our text entry. Then when that's closed, can we return it to the game.
This sounds like simple stuff, but it can be a pain in the ass. Like do binds still run in the game when we're chatting. If we press enter to send a chat message, which closes the text entry box, does the game then pick up the enter key and run the bind on it.
This also was an opportunity to work out the server/client architecture and how they interact. In Garry's Mod the server and client Lua states are separate. In Sandbox they're running in the same realm.
So check this out, all this code is on the ChatUI control.
This gets called when you press enter on the text entry. It's easy enough to read, close the box, clear the text entry text, if the message they typed isn't bullshit we call the Say function.
But check that out, the Say function is a console command.. and it's server-side.
There's some nice magic happening here in the background that you don't need to worry about. If you're a listen server or single player, it'll just call it. If not, it'll send a message to the server and call it there.
So the server just calls the function Chat_Add with a list of players, the calling player's name and the message they passed in.
Here's some more magic. This is a client command.
Something you'll notice is that it doesn't even take a list of players, that's just magic. That function is generated automatically. You don't get any compile errors or intellisense errors, we just done some magic for you.
So the chat_add command just get the Current ChatUI instance and adds the chat entry.
Give this section and thumbs up it that makes sense, or a thumbs down if you're really confused.