Created: 2026/07/02 19:41:27 America/Chicago
By: admin
Modified: 2026/07/03 16:24:56 America/Chicago
By: admin

The time.lua script creates a small user-list entry whose name changes to show the current time. Use it when a Verlihub hub needs a visible timezone marker for international users, regional rooms, or operators who coordinate across time zones.

The script does not require a separate external bot process. It uses the Verlihub Lua plugin to create a bot-like entry inside the hub user list. A clock entry can look like this:

!_US_06:30:00PM

You can change the prefix, postfix, time format, update interval, and timezone offset before loading the script.

What This Script Does

The script builds the display name from three parts:

prefix + current time + postfix

Example output:

!_US_06:30:00PM

The visible user-list entry updates on a timer so the displayed time remains current.

Use this script for:

  • Showing a hub timezone.
  • Showing a regional clock.
  • Helping international users coordinate time.
  • Creating a simple visual marker in the user list.
  • Adding a small utility bot without running external software.

Requirements

This script requires:

  • Verlihub installed and running.
  • The Verlihub Lua plugin installed.
  • The Lua plugin enabled in Verlihub.
  • Permission to load and unload Lua scripts.
  • A writable script directory for Verlihub Lua files.

Before loading the script, confirm that the Lua plugin is active:

!pluglist

If the Lua plugin is not listed, load or enable it first from the parent Lua setup article.

Use a dedicated script directory:

mkdir -p /PATH/TO/HUB/scripts

Place the script at:

/PATH/TO/HUB/scripts/time.lua

For production systems, the directory should be writable only by trusted administrators or by the Verlihub service user. Do not make the directory world-writable.

Load And Unload Commands

Load the script:

!luaload /PATH/TO/HUB/scripts/time.lua

Unload the script:

!luaunload /PATH/TO/HUB/scripts/time.lua

If you edit the script, unload it and load it again:

!luaunload /PATH/TO/HUB/scripts/time.lua
!luaload /PATH/TO/HUB/scripts/time.lua

Use the full absolute path unless your Verlihub Lua plugin configuration supports relative paths.

Script Code

name = ''
class = 3
description = 'Time Bot: US'
speed = '100'
email = ''
share = '0'
prefix = '!_US_'
postfix = ''
interval = 10
counter = 0
format = "%I:%M:%S%p"
offset = -5

function GetTime()
    return os.date(format, os.time() + offset * 60 * 60)
end

function GetName()
    time = GetTime()
    return prefix..time..postfix
end

Configuration Options

name

name = ''

The base name value for the bot-like entry. In this script, the visible name is generated by GetName(), so name can usually remain empty.

class

class = 3

Controls the displayed class or profile level of the bot-like entry. The exact meaning of class values depends on the hub configuration. In many hub setups, higher class numbers represent elevated user roles.

Use a class value that fits how you want the clock entry to appear in the user list.

description

description = 'Time Bot: US'

The description shown for the bot-like entry. Use this to explain what the entry represents.

description = 'Time Bot: US'
description = 'Time Bot: UTC'
description = 'Hub Clock'
description = 'Server Time'

speed

speed = '100'

The connection speed value displayed for the bot-like entry. This is mostly cosmetic. It does not control how often the script updates.

email

email = ''

The email field shown for the bot-like entry. Leave it empty unless you want to display a contact address.

share

share = '0'

The share size displayed for the bot-like entry. For a clock bot, 0 is appropriate because it is not a real file-sharing user.

prefix

prefix = '!_US_'

Text placed before the generated time. This makes the clock easy to identify in the user list.

prefix = '!_US_'
prefix = '!_UTC_'
prefix = '[TIME] '
prefix = 'Clock_'

Choose a prefix that sorts clearly in your hub user list.

postfix

postfix = ''

Text placed after the generated time.

postfix = ''
postfix = '_EST'
postfix = '_UTC'
postfix = ' HubTime'

interval

interval = 10

Controls how often the script should update, usually in seconds. Keep the interval reasonable. Updating every second is usually unnecessary for a hub user-list entry.

  • 10: useful for a visible seconds-based clock.
  • 30: a good balance for many hubs.
  • 60: best for minute-only clocks.

If your format does not show seconds, use 60.

format = "%I:%M%p"
interval = 60

counter

counter = 0

Internal counter used by the script. Do not change this unless you are modifying the script logic.

format

format = "%I:%M:%S%p"

Controls how the time is displayed. This uses Lua os.date formatting. The default format displays 12-hour time with seconds and AM/PM.

Example output:

06:30:00PM

Common formats:

format = "%I:%M:%S%p"      -- 06:30:00PM
format = "%I:%M%p"         -- 06:30PM
format = "%H:%M:%S"        -- 18:30:00
format = "%H:%M"           -- 18:30
format = "%Y-%m-%d %H:%M"  -- 2026-07-02 18:30

For user-list entries, shorter formats are usually easier to read.

offset

offset = -5

Timezone difference from the server time, in hours. The script calculates time using:

os.time() + offset * 60 * 60

Examples:

offset = 0    -- same as server time
offset = -5   -- five hours behind server time
offset = 1    -- one hour ahead of server time
offset = 5.5  -- five and a half hours ahead, if fractional offsets work in your Lua environment

This is a fixed offset. It does not handle daylight saving time rules automatically unless the server time and offset are adjusted. For daylight saving changes, update the offset when needed.

Example Configurations

US Eastern Time Style

description = 'Time Bot: US Eastern'
prefix = '!_US_'
postfix = ''
interval = 60
format = "%I:%M%p"
offset = -5

Example display:

!_US_06:30PM

UTC Clock

description = 'Time Bot: UTC'
prefix = '!_UTC_'
postfix = ''
interval = 60
format = "%H:%M"
offset = 0

Example display:

!_UTC_23:30

24-Hour Hub Clock

description = 'Hub Clock'
prefix = '!_TIME_'
postfix = ''
interval = 60
format = "%H:%M"
offset = 0

Example display:

!_TIME_18:30

For most hubs, use a minute-only clock:

prefix = '!_US_'
postfix = ''
interval = 60
format = "%I:%M%p"
offset = -5

This reduces unnecessary updates while keeping the clock readable.

Use seconds only when you want a live clock effect:

interval = 10
format = "%I:%M:%S%p"

A one-second update interval is usually unnecessary for a hub user-list entry:

interval = 1

Testing The Script

After loading the script, check the hub user list for the generated time entry.

Confirm that:

  • The entry appears only once.
  • The displayed time is correct.
  • The prefix and postfix look right.
  • The update interval is not too aggressive.
  • The entry disappears after unloading the script.
  • Reloading the script does not create duplicates.

If the time is wrong, check the server timezone and the configured offset.

On the server, check current system time:

date
timedatectl

Troubleshooting

The Script Does Not Load

Check that the Lua plugin is active:

!pluglist

Check that the file path is correct:

!luaload /PATH/TO/HUB/scripts/time.lua

Use the absolute path if relative paths do not work.

The Time Is Incorrect

Check:

  • Server timezone.
  • offset value.
  • Daylight saving time.
  • Whether the server clock is synchronized.

Server checks:

date
timedatectl

If the server time is correct but the displayed clock is wrong, adjust offset.

The Script Creates Duplicate Entries

Unload the script and confirm the old entry disappears:

!luaunload /PATH/TO/HUB/scripts/time.lua

Then load it again:

!luaload /PATH/TO/HUB/scripts/time.lua

If duplicates remain, restart the Lua plugin or the Verlihub service during a maintenance window.

The Clock Updates Too Often

Increase the interval.

interval = 60
format = "%I:%M%p"

If seconds are displayed, use:

interval = 10
format = "%I:%M:%S%p"

Users Are Confused By The Entry

Make the prefix or description clearer.

prefix = '!_HUB_TIME_'
description = 'Hub Time Clock'

Safety Notes

This script is small, but it still runs inside the Verlihub Lua environment. Keep the script focused on calculating the current time and updating the display name.

Do not add:

  • External HTTP requests.
  • Database queries.
  • File scanning.
  • Long loops.
  • Blocking sleep calls.

Maintenance Notes

Keep a backup before changing the script:

cp /PATH/TO/HUB/scripts/time.lua /PATH/TO/HUB/scripts/time.lua.bak

If using Git:

cd /PATH/TO/HUB/scripts
git add time.lua
git commit -m "Update time.lua clock settings"

When changing only the prefix, postfix, format, interval, or offset, no code logic changes are required.

Parent Page