Hi guys,
I'm looking for a simple script to have a chat channel which'll contain all whispers
Thanks in advance
Elvang
06-16-2016, 06:10 AM
Hi guys,
I'm looking for a simple script to have a chat channel which'll contain all whispers
Thanks in advance
It's a hud instead of a channel, found in the examples folder with xenobot when downloading.
--[[
This is a XenoBot example script, intended to
teach new users about the scripting API and
act as script that is usable in actual play.
recentPrivateMessageHUD.lua - displays a HUD
showing your most recent private messages.
** DO NOT EDIT THIS FILE. INSTEAD, COPY IT TO
"Documents\XenoBot\Scripts" AND EDIT THE COPY. **
]]--
--set the title of the HUD
local title = "Recent Private Messages:"
local showTitle = true
--set the number of messages to show
local messageCount = 4
--set the maximum message length (including sender name)
local messageLength = 60
--set the top left x and y coordinates of the HUD
local location =
{
x = 25,
y = 5
}
--set the colors for the HUD
local colors =
{
message = {95, 247, 247},
title = {225, 225, 225},
}
-------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------
--this creates the title HUD
if (showTitle == true) then
local HUDTitle = HUD.CreateTextDisplay(location.x, location.y, title, unpack(colors.title))
location.y = location.y + 20 -- just offsets the y axis to below the header
end
--loop from 1 until messageCount, creating HUD objects for each
local HUDData = {}
for index = 1, messageCount do
local data = {}
-- no message yet
data.message = ""
--create the label HUD
data.label = HUD.CreateTextDisplay(
location.x,
-- +12 pixels to the y axis for every item
location.y + ((index - 1) * 12),
data.message,
-- text color
unpack(colors.message)
)
--store the data to use later
HUDData[index] = data
end
--this is a proxy event which gets invoked when a private message is received
PrivateMessageProxy.OnReceive("pmProxy", function (proxy, speaker, level, text)
--create the message from the data
local message = speaker .. " [" .. level .. "]: " .. text
--if the message is too long, this will shorten it
if (string.len(message) > messageLength) then
message = string.sub(message, 0, messageLength - 3) .. "..."
end
--this will move each message "up" (from index 4 to 3, 3 to 2, 2 to 1, etc)
for index = 1, messageCount-1 do
HUDData[index].message = HUDData[index+1].message
HUDData[index].label:SetText(HUDData[index].message)
end
--this will put the new message in the last index
HUDData[messageCount].message = message
HUDData[messageCount].label:SetText(message)
end)
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.