The Hex namespace contains functions that will allow you to obtain information about the hub. And other tasks like sending data to all users and so forth.
Sends sData to all clients that is connected to the hub.
This function does not return a value.
Your are prohibited from sending "$ConnectToMe" and "$RevConnectTome"
Parameters:
-
sData = The data to broadcast
Hex.Broadcast("<LuaScript> Hello World!|")
Posts a message to OpChat.
This function does not return a value.
Parameters:
-
sData = The message to show in opchat
Hex.OpchatMessage("Hi there operators!")
This function returns the number of connected users.
local iUsercount = Hex.UserCount()
This function returns the current hub topic.
local sTopic = Hex.GetTopic()
This function sets the hub topic.
This function does not return a value.
Parameters:
-
sTopic = A string with the new topic.
Hex.SetTopic("This hub is powered by Hex Script")
This function returns the current MOTD (message of the day).
local sMotd = Hex.GetMOTD()
Sets the MOTD (message of the day).
This function does not return a value.
Parameters:
-
sMotd = A string with the new MOTD.
Hex.SetMOTD("Welcome to my hub")
This function returns the hubs uptime in seconds.
local iUptime = Hex.Uptime()
This function returns a string with the version of hexhub.
local sVersion = Hex._GetVersion()
This function returns the path to the scripts directory.
local sFolder = Hex.GetScriptsFolder()
This function returns a new object of type Bot
For more information read the
Bot class section.
This function returns a new object of type HelpString (shown in !help).
The
HelpString class is initialized with two parameters.
-
iSection: 0 = Hub information, 1 = Commands for messages, 2 = Operator commands, 3 = reserved, 4 = Profile management, 5 = DC++ commands, 6 = Extra
-
sLanguage: a 2-letter language identifier (e.g. "EN", "RO", "DE", ect.).
For more information read the
HelpString class section.
myhelpstring = Hex.HelpString(0, "EN")
This function returns a new object of type User.
To iterate through all users connected to the hub use a value of -1 when initializing the object (Hex.User(-1)).
The object returned will be set to the first user found. User:GetUserID will return -1 if no users were found
In Hex Script 1.2.0.1-unstable and greater you can also use a value of -2 to iterate master users (users that has master status over the hex script plugin).
-
iUserId = Identifier of the user you wish to associate with this object.
For more information read the
User class section.
local usr = Hex.User(iUserId)
This function returns a new object of type Right.
-
iUserId = Identifier of the user you wish to associate with this object.
For more information read the
Right class section.
local usrrights = Hex.Right(iUserId)
This function returns a new object of type UserCommand.
For more information read the
UserCommand class section.
usercommand = Hex.UserCommand()
This function returns a new object of type UserCommandEx.
For more information read the
UserCommandEx class section.
Remarks:
This function is only availabe in Hex Script versions >= 1.2.0.0
usercommandex = Hex.UserCommandEx()
This function returns a new object of type Trigger.
For more information read the
Trigger class section.
mytrigger = Hex.Trigger()
This function returns a new object of type Profile.
To iterate through all account profiles use a value of -1 when initializing the object (Hex.Profile(-1)).
The object returned will be set to the first profile found.
For more information read the
Profile class section.
local profile = Hex.Profile(User:GetProfileID())
This function returns a new object of type Timer.
For more information read the
Timer class section.
This function returns the identifier of a user. If the use was not found it returns -1.
For more information read the
Hex.User(iUserId) section.
Parameters:
-
sNickname = the nickname of the user to find a user identifier for
local iUserId = Hex.GetUserID("nickname")
if iUserId == -1 then
-- not found
end
This function sets the copyright text shown in !about trigger
Parameters:
-
sAbout = your name and the year, max length = 50, forbidden chars = "\n"
Hex.SetAboutText("Surname Lastname, 2007-2008")
This function starts a asynchronous execute operation.
When a asynchronous operation has successfully been initiated there is no way to cancel it
Remarks:
When a script is stopped for what ever reason, all asynchronous operations will be canceled and complete with an error code regardless of their state.
For the executer this means that the program executed will be terminated immediately.
There is no limit on the number of async operations allowed other than hardware such as memory.
Parameters:
-
sFile = a fully qualified path to the file to execute.
-
sParameters = the command line parameters
-
sCallback = a string specifying what function to call when the asynchronous operation has completed.
Return values:
-
-4 this operation is not allowed by the hub owner
-
-3 the file does not exist.
-
-2 the thread pool is exhausted.
-
-1 the queue for asynchronous operations is full, try again later
-
0 general error such as out of memory, bad parameters, ect.
-
1 the asynchronous operation was successfully initiated.
Callback:
-- iExitCode = the exit code of the program, or -1 on error executing
-- if the callback returns true the output dumpfile (console output) will be deleted.
function ExecuteCompleted(iExitCode, sFilename)
return true
end
Example:
if Hex.Execute("C:\\file.exe", "", "OnExecuted") ~= 1 then
print("Could not execute file!")
end
function OnExecuted(iExitCode, sFilename)
if iExitCode ~= -1 then
print("File was executed, output is in: "..sFilename)
else
print("Execute failed!")
end
-- read file with output from this program
-- true == delete file
return true
end
This function schedules a message to be sent to another script, the message is guaranteed to be delivered unless the receiving script is not running or does not exist.
If you need to get notification of delivery the receiver script can send you a message back.
Remarks:
When a script is stopped for what ever reason, all asynchronous operations will be canceled and any messages in the queue will be dropped to the bit can.
There is no limit on the number of async operations allowed other than hardware such as memory.
The receiving script has to have
The OnScriptMessage(iMessageCode, sSender, sData) callback
Parameters:
-
sReceiver = The filename of the script that will receive the message; Hex.GetScriptsFolder() + "filename.lau".
-
iMessageCode = a number of your choice to send to the receiver.
-
sData = a message of your choice to send to the receiver.
Example sender script:
-- File: ScriptA.lua
mytimer = Hex.Timer()
mytimer:Start(1000, 1000, "MyTimerProc")
function MyTimerProc(iTimerId)
Hex.SendScriptMessage(Hex.GetScriptsFolder().."ScriptB.lua", 1, "Hello script B")
end
Example receiving script:
-- File: ScriptB.lua
function OnScriptMessage(iMessageCode, sSender, sData)
print("Message recived from: "..sSender.." with message code: "..iMessageCode.." Message: "..sData)
end
This function returns a 2-letter language code specifying the default language of the hub.
local slang = Hex.GetDefaultLanguage()
This function returns the version of the current Hex Script implemtation in use. The return value is an integer.
Remarks:
This function is only available in Hex Script versions >= 1.2.0.0
-- For Hex Script 1.2.0.0 iVersion would be set to 1200
local iVersion = Hex.GetHexScriptVersionInt()
This function returns the string version of the current Hex Script implemtation in use.
Remarks:
This function is only available in Hex Script versions >= 1.2.0.0
-- For Hex Script 1.2.0.0 sVersion would be set to "Hex Script 1.2.0.0"
local sVersion = Hex.GetHexScriptVersionString()
This function stops a scripts execution.
Remarks:
This function is only available in Hex Script versions >= 1.2.0.0
This function returns information about the hub, the following is avaiable acording to HeXHub's plugins.txt
-
"hub_name" - hub name, maximum possible length: 512 bytes (HeXHub 5.02b)
-
"hub_description" - hub description, maximum possible length: 1000 bytes (HeXHub 5.02b)
-
"hub_address" - hub address, maximum possible length: 255 bytes (HeXHub 5.02b)
-
"hub_owner_email" - hub owner's e-mail address, maximum possible length: 255 bytes (HeXHub 5.02b)
-
"path_hub_icon" - path to hub icon, maximum possible length: 255 bytes (HeXHub 5.02b)
-
"hub_topic" - hub's topic, maximum possible length: 2000 bytes (HeXHub 5.02b)
-
"forbid_search" - forbidden words searched in search requests, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"forbid_sr" - forbidden words searched in search results, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"forbid_info" - forbidden words searched in descriptions, e-mails and share sizes, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"forbid_mc" - forbidden words searched in mainchat messages, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"forbid_topic" - forbidden words searched in !topic and !motd, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"forbid_pm" - forbidden words searched in private messages, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"hubbot_responses" - automatic responses of Hub-Security, maximum possible length: 32768 bytes (HeXHub 5.02b)
Remarks:
This function is only available in Hex Script versions >= 1.2.0.1
This function does always return a string, on error a empty ("") string is returned.
Parameters:
-
sWhat = string that specifies what kind of information must be returned
Example:
local hubname = Hex.GetHubInfo("hub_name")
local hubTopic = Hex.GetHubInfo("hub_topic")
This function returns information about the hub, the following is avaiable acording to HeXHub's plugins.txt
-
"hub_name" - hub name, maximum possible length: 512 bytes (HeXHub 5.02b)
-
"hub_description" - hub description, maximum possible length: 1000 bytes (HeXHub 5.02b)
-
"hub_address" - hub address, maximum possible length: 255 bytes (HeXHub 5.02b)
-
"hub_owner_email" - hub owner's e-mail address, maximum possible length: 255 bytes (HeXHub 5.02b)
-
"path_hub_icon" - path to hub icon, maximum possible length: 255 bytes (HeXHub 5.02b)
-
"hub_topic" - hub's topic, maximum possible length: 2000 bytes (HeXHub 5.02b)
-
"forbid_search" - forbidden words searched in search requests, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"forbid_sr" - forbidden words searched in search results, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"forbid_info" - forbidden words searched in descriptions, e-mails and share sizes, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"forbid_mc" - forbidden words searched in mainchat messages, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"forbid_topic" - forbidden words searched in !topic and !motd, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"forbid_pm" - forbidden words searched in private messages, maximum possible length: 32768 bytes (HeXHub 5.02b)
-
"hubbot_responses" - automatic responses of Hub-Security, maximum possible length: 32768 bytes (HeXHub 5.02b)
Remarks:
This function is only available in Hex Script versions >= 1.2.0.1
This function returns -1 on error, otherwise success is indicated.
Parameters:
-
sWhat = string that specifies what kind of information must be returned
-
sData = string with the new value to be set
Example:
if Hex.SetHubInfo("hub_name", "new hub name for this hub here") == -1 then
-- error
end