Subtle Messages are generally small, temporary messages (They can be made to appear permanent) that pop up on a player's screen, like a quick notification.
Let's make your mod send a welcome message when it loads. Open the main.lua file we created in the previous step and find the OnModLoaded function and add tm.playerUI.AddSubtleMessagesForAll, AddSubtleMessageForAll does exactly as the name implies; it creates a Subtle Message for all players that are currently in the server whilst the mod is running.
function OnModLoaded()
tm.os.Log("My UI Mod is ready!")
-- Send a quick message to *all* players.
-- "Mod Started!" is the big text, "Welcome!" is the smaller text.
-- The '3.0' means it stays for 3 seconds. The '' is for an optional image.
tm.playerUI.AddSubtleMessageForAllPlayers("Mod Started!", "Welcome to the game!", 3.0, "")
end
Save the file and active the mod in Trailmakers, you should see large text of "Mod Started" and smaller text of "Welcome to the game!".Â
We can also use Subtle Messages as a way to notify everyone that a player joined the server, this can be done by combining Subtle Message with OnPlayerJoined.
function OnPlayerJoined(player)
local playername = tm.players.GetPlayerName(player.playerId)
tm.playerUI.AddSubtleMessageForAllPlayers("Player Joined", playername, 3.0, "")
end
The above code will trigger everytime someone joins the server whilst the mod is running, it will say "Player Joined" and the players username for 3 seconds.
Subtle Messages can be used in various scenarios and offer much more functionality but for this guide; this is as much as we will cover for Subtle Messages. In the next step we will cover Labels.