DOWNLOAD: https://drive.google.com/file/d/1sklK7U1ZNEz_lSmtUxCcwBAPculqVQCt/view?usp=sharing
To use the module, put a button on a GUI, then create a new chat instance:
bgSprite is a sprite slot for the background, it gets auto-tiled if it's smaller than the button. You can also state width and height, in that case the button is resized to those dimensions.
Optionally add sound:
Pass null to disable sound.
To add a message, just call:
If you put an asterisk at the start of the sender, like "*Alice", the message appears on the right. You can optionally state a timestamp, or omit for user's local time.
Adding a message makes the chat scroll down automatically. You can also scroll using the mousewheel, while hovering over the chat.
The chat is automatically drawn and scrolled if the GUI and button are visible.
It's also possible to prepare multiple messages, just call Chat.Prepare() instead. Show them one by one using Chat.Advance(globalHandleInt); or all at once using Chat.ShowAllPrepared(globalHandleInt);.
(Calling .Add() will simply call .Prepare(), then .Advance(), so make sure you have advanced over all prepared messages before using .Add(), or you will get unexpected results )
It is recommended to call Chat.CleanUp() upon quitting the game, this will delete all the DynamicSprites, avoiding a warnings log in the game folder.
Given that most people will probably want to customize the look of the chat, I've moved the function that draws a message to the very top of the module script.
It gets passed all relevant parameters:
and must return a new DynamicSprite containing the message.
Preview of default look:
My example room script: http://pastebin.com/raw/BvruHqr7
To use the module, put a button on a GUI, then create a new chat instance:
bgSprite is a sprite slot for the background, it gets auto-tiled if it's smaller than the button. You can also state width and height, in that case the button is resized to those dimensions.
Optionally add sound:
Pass null to disable sound.
To add a message, just call:
If you put an asterisk at the start of the sender, like "*Alice", the message appears on the right. You can optionally state a timestamp, or omit for user's local time.
Adding a message makes the chat scroll down automatically. You can also scroll using the mousewheel, while hovering over the chat.
The chat is automatically drawn and scrolled if the GUI and button are visible.
It's also possible to prepare multiple messages, just call Chat.Prepare() instead. Show them one by one using Chat.Advance(globalHandleInt); or all at once using Chat.ShowAllPrepared(globalHandleInt);.
(Calling .Add() will simply call .Prepare(), then .Advance(), so make sure you have advanced over all prepared messages before using .Add(), or you will get unexpected results )
It is recommended to call Chat.CleanUp() upon quitting the game, this will delete all the DynamicSprites, avoiding a warnings log in the game folder.
Given that most people will probably want to customize the look of the chat, I've moved the function that draws a message to the very top of the module script.
It gets passed all relevant parameters:
and must return a new DynamicSprite containing the message.
Preview of default look:
My example room script: http://pastebin.com/raw/BvruHqr7