- Joined
- Feb 20, 2015
- Messages
- 79
About the System
LUA ToastBuilder is a customizable notification system for Warcraft 3, written in Lua. It supports personal queues for each player, intelligent merging of similar messages, and replacement of outdated toasts using a shared key. It also features progress bars (including segmented ones) with smooth animation, sound effects, and flexible style settings in a separate module—all of which eliminates spam and makes the game interface informative, dynamic, and concise.
Introductory
I've coded several new systems for my "Divine Roguelike" map. I'll be gradually releasing them if anyone's interested.
I'm fairly self-aware of my skills, and I understand that I couldn't have done this without the code. So if you find any errors, synchronization risks, or suboptimal paths, please let me know. I've done my best to minimize the reliance on synchronization, the possibility of leaks, etc.
Peculiarities
Customizable notification mechanism, including:
1) Waiting queue. New notifications are not displayed until the queue is empty. Each player has their own personal queue. Mixing personal and shared notifications is allowed.
2) Merging similar notifications. For example, two notifications, "+50 experience" and "+100 experience," received in a short period of time will merge into "+150 experience."
3) Replacing general notifications. For example, when quickly killing quest wolves, the "1/3 of the wolves killed" notification will be replaced by "2/3 of the wolves killed," then replaced by "quest completed," and then "quest reward." All these toasts are united by a single key, which prevents spam with outdated information from appearing on the screen. This is achieved by combining the toast key=AnyQuest (string, handle, or object), + replace = true.
4) Waiting for general notifications. A toast with the specified key will not display while the player is displaying other notifications with the same key. For example, you can create two notifications simultaneously: "You have entered a dangerous zone" or "The enemy and loot levels have increased." These notifications will display one after the other, but not simultaneously. These toasts may appear at different times for different players, for example, if they have other local toasts running or if the queue is full. This is achieved by combining key="extraDanger" + replace = true (the toast will replace the toast with the same key) + waitKey = true (but the toast will wait until another toast with the same key has disappeared before adding or replacing it), + (optional) waitKeyFade = true (instead of waiting for the previous toast to completely disappear, it will wait until the previous toast starts its disappearing animation and then replace it).
5) Progress bars on notifications. Solid and segmented. Set at the style level. For example, a segmented progress bar can be attached to the "3 out of 7 wolves killed" toast. This segmented progress bar actually consists of 7 mini-progress bars, 3 of which are filled. A non-integer number can be filled if desired. For example, "50% of wave 2/3 completed" can fill the segmented progress bar by 2.5, in which case 2 bars will be fully filled, and the 3rd bar will be half-filled.
6) Smooth animation of bar filling when replacing toasts. If toasts replace each other and they have different values for the current progress bar, the bar in the new toast will gradually fill from the previous value. This also works well with repeated spam notifications of the same type (for example, if you kill 7 wolves at once, the progress bar will beautifully fill from 1 to 7).
7) Other beautiful animations. For example, when replacing a toast, its icon pops up. 8) Sound Accompaniment - you can configure different appearance sounds for different styles. For example, "quest received," "warning," etc.
9) Toast styles and constants are configured in a separate module. You can create your own toast styles and call them.
10) There is no 10th item; I just didn't want to stop at number 9.
Example
The toast system scripts are contained in two required files:ToastsConfig.luaToasts.lua(in that order)Then come the scripts for the map itself that uses this system. Specifically, "RoguelikeToasts.lua" contains convenient map-specific functions. These can be examined as an example. They reuse {} to minimize dynamic table creation during gameplay.
Examples of calling toasts
Lua:
local testQuest = {} -- a placeholder quest just for example
local toastOptions = {
style = "taskUpdated",
key = testQuest,
replace = true,
duration = 4,
icon = "ReplaceableTextures\\CommandButtons\\BTNTimberWolf.blp",
title = "One Chicken's Request",
text = "Wolves killed 1/7",
progressCurrent = 1,
progressMax = 7
}
Toasts.show(toastOptions)
-- after a couple of seconds
local toastOptionsComplete = {
style = "taskCompleted",
key = testQuest,
replace = true,
duration = 4,
icon = "ReplaceableTextures\\CommandButtons\\BTNTimberWolf.blp",
title = "One Chicken's Request",
text = "All the wolves are killed!",
progressCurrent = 1,
progressMax = 1
}
Toasts.show(toastOptionsComplete)
(Note: To avoid constantly recreating tables, you can reuse them by changing the parameters. This will not cause errors.)If a player kills two monsters from two different quests in a short period of time, the toasts for the two quests will not overlap, and their notifications will be displayed in parallel.
I've been a bit tired lately, so I've only described one type of toast in the example. Other types are in the example map in the Toasts folder. But if you're interested in a specific technique (like in the video), let me know what you're interested in, and I'll fill those examples in among the first ones when the resources become available.
Attachments
Last edited: