Chat System

This bundle is marked as awaiting update. A staff member has requested changes to it before it can be approved.

A simple chat system created by me, to provide you with easy and comfortable chat handling.
(Observer chat & Whispers are disabled in this system due to problems with sync!)
I'm open for any feedback and suggestions.

JASS API

Lua API

Patch Notes

Default Imports Explanation

Variables

Contact Information

Public Functions that may be used outside of System.
function getMessageSender takes integer messageID returns string
  • Message Info function of the chat system. Can be used to retrieve a message sender.
  • messageID is a iteration of all messages starting at 0.
  • The returned string is the player color + the player name.
  • Example Usage: call getMessageSender(messageID)
function getMessageContent takes integer messageID returns string
  • Message Info function of the chat system. Can be used to retrieve a message content.
  • messageID is a iteration of all messages starting at 0.
  • The returned string is the text the message had.
  • Example Usage: call getMessageContent(messageID)
function getMessageType takes integer messageID returns string
  • Message Info function of the chat system. Can be used to retrieve a message type.
  • messageID is a iteration of all messages starting at 0.
  • The returned string is the estimated type of the message.
  • Example Usage: call getMessageType(messageID)
function getMessageReceivers takes integer messageID returns string
  • Message Info function of the chat system. Can be used to retrieve a list of everyone that received the message.
  • messageID is a iteration of all messages starting at 0.
  • The returned string is a list of all players that received the message (player id).
  • Example Usage: call getMessageReceivers(messageID)
function getMessageTime takes integer messageID returns string
  • Message Info function of the chat system. Can be used to retrieve the time the message was sent.
  • messageID is a iteration of all messages starting at 0.
  • The returned string is the time when the message was sent.
  • Example Usage: call getMessageTime(messageID)
function sendSystemMessage takes integer receiver, string message returns nothing
  • System Message function of the chat system. It can be used to send a system message to a single player.
  • Example Usage: call sendSystemMessage(0, "Hello Player Red!")
function sendSystemMessageMultiple takes integer receivers, string message returns nothing
  • System Message function of the chat system. It can be used to send a system message to a multiple players.
  • Receivers is a geometric sequence with the formula "pow(2, playerID)"
  • Following example sends the message to player red, blue and purple.
  • Example Usage: call sendSystemMessageMultiple(11, "Hello Red, Blue, Purple!")
    • 11 (base 10) represented in binary (base 2) is 1011. The player ids of red, blue and purple using GetPlayerId are 0, 1 and 3 respectively. If we look closely at the binary value, and take note of the bits where the value is 1, we can easily see that the "flagged" bits (where the value is 1) are found in the 0th, 1st and 3rd positions respectively, the same as our player ids (the 0th bit is the rightmost bit in this case).
function print takes string message returns nothing
  • System Message function of the chat system. It can be used to send a system message to a all players.
  • Example Usage: call print("Hello World!")

Public Functions that may be used outside of System.
function getMessageSender(int messageID) -> string
  • Message Info function of the chat system. Can be used to retrieve a message sender.
  • messageID is a iteration of all messages starting at 0.
  • The returned string is the player color + the player name.
  • Example Usage: getMessageSender(messageID)
function getMessageContent(int messageID) -> string
  • Message Info function of the chat system. Can be used to retrieve a message content.
  • messageID is a iteration of all messages starting at 0.
  • The returned string is the text the message had.
  • Example Usage: getMessageContent(messageID)
function getMessageType(int messageID) -> string
  • Message Info function of the chat system. Can be used to retrieve a message type.
  • messageID is a iteration of all messages starting at 0.
  • The returned string is the estimated type of the message.
  • Example Usage: getMessageType(messageID)
function getMessageReceivers(int messageID) -> string
  • Message Info function of the chat system. Can be used to retrieve a list of everyone that received the message.
  • messageID is a iteration of all messages starting at 0.
  • The returned string is a list of all players that received the message (player id).
  • Example Usage: getMessageReceivers(messageID)
function getMessageTime(int messageID) -> string
  • Message Info function of the chat system. Can be used to retrieve the time the message was sent.
  • messageID is a iteration of all messages starting at 0.
  • The returned string is the time when the message was sent.
  • Example Usage: getMessageTime(messageID)
function sendSystemMessage(int receiver, string message)
  • System Message function of the chat system. It can be used to send a system message to a single player.
  • Example Usage: sendSystemMessage(0, "Hello Player Red!")
function sendSystemMessageMultiple(int receivers, string message)
  • System Message function of the chat system. It can be used to send a system message to a multiple players.
  • Receivers is a geometric sequence with the formula "pow(2, playerID)"
  • Following example sends the message to player red, blue and purple.
  • Example Usage: sendSystemMessageMultiple(11, "Hello Red, Blue, Purple!")
function print(string message)
  • System Message function of the chat system. It can be used to send a system message to a all players.
  • Example Usage: call print("Hello World!")


v0.1
  • Release Version
v0.1*
  • Lua Release Version
[REQUIRED]
UI\ChatSystem.toc -> Loads the UI\ChatSystem.fdf file
UI\ChatSystem.fdf -> Defines the frames used by chat system

How to import:
  1. Import UI\ChatSystem.fdf into your map
  2. Import UI\ChatSystem.toc into your map
  3. Copy-paste Chat System Script into your map

systemIcon -> Icon used by System Messages (defaults to null)

playerColor -> Color of player name in chat (defaults to standard player color)

playerIcon -> Icon used by individual Player Messages (defaults to Peasant)​

If you have any problems or questions related to this system,
feel free to ask me on discord under the name Niklas#0786.



Contents

Chat System (Map)

Chat System [Lua] (Map)

In the Lua version, there appears to be a lot of closure functions being employed (and generated) when using certain public functions such as print, sendSystemMessage, sendPlayerMessage and so on. I suggest declaring them as their own functions.

The chat system also appears to have functions which should behave as private functions, but are accessible everywhere (due to the global table _G. You can hide these functions from the global scope by doing the following:

Lua:
do
    local function convertTime(...)
    end
    local function sizeCheck(...)
    end
    function sendSystemMessage(...)
    end
end

The for-loops in the system appear to have an unnecessary parameter, and also contains "magic" numbers.

Lua:
-- An experienced modder would likely already know the meaning behind the numbers 0 and 23
-- after a careful inspection.
for pID = 0, 23, 1 do
    -- do stuff
end

You can remove the trailing 1 from the for-loop block and identify the purpose of the "magic" number by storing it as a "constant".
Lua:
local MAX_PLAYERS = 24
MAX_PLAYERS = MAX_PLAYERS - 1

for pID = 0, MAX_PLAYERS do
    -- do stuff
end

Indentation in the code might be a bit wonky.

EDIT:
Forgot to place this under Awaiting Update
 
Top