Go to file
AliasAlreadyTaken 737aea012f Adds MIT license
2024-06-02 02:19:22 +02:00
dev Initial commit 2023-09-17 20:30:37 +00:00
.luacheckrc Initial commit 2023-09-17 20:30:37 +00:00
api.lua your-land/yl_announcements#2 Changes wrong minutes to seconds in help and documentation 2024-05-27 23:25:03 +02:00
chatcommand_add.lua your-land/yl_announcements#6 Adds help command 2024-05-29 03:00:13 +02:00
chatcommand_copy.lua your-land/yl_announcements#6 Adds help command 2024-05-29 03:00:13 +02:00
chatcommand_delete.lua Formatting 2024-05-29 03:14:39 +02:00
chatcommand_help.lua Formatting 2024-05-29 03:14:39 +02:00
chatcommand_list_all.lua Formatting 2024-05-29 03:14:39 +02:00
chatcommand_list.lua Formatting 2024-05-29 03:14:39 +02:00
chatcommand_say_all.lua Formatting 2024-05-29 03:14:39 +02:00
chatcommand_say.lua Formatting 2024-05-29 03:14:39 +02:00
chatcommands.lua Formatting 2024-05-29 03:14:39 +02:00
config.lua Rename priv to privs to match README 2024-05-10 09:23:04 +02:00
globalsteps.lua Formatting 2024-05-29 03:14:39 +02:00
init.lua Implements globalstep to actually deliver the announcements 2024-05-27 19:38:31 +02:00
initialize.lua Adds run_each_serverstart 2024-05-10 09:54:06 +02:00
internal.lua Formatting 2024-05-29 03:14:39 +02:00
LICENSE Adds MIT license 2024-06-02 02:19:22 +02:00
mod.conf Changes mod.conf to yl_announcement values instead of template 2024-05-10 07:06:28 +02:00
README.md Replaces terrible screenshot with good screenshot 2024-06-02 02:11:37 +02:00
screenshot.png Replaces terrible screenshot with good screenshot 2024-06-02 02:11:37 +02:00
settingtypes.txt Adds settingtypes 2024-05-10 09:48:57 +02:00
setup.lua Adds setup 2024-05-10 09:51:05 +02:00

yl_announcements

Purpose

This mod allows you to send messages to your players in an interval.

Download

Get it from https://gitea.your-land.de/your-land/yl_announcements

Installation

  1. Copy the "yl_announcements" folder to your mod directory.
  2. Enable the mod in your world.mt file.

Configuration

yl_announcements.debug = false

Set to true to enable debug mode

yl_announcements.save_path

Set this to where in the worldfolder you want the JSON files stored.

yl_announcements.colour

Set this to the colour you want the announcements have in chat

yl_announcements.frequency

Set this to the default repeat timer you want the announcements have in chat. 3600 means "once per hour"

yl_announcements.user_privs
yl_announcements.admin_privs

Set those to the list of privs you want to allow the execution of the corresponding commands:

yl_announcements.user_privs allows

  • listing single announcement
  • copy single announcement
  • listing all announcements

yl_announcements.admin_privs allows

  • listing single announcement
  • copy single announcement
  • listing all announcements
  • add announcement
  • delete announcement
  • say announcement to main chat
  • say all announcements to main chat

Usage

This mod targets servers, but should work in singleplayer, too. It comes with no direct content but exposes functions you can use in your mod.

Data structure

One announcement consists of an id, a message, an owner, a runtime and a frequency. Example:

{
    id = 1,
    creation_date = os.time(),
    message = "[EVENT] Don't forget to join the event tonight!",
    owner = "Admin",
    runtime = 1000000,
    frequency = 3600
}

Those announcements sit in a table with id as index:

{
    1 = {announcement},
    2 = {announcement},
    ["5"] = {announcement}
}

Chatcommands

/announcement_add message$frequency in seconds$runtime in seconds

Sends the message each frequency seconds for a maximum number of runtime seconds.

/announcement_copy announcement_id

Open the announcement with ID in a formspec, so it can be copied.

/announcement_delete announcement_id

Delete the announcement ID.

/announcement_list

List announcement with ID to you.

/announcement_list_all

Lists all announcements to you.

/announcement_say announcement_id

Say the announcement with ID in main chat.

/announcement_say_all

Say all announcements in main chat.

Modmakers

Use the following public functions to get, set, list and remove announcements

yl_announcements.get(announcement_id)

Returns a table with the values of this announcement_id. Returns nil, if it does not exist. Returns false, "errormessage" if an error occurred.

yl_announcements.set(message, frequency, runtime, owner)

Adds this announcement to the list and returns true, announcement_id if accepted, false, "errormessage" if not.

yl_announcements.formspec(announcement_id)

Returns true, formspecstring if an announcement was found, with formspecstring including the /announcement_add string, so it can be easily copied from. Returns false, errormessage if an error occurred.

yl_announcements.delete(announcement_id)

Returns true, {announcement} if one task was successfully removed, false, "errormessage" otherwise.

yl_announcements.list()

Returns true, { id = {announcement}, ... } if one or more announcements were found or false, {} if none were found.

yl_announcements.say(announcement_id)

Returns true, {announcement} if one announcement was found or false, {} if none were found.

Limitations

  • No colours
  • No tags like [EVENT]

Alternatives

  • For immediate one-time announcements, use the notification mod
  • For future one-time announcements, use the yl_scheduler mod

Supported versions

If you run yl_announcements, but something is wrong, please file a bug. PRs also welcome.

There is no reason to believe it doesn't work anywhere, but you never know.

Allied projects

If you know a project that uses this mod tell us and we will add it to the list.

Uninstall

Remove it from your mod folder or deactivate it in your world.mt

Mods that depend on it will cease to work, if the mod is removed without proper replacement.

License

  • Code MIT AliasAlreadyTaken
  • Screenshot CC0 Styxcolor

Thank you

  • Styxcolor