Horthex
Little Mouse
Chat Message Box
A small script to replace tfm.exec.chatMessage()
As some of you may know the tfm.exec.chatMessage() function is no longer available for normal users. Some people suggested that print() is a worthy alternative, but it can't be formatted and it's only available to the person who executed the code. The only REAL alternative is using the ui.addTextArea() function, and my script is based on that. It adds a tiny chat message box on the top left of the screen where your messages will be displayed. It has a "+" and "-" sign, where you can go back and forth between the messages your displayed via the chatBox() function.A small script to replace tfm.exec.chatMessage()
chatBox(text,show)
Displays a message.
Parameters:
- text (string) - The message you want to display.
- show (string) - The name of the player you want the message to be displayed to. (if it's nil, it will be displayed to everyone)
The Code
Code:
chatBoxText = {}
function chatBox(text,show)
table.insert(chatBoxText,text)
chatBoxTextCounter = 0
for index,name in pairs(chatBoxText) do
chatBoxTextCounter = chatBoxTextCounter + 1
end
callbackCounter = chatBoxTextCounter
ui.addTextArea(666,"\t\t"..chatBoxText[chatBoxTextCounter],nil,7,28,476,20,0x324650,0x000000,1,false)
ui.addTextArea(667,"<a href = 'event:up'>+",nil,8,30,15,15,0x324650,0x324650,1,false)
ui.addTextArea(668,"<a href = 'event:down'>-",nil,32,30,15,15,0x324650,0x324650,1,false)
end
function eventTextAreaCallback(textAreaID,playerName,callback)
if callback == "up" then
if (callbackCounter-1) ~= 0 then
callbackCounter = callbackCounter - 1
ui.updateTextArea(666,"\t\t"..chatBoxText[callbackCounter],show)
ui.updateTextArea(667,"<a href = 'event:up'>+",nil)
ui.updateTextArea(668,"<a href = 'event:down'>-",nil)
end
elseif callback == "down" then
if (callbackCounter + 1) <= chatBoxTextCounter then
callbackCounter = callbackCounter + 1
ui.updateTextArea(666,"\t\t"..chatBoxText[callbackCounter],show)
ui.updateTextArea(667,"<a href = 'event:up'>+",nil)
ui.updateTextArea(668,"<a href = 'event:down'>-",nil)
end
end
end
chatBox("Example of the chatBox function.",nil)
