From c49884062ea469da4f935a8a9187d446810c2857 Mon Sep 17 00:00:00 2001 From: AliasAlreadyTaken Date: Sun, 2 Jun 2024 03:27:35 +0200 Subject: [PATCH] Refactors announcement to ticker. Great headache! --- README.md | 114 +++++++++++++------------- api.lua | 124 ++++++++++++++-------------- chatcommand_add.lua | 18 ++-- chatcommand_copy.lua | 22 ++--- chatcommand_delete.lua | 22 ++--- chatcommand_help.lua | 20 ++--- chatcommand_list.lua | 22 ++--- chatcommand_list_all.lua | 20 ++--- chatcommand_say.lua | 22 ++--- chatcommand_say_all.lua | 20 ++--- chatcommands.lua | 16 ++-- config.lua | 14 ++-- globalsteps.lua | 66 +++++++-------- init.lua | 42 +++++----- initialize.lua | 6 +- internal.lua | 172 +++++++++++++++++++-------------------- mod.conf | 4 +- settingtypes.txt | 22 ++--- setup.lua | 4 +- 19 files changed, 375 insertions(+), 375 deletions(-) diff --git a/README.md b/README.md index d1cacc8..b8b99db 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# yl_announcements +# yl_ticker ## Purpose @@ -7,54 +7,54 @@ 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 +Get it from https://gitea.your-land.de/your-land/yl_ticker ## Installation -1. Copy the "yl_announcements" folder to your mod directory. +1. Copy the "yl_ticker" folder to your mod directory. 2. Enable the mod in your world.mt file. ## Configuration ``` -yl_announcements.debug = false +yl_ticker.debug = false ``` Set to true to enable debug mode ``` -yl_announcements.save_path +yl_ticker.save_path ``` Set this to where in the worldfolder you want the JSON files stored. ``` -yl_announcements.colour +yl_ticker.colour ``` -Set this to the colour you want the announcements have in chat +Set this to the colour you want the ticker have in chat ``` -yl_announcements.frequency +yl_ticker.frequency ``` -Set this to the default repeat timer you want the announcements have in chat. 3600 means "once per hour" +Set this to the default repeat timer you want the ticker have in chat. 3600 means "once per hour" ``` -yl_announcements.user_privs -yl_announcements.admin_privs +yl_ticker.user_privs +yl_ticker.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_ticker.user_privs allows +* listing single ticker +* copy single ticker +* listing all tickers -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 +yl_ticker.admin_privs allows +* listing single ticker +* copy single ticker +* listing all tickers +* add ticker +* delete ticker +* say ticker to main chat +* say all tickers to main chat ## Usage @@ -62,7 +62,7 @@ This mod targets servers, but should work in singleplayer, too. It comes with no ### Data structure -One announcement consists of an id, a message, an owner, a runtime and a frequency. Example: +One ticker consists of an id, a message, an owner, a runtime and a frequency. Example: ``` { @@ -75,99 +75,99 @@ One announcement consists of an id, a message, an owner, a runtime and a frequen } ``` -Those announcements sit in a table with `id` as index: +Those tickers sit in a table with `id` as index: ``` { - 1 = {announcement}, - 2 = {announcement}, - ["5"] = {announcement} + 1 = {ticker}, + 2 = {ticker}, + ["5"] = {ticker} } ``` ### Chatcommands ``` -/announcement_add message$frequency in seconds$runtime in seconds +/ticker_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 +/ticker_copy ticker_id ``` -Open the announcement with ID in a formspec, so it can be copied. +Open the ticker with ID in a formspec, so it can be copied. ``` -/announcement_delete announcement_id +/ticker_delete ticker_id ``` -Delete the announcement ID. +Delete the ticker ID. ``` -/announcement_list +/ticker_list ``` -List announcement with ID to you. +List ticker with ID to you. ``` -/announcement_list_all +/ticker_list_all ``` -Lists all announcements to you. +Lists all ticker to you. ``` -/announcement_say announcement_id +/ticker_say ticker_id ``` -Say the announcement with ID in main chat. +Say the ticker with ID in main chat. ``` -/announcement_say_all +/ticker_say_all ``` -Say all announcements in main chat. +Say all tickers in main chat. ### Modmakers -Use the following public functions to get, set, list and remove announcements +Use the following public functions to get, set, list and remove ticker ``` -yl_announcements.get(announcement_id) +yl_ticker.get(ticker_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. +Returns a table with the values of this ticker_id. Returns `nil`, if it does not exist. Returns `false, "errormessage"` if an error occurred. ``` -yl_announcements.set(message, frequency, runtime, owner) +yl_ticker.set(message, frequency, runtime, owner) ``` -Adds this announcement to the list and returns `true, announcement_id` if accepted, `false, "errormessage"` if not. +Adds this ticker to the list and returns `true, ticker_id` if accepted, `false, "errormessage"` if not. ``` -yl_announcements.formspec(announcement_id) +yl_ticker.formspec(ticker_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. +Returns `true, formspecstring` if a ticker was found, with formspecstring including the `/ticker_add` string, so it can be easily copied from. Returns `false, errormessage` if an error occurred. ``` -yl_announcements.delete(announcement_id) +yl_ticker.delete(ticker_id) ``` -Returns `true, {announcement}` if one task was successfully removed, `false, "errormessage"` otherwise. +Returns `true, {ticker}` if one ticker was successfully removed, `false, "errormessage"` otherwise. ``` -yl_announcements.list() +yl_ticker.list() ``` -Returns `true, { id = {announcement}, ... }` if one or more announcements were found or `false, {}` if none were found. +Returns `true, { id = {ticker}, ... }` if one or more ticker were found or `false, {}` if none were found. ``` -yl_announcements.say(announcement_id) +yl_ticker.say(ticker_id) ``` -Returns `true, {announcement}` if one announcement was found or `false, {}` if none were found. +Returns `true, {ticker}` if one ticker was found or `false, {}` if none were found. ## Limitations @@ -176,12 +176,12 @@ Returns `true, {announcement}` if one announcement was found or `false, {}` if n ## Alternatives -* For immediate one-time announcements, use the notification mod -* For future one-time announcements, use the yl_scheduler mod +* For immediate one-time ticker, use the notification mod +* For future one-time ticker, use the yl_scheduler mod ## Supported versions -If you run yl_announcements, but something is wrong, please [file a bug](https://gitea.your-land.de/your-land/yl_announcements/issues/new). PRs also welcome. +If you run yl_ticker, but something is wrong, please [file a bug](https://gitea.your-land.de/your-land/yl_ticker/issues/new). PRs also welcome. There is no reason to believe it doesn't work anywhere, but you never know. diff --git a/api.lua b/api.lua index a0ce10b..4300532 100644 --- a/api.lua +++ b/api.lua @@ -1,28 +1,28 @@ -function yl_announcements.list() - if next(yl_announcements.data) ~= nil then - return true, yl_announcements.data +function yl_ticker.list() + if next(yl_ticker.data) ~= nil then + return true, yl_ticker.data end return false, {} end -function yl_announcements.get(announcement_id) +function yl_ticker.get(ticker_id) - -- Check announcement_id - if (type(announcement_id) ~= "number") then - return false, "Announcement ID is not a number" + -- Check ticker_id + if (type(ticker_id) ~= "number") then + return false, "Ticker ID is not a number" end - if (announcement_id <= 0) then - return false, "Announcement ID cannot be zero or negative" + if (ticker_id <= 0) then + return false, "Ticker ID cannot be zero or negative" end - local success, data = yl_announcements.list() - if ((success == true) and (data[announcement_id] ~= nil)) then - return true, table.copy(data[announcement_id]) + local success, data = yl_ticker.list() + if ((success == true) and (data[ticker_id] ~= nil)) then + return true, table.copy(data[ticker_id]) end return nil end -function yl_announcements.set(message, frequency, runtime, owner) +function yl_ticker.set(message, frequency, runtime, owner) -- Check message if (type(message) ~= "string") then return false, "message not a string" end @@ -44,7 +44,7 @@ function yl_announcements.set(message, frequency, runtime, owner) if (owner == "") then return false, "Owner cannot be empty" end local index = 1 - while yl_announcements.data[index] ~= nil do index = index + 1 end + while yl_ticker.data[index] ~= nil do index = index + 1 end local content = { id = index, @@ -55,100 +55,100 @@ function yl_announcements.set(message, frequency, runtime, owner) owner = owner } - yl_announcements.data[index] = content + yl_ticker.data[index] = content - local success = yl_announcements.save_json(tostring(index) .. ".json", + local success = yl_ticker.save_json(tostring(index) .. ".json", content) if (success == true) then return true, index end - return false, "Could not store announcement" + return false, "Could not store ticker" end --- /announcement_add message$frequency in seconds$runtime in seconds -function yl_announcements.formspec(announcement_id) +-- /ticker_add message$frequency in seconds$runtime in seconds +function yl_ticker.formspec(ticker_id) - -- Check announcement_id - if (type(announcement_id) ~= "number") then - return false, "Announcement ID is not a number" + -- Check ticker_id + if (type(ticker_id) ~= "number") then + return false, "Ticker ID is not a number" end - if (announcement_id <= 0) then - return false, "Announcement ID cannot be zero or negative" + if (ticker_id <= 0) then + return false, "Ticker ID cannot be zero or negative" end - local success, announcement = yl_announcements.get(announcement_id) - core.log("action", "announcement = " .. dump(announcement)) - if ((success == false) or (announcement == nil)) then - return false, "No announcement" + local success, ticker = yl_ticker.get(ticker_id) + core.log("action", "ticker = " .. dump(ticker)) + if ((success == false) or (ticker == nil)) then + return false, "No ticker" end - local m = announcement.message or "message" - local f = announcement.frequency or "frequency" - local r = announcement.runtime or "runtime" + local m = ticker.message or "message" + local f = ticker.frequency or "frequency" + local r = ticker.runtime or "runtime" - local c = "/announcement_add " .. m .. "$" .. f .. "$" .. r - local content = minetest.formspec_escape(c .. "\n\n" .. dump(announcement)) + local c = "/ticker_add " .. m .. "$" .. f .. "$" .. r + local content = minetest.formspec_escape(c .. "\n\n" .. dump(ticker)) local formspec = "formspec_version[6]" .. "size[16,4]" .. "button_exit[15.4,0.1;0.5,0.5;X;X]" .. "textarea[0.05,0.05;15.3,3.9;;;" .. content .. "]" return true, formspec end -function yl_announcements.delete(announcement_id) +function yl_ticker.delete(ticker_id) - -- Check announcement_id - if (type(announcement_id) ~= "number") then - return false, "Announcement ID is not a number" + -- Check ticker_id + if (type(ticker_id) ~= "number") then + return false, "Ticker ID is not a number" end - if (announcement_id <= 0) then - return false, "Announcement ID cannot be zero or negative" + if (ticker_id <= 0) then + return false, "Ticker ID cannot be zero or negative" end - local success, data = yl_announcements.list() + local success, data = yl_ticker.list() if ((success == false) or (data == nil)) then return false, "Could not retrieve list" end - if ((success == true) and (data[announcement_id] == nil)) then - return false, "Could not retrieve announcement" + if ((success == true) and (data[ticker_id] == nil)) then + return false, "Could not retrieve ticker" end - local announcement = table.copy(data[announcement_id]) or + local ticker = table.copy(data[ticker_id]) or "No data available" - if (announcement ~= nil) then - data[announcement_id] = nil - local success_f, err = yl_announcements.remove_file(announcement_id .. + if (ticker ~= nil) then + data[ticker_id] = nil + local success_f, err = yl_ticker.remove_file(ticker_id .. ".json") if (success_f == nil) then return false, err end success = true end if (success ~= true) then - announcement = "Could not find announcement with id " .. - dump(announcement_id) + ticker = "Could not find ticker with id " .. + dump(ticker_id) end - return success, announcement + return success, ticker end -function yl_announcements.say(announcement_id, target) +function yl_ticker.say(ticker_id, target) - -- Check announcement_id - if (type(announcement_id) ~= "number") then - return false, "Announcement ID is not a number" + -- Check ticker_id + if (type(ticker_id) ~= "number") then + return false, "Ticker ID is not a number" end - if (announcement_id <= 0) then - return false, "Announcement ID cannot be zero or negative" + if (ticker_id <= 0) then + return false, "Ticker ID cannot be zero or negative" end -- No check for target, it is optional local success = false - local announcement = yl_announcements.data[announcement_id] + local ticker = yl_ticker.data[ticker_id] - if (announcement ~= nil) then - local color = yl_announcements.settings.colour - local message = announcement.message + if (ticker ~= nil) then + local color = yl_ticker.settings.colour + local message = ticker.message local content = minetest.colorize(color, message) if ((target == "*") or (target == nil)) then @@ -160,8 +160,8 @@ function yl_announcements.say(announcement_id, target) end if (success ~= true) then - announcement = "Could not find announcement with id " .. - dump(announcement_id) + ticker = "Could not find ticker with id " .. + dump(ticker_id) end - return success, announcement + return success, ticker end diff --git a/chatcommand_add.lua b/chatcommand_add.lua index ab8e635..e21661b 100644 --- a/chatcommand_add.lua +++ b/chatcommand_add.lua @@ -1,21 +1,21 @@ -local chatcommand_cmd = "announcement_add" +local chatcommand_cmd = "ticker_add" local chatcommand_definition = { params = "$$", description = "Sends the message each frequency seconds for a maximum number of runtime seconds." .. - "\nExample: /announcement_add Runs every 50 seconds for one hour (= 3600 seconds)$50$3600", - privs = {[yl_announcements.settings.admin_privs] = true}, + "\nExample: /ticker_add Runs every 50 seconds for one hour (= 3600 seconds)$50$3600", + privs = {[yl_ticker.settings.admin_privs] = true}, func = function(name, param) - local success, message = yl_announcements.chatcommand_announcement_add( + local success, message = yl_ticker.chatcommand_ticker_add( name, param) if success then - minetest.log("action", "[yl_announcements] player " .. name .. - " added new announcement: " .. param) + minetest.log("action", "[yl_ticker] player " .. name .. + " added new ticker: " .. param) return true, message else minetest.log("warning", - "[yl_announcements] player " .. name .. - " added new announcement: " .. param .. + "[yl_ticker] player " .. name .. + " added new ticker: " .. param .. " unsuccessfully, message: " .. message) return false, message end @@ -23,4 +23,4 @@ local chatcommand_definition = { } minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) -yl_announcements.register_help(chatcommand_cmd, chatcommand_definition) +yl_ticker.register_help(chatcommand_cmd, chatcommand_definition) diff --git a/chatcommand_copy.lua b/chatcommand_copy.lua index 13b6bf1..55fa8a0 100644 --- a/chatcommand_copy.lua +++ b/chatcommand_copy.lua @@ -1,21 +1,21 @@ -local chatcommand_cmd = "announcement_copy" +local chatcommand_cmd = "ticker_copy" local chatcommand_definition = { - params = "", - description = "Open the announcement with ID in a formspec, so it can be copied." .. - "\nExample: /announcement_copy 5", - privs = {[yl_announcements.settings.user_privs] = true}, + params = "", + description = "Open the ticker with ID in a formspec, so it can be copied." .. + "\nExample: /ticker_copy 5", + privs = {[yl_ticker.settings.user_privs] = true}, func = function(name, param) - local success, message = yl_announcements.chatcommand_announcement_copy( + local success, message = yl_ticker.chatcommand_ticker_copy( name, param) if success then - minetest.log("action", "[yl_announcements] player " .. name .. - " copied announcement: " .. param) + minetest.log("action", "[yl_ticker] player " .. name .. + " copied ticker: " .. param) return true, message else minetest.log("warning", - "[yl_announcements] player " .. name .. - " copied announcement: " .. param .. + "[yl_ticker] player " .. name .. + " copied ticker: " .. param .. " unsuccessfully, message: " .. message) return false, message end @@ -23,4 +23,4 @@ local chatcommand_definition = { } minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) -yl_announcements.register_help(chatcommand_cmd, chatcommand_definition) +yl_ticker.register_help(chatcommand_cmd, chatcommand_definition) diff --git a/chatcommand_delete.lua b/chatcommand_delete.lua index a11df95..5c2ebfb 100644 --- a/chatcommand_delete.lua +++ b/chatcommand_delete.lua @@ -1,21 +1,21 @@ -local chatcommand_cmd = "announcement_delete" +local chatcommand_cmd = "ticker_delete" local chatcommand_definition = { - params = "", - description = "Delete the announcement ID." .. - "\nExample: /announcement_delete 5", - privs = {[yl_announcements.settings.admin_privs] = true}, + params = "", + description = "Delete the ticker ID." .. + "\nExample: /ticker_delete 5", + privs = {[yl_ticker.settings.admin_privs] = true}, func = function(name, param) local success, message = - yl_announcements.chatcommand_announcement_delete(name, param) + yl_ticker.chatcommand_ticker_delete(name, param) if success then - minetest.log("action", "[yl_announcements] player " .. name .. - " deleted new announcement: " .. param) + minetest.log("action", "[yl_ticker] player " .. name .. + " deleted ticker: " .. param) return true, message else minetest.log("warning", - "[yl_announcements] player " .. name .. - " deleted new announcement: " .. param .. + "[yl_ticker] player " .. name .. + " deleted ticker: " .. param .. " unsuccessfully, message: " .. message) return false, message end @@ -23,4 +23,4 @@ local chatcommand_definition = { } minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) -yl_announcements.register_help(chatcommand_cmd, chatcommand_definition) +yl_ticker.register_help(chatcommand_cmd, chatcommand_definition) diff --git a/chatcommand_help.lua b/chatcommand_help.lua index 1ad528e..7c0ff4d 100644 --- a/chatcommand_help.lua +++ b/chatcommand_help.lua @@ -1,22 +1,22 @@ -local chatcommand_cmd = "announcement_help" +local chatcommand_cmd = "ticker_help" local chatcommand_definition = { params = "", - description = "Lists the command help for the announcements." .. - "\nExample: /announcement_help", - privs = {[yl_announcements.settings.user_privs] = true}, + description = "Lists the command help for the ticker." .. + "\nExample: /ticker_help", + privs = {[yl_ticker.settings.user_privs] = true}, func = function(name, param) - local success, message = yl_announcements.chatcommand_announcement_help( + local success, message = yl_ticker.chatcommand_ticker_help( name, param) if success then minetest.log("action", - "[yl_announcements] player " .. name .. - " displays help for announcements: " .. param) + "[yl_ticker] player " .. name .. + " displays help for ticker: " .. param) return true, message else minetest.log("warning", - "[yl_announcements] player " .. name .. - " displays help for announcements: " .. param .. + "[yl_ticker] player " .. name .. + " displays help for ticker: " .. param .. " unsuccessfully, message: " .. message) return false, message end @@ -24,4 +24,4 @@ local chatcommand_definition = { } minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) -yl_announcements.register_help(chatcommand_cmd, chatcommand_definition) +yl_ticker.register_help(chatcommand_cmd, chatcommand_definition) diff --git a/chatcommand_list.lua b/chatcommand_list.lua index 353bf39..013f79a 100644 --- a/chatcommand_list.lua +++ b/chatcommand_list.lua @@ -1,21 +1,21 @@ -local chatcommand_cmd = "announcement_list" +local chatcommand_cmd = "ticker_list" local chatcommand_definition = { - params = "", - description = "List announcement with ID to you." .. - "\nExample: /announcement_list 5", - privs = {[yl_announcements.settings.user_privs] = true}, + params = "", + description = "List tickers with ID to you." .. + "\nExample: /ticker_list 5", + privs = {[yl_ticker.settings.user_privs] = true}, func = function(name, param) - local success, message = yl_announcements.chatcommand_announcement_list( + local success, message = yl_ticker.chatcommand_ticker_list( name, param) if success then - minetest.log("action", "[yl_announcements] player " .. name .. - " lists announcement: " .. param) + minetest.log("action", "[yl_ticker] player " .. name .. + " lists tickers: " .. param) return true, message else minetest.log("warning", - "[yl_announcements] player " .. name .. - " lists announcement: " .. param .. + "[yl_ticker] player " .. name .. + " lists tickers: " .. param .. " unsuccessfully, message: " .. message) return false, message end @@ -23,4 +23,4 @@ local chatcommand_definition = { } minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) -yl_announcements.register_help(chatcommand_cmd, chatcommand_definition) +yl_ticker.register_help(chatcommand_cmd, chatcommand_definition) diff --git a/chatcommand_list_all.lua b/chatcommand_list_all.lua index ce4eee5..483cf46 100644 --- a/chatcommand_list_all.lua +++ b/chatcommand_list_all.lua @@ -1,21 +1,21 @@ -local chatcommand_cmd = "announcement_list_all" +local chatcommand_cmd = "ticker_list_all" local chatcommand_definition = { params = "", - description = "Lists all announcements to you." .. - "\nExample: /announcement_list_all", - privs = {[yl_announcements.settings.user_privs] = true}, + description = "Lists all tickers to you." .. + "\nExample: /ticker_list_all", + privs = {[yl_ticker.settings.user_privs] = true}, func = function(name, param) local success, message = - yl_announcements.chatcommand_announcement_list_all(name, param) + yl_ticker.chatcommand_ticker_list_all(name, param) if success then - minetest.log("action", "[yl_announcements] player " .. name .. - " lists all announcements: " .. param) + minetest.log("action", "[yl_ticker] player " .. name .. + " lists all tickers: " .. param) return true, message else minetest.log("warning", - "[yl_announcements] player " .. name .. - " lists all announcements: " .. param .. + "[yl_ticker] player " .. name .. + " lists all tickers: " .. param .. " unsuccessfully, message: " .. dump(message)) return false, dump(message) end @@ -23,4 +23,4 @@ local chatcommand_definition = { } minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) -yl_announcements.register_help(chatcommand_cmd, chatcommand_definition) +yl_ticker.register_help(chatcommand_cmd, chatcommand_definition) diff --git a/chatcommand_say.lua b/chatcommand_say.lua index 8dfaf80..2061848 100644 --- a/chatcommand_say.lua +++ b/chatcommand_say.lua @@ -1,21 +1,21 @@ -local chatcommand_cmd = "announcement_say" +local chatcommand_cmd = "ticker_say" local chatcommand_definition = { - params = "", - description = "Say the announcement with ID in main chat." .. - "\nExample: /announcement_say 5", - privs = {[yl_announcements.settings.admin_privs] = true}, + params = "", + description = "Say the ticker with ID in main chat." .. + "\nExample: /ticker_say 5", + privs = {[yl_ticker.settings.admin_privs] = true}, func = function(name, param) - local success, message = yl_announcements.chatcommand_announcement_say( + local success, message = yl_ticker.chatcommand_ticker_say( name, param) if success then - minetest.log("action", "[yl_announcements] player " .. name .. - " sent announcement: " .. param) + minetest.log("action", "[yl_ticker] player " .. name .. + " sent ticker: " .. param) return true, message else minetest.log("warning", - "[yl_announcements] player " .. name .. - " sent announcement: " .. param .. + "[yl_ticker] player " .. name .. + " sent ticker: " .. param .. " unsuccessfully, message: " .. message) return false, message end @@ -23,4 +23,4 @@ local chatcommand_definition = { } minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) -yl_announcements.register_help(chatcommand_cmd, chatcommand_definition) +yl_ticker.register_help(chatcommand_cmd, chatcommand_definition) diff --git a/chatcommand_say_all.lua b/chatcommand_say_all.lua index 617c4e8..db9bb4e 100644 --- a/chatcommand_say_all.lua +++ b/chatcommand_say_all.lua @@ -1,21 +1,21 @@ -local chatcommand_cmd = "announcement_say_all" +local chatcommand_cmd = "ticker_say_all" local chatcommand_definition = { params = "", - description = "Say all announcements in main chat." .. - "\nExample: /announcement_say_all", - privs = {[yl_announcements.settings.admin_privs] = true}, + description = "Say all tickers in main chat." .. + "\nExample: /ticker_say_all", + privs = {[yl_ticker.settings.admin_privs] = true}, func = function(name, param) local success, message = - yl_announcements.chatcommand_announcement_say_all(name, param) + yl_ticker.chatcommand_ticker_say_all(name, param) if success then - minetest.log("action", "[yl_announcements] player " .. name .. - " sent all announcements: " .. param) + minetest.log("action", "[yl_ticker] player " .. name .. + " sent all tickers: " .. param) return true, message else minetest.log("warning", - "[yl_announcements] player " .. name .. - " sent all announcements: " .. param .. + "[yl_ticker] player " .. name .. + " sent all tickers: " .. param .. " unsuccessfully, message: " .. message) return false, message end @@ -23,4 +23,4 @@ local chatcommand_definition = { } minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition) -yl_announcements.register_help(chatcommand_cmd, chatcommand_definition) +yl_ticker.register_help(chatcommand_cmd, chatcommand_definition) diff --git a/chatcommands.lua b/chatcommands.lua index 3825f5c..504105d 100644 --- a/chatcommands.lua +++ b/chatcommands.lua @@ -1,8 +1,8 @@ -dofile(yl_announcements.modpath .. DIR_DELIM .. "chatcommand_list.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "chatcommand_list_all.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "chatcommand_add.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "chatcommand_delete.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "chatcommand_say.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "chatcommand_say_all.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "chatcommand_copy.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "chatcommand_help.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "chatcommand_list.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "chatcommand_list_all.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "chatcommand_add.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "chatcommand_delete.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "chatcommand_say.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "chatcommand_say_all.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "chatcommand_copy.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "chatcommand_help.lua") diff --git a/config.lua b/config.lua index 6a8a351..f47870c 100644 --- a/config.lua +++ b/config.lua @@ -1,16 +1,16 @@ -- Setting a configuration, switch the order in which the settings shall take precedence. First valid one taken. -yl_announcements.settings = {} +yl_ticker.settings = {} -yl_announcements.settings.debug = minetest.settings:get("yl_announcements.debug") or false +yl_ticker.settings.debug = minetest.settings:get("yl_ticker.debug") or false -yl_announcements.settings.save_path = minetest.settings:get("yl_announcements.save_path") or "yl_announcements" +yl_ticker.settings.save_path = minetest.settings:get("yl_ticker.save_path") or "yl_ticker" -yl_announcements.settings.colour = minetest.settings:get("yl_announcements.colour") or "#7676ff" +yl_ticker.settings.colour = minetest.settings:get("yl_ticker.colour") or "#7676ff" -yl_announcements.settings.frequency = minetest.settings:get("yl_announcements.frequency") or 3600 +yl_ticker.settings.frequency = minetest.settings:get("yl_ticker.frequency") or 3600 -yl_announcements.settings.user_privs = minetest.settings:get("yl_announcements.user_privs") or "interact" +yl_ticker.settings.user_privs = minetest.settings:get("yl_ticker.user_privs") or "interact" -yl_announcements.settings.admin_privs = minetest.settings:get("yl_announcements.admin_privs") or "server" +yl_ticker.settings.admin_privs = minetest.settings:get("yl_ticker.admin_privs") or "server" diff --git a/globalsteps.lua b/globalsteps.lua index 1489039..766aadc 100644 --- a/globalsteps.lua +++ b/globalsteps.lua @@ -2,46 +2,46 @@ local function calculate_bucket(bucket, data) -- This is per bucket if type(bucket) ~= "number" then bucket = tonumber(bucket) end - local affected_announcements = {} + local affected_tickers = {} - for _, announcement in ipairs(data) do - if announcement.frequency == bucket then - table.insert(affected_announcements, announcement) + for _, ticker in ipairs(data) do + if ticker.frequency == bucket then + table.insert(affected_tickers, ticker) end end -- Prevent division by 0 - if (#affected_announcements == 0) then + if (#affected_tickers == 0) then -- We should never reach this code. If there are members of the bucket, - -- then there must be affected announcements. + -- then there must be affected ticker. minetest.log("error", - "[yl_announcements] globalstep division by zero, no members of bucket = " .. + "[yl_ticker] globalstep division by zero, no members of bucket = " .. dump(bucket)) return end -- Let's calculate the distance - local distance = bucket / #affected_announcements + local distance = bucket / #affected_tickers local n = 0 - for _, announcement in ipairs(affected_announcements) do - announcement._next_runtime = os.time() + n * distance + for _, ticker in ipairs(affected_tickers) do + ticker._next_runtime = os.time() + n * distance n = n + 1 end end -local tick = 1 +local delta = 1 local timer = 0 local gs = function(dtime) timer = timer + dtime - if timer <= tick then return end - timer = timer - tick + if timer <= delta then return end + timer = timer - delta -- payload - local success, data = yl_announcements.list() + local success, data = yl_ticker.list() if ((success == false) or (data == nil)) then return false, "Could not retrieve list" end @@ -49,37 +49,37 @@ local gs = function(dtime) local current_time = os.time() local affected_bucket = {} - -- Check if any announcement should be displayed - for _, announcement in pairs(data) do - -- Check if any announcement needs to be removed from the list due to runtime expired. - if ((type(announcement.runtime) == "number") and - (current_time >= (announcement.creation_date + announcement.runtime))) then - yl_announcements.delete(announcement.id) - elseif current_time >= (announcement._next_runtime or 0) then + -- Check if any ticker should be displayed + for _, ticker in pairs(data) do + -- Check if any ticker needs to be removed from the list due to runtime expired. + if ((type(ticker.runtime) == "number") and + (current_time >= (ticker.creation_date + ticker.runtime))) then + yl_ticker.delete(ticker.id) + elseif current_time >= (ticker._next_runtime or 0) then - if (type(announcement._next_runtime) ~= "number") then - table.insert(affected_bucket, announcement.frequency) + if (type(ticker._next_runtime) ~= "number") then + table.insert(affected_bucket, ticker.frequency) else local a_success, message = - yl_announcements.say(announcement.id, "*") + yl_ticker.say(ticker.id, "*") if (a_success == false) then minetest.log("error", - "[yl_announcements] globalstep cannot send to target, message = " .. - dump(message) .. " : announcement = " .. - dump(announcement)) + "[yl_ticker] globalstep cannot send to target, message = " .. + dump(message) .. " : ticker = " .. + dump(ticker)) return end - announcement._next_runtime = - announcement._next_runtime + - (announcement.frequency or 3600) + ticker._next_runtime = + ticker._next_runtime + + (ticker.frequency or 3600) end - yl_announcements.log(os.date("!%H:%M:%S", os.time()) .. "=" .. - tostring(announcement.id)) + yl_ticker.log(os.date("!%H:%M:%S", os.time()) .. "=" .. + tostring(ticker.id)) end end - -- If there were any announcements that had no _next_runtime, then we need to recalculate their bucket + -- If there were any tickers that had no _next_runtime, then we need to recalculate their bucket for _, bucket in ipairs(affected_bucket) do calculate_bucket(bucket, data) end diff --git a/init.lua b/init.lua index ab993ed..52a6493 100644 --- a/init.lua +++ b/init.lua @@ -3,29 +3,29 @@ -- License MIT -- Changelog local mod_start_time = core.get_us_time() -core.log("action", "[MOD] yl_announcements loading") +core.log("action", "[MOD] yl_ticker loading") -yl_announcements = {} -yl_announcements.error = {} --- yl_announcements.modstorage = core.get_mod_storage() -yl_announcements.modpath = core.get_modpath("yl_announcements") -yl_announcements.worldpath = core.get_worldpath() +yl_ticker = {} +yl_ticker.error = {} +-- yl_ticker.modstorage = core.get_mod_storage() +yl_ticker.modpath = core.get_modpath("yl_ticker") +yl_ticker.worldpath = core.get_worldpath() -yl_announcements.information = {} -yl_announcements.information.version = "0.0.1" -yl_announcements.information.author = "AliasAlreadyTaken" -yl_announcements.information.license = "MIT" -yl_announcements.information.name = "yl_announcements" -yl_announcements.information.source = "https://gitea.your-land.de/your-land/yl_announcements" -yl_announcements.information.additional = "Displays messages once per timeframe" +yl_ticker.information = {} +yl_ticker.information.version = "0.0.1" +yl_ticker.information.author = "AliasAlreadyTaken" +yl_ticker.information.license = "MIT" +yl_ticker.information.name = "yl_ticker" +yl_ticker.information.source = "https://gitea.your-land.de/your-land/yl_ticker" +yl_ticker.information.additional = "Displays messages once per timeframe" -dofile(yl_announcements.modpath .. DIR_DELIM .. "config.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "setup.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "internal.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "api.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "initialize.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "globalsteps.lua") -dofile(yl_announcements.modpath .. DIR_DELIM .. "chatcommands.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "config.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "setup.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "internal.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "api.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "initialize.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "globalsteps.lua") +dofile(yl_ticker.modpath .. DIR_DELIM .. "chatcommands.lua") local mod_end_time = (core.get_us_time() - mod_start_time) / 1000000 -core.log("action", "[MOD] yl_announcements loaded in [" .. mod_end_time .. "s]") +core.log("action", "[MOD] yl_ticker loaded in [" .. mod_end_time .. "s]") diff --git a/initialize.lua b/initialize.lua index 97c3996..542085b 100644 --- a/initialize.lua +++ b/initialize.lua @@ -1,7 +1,7 @@ local function run_each_serverstart() - yl_announcements.data = {} - minetest.after(0.0, yl_announcements.load_all_data) - minetest.after(0.0, yl_announcements.check_privs) + yl_ticker.data = {} + minetest.after(0.0, yl_ticker.load_all_data) + minetest.after(0.0, yl_ticker.check_privs) end run_each_serverstart() diff --git a/internal.lua b/internal.lua index ad9a8f1..d565541 100644 --- a/internal.lua +++ b/internal.lua @@ -1,18 +1,18 @@ -- The functions and variables in this file are only for use in the mod itself. -- Those that do real work should be local and wrapped in public functions -local debug = yl_announcements.settings.debug or true +local debug = yl_ticker.settings.debug or true local function log(text) - if debug then minetest.log("action", "[MOD] yl_announcements : " .. text) end + if debug then minetest.log("action", "[MOD] yl_ticker : " .. text) end end -function yl_announcements.log(text) return log(text) end +function yl_ticker.log(text) return log(text) end -- Storage local function get_savepath() - local save_path = yl_announcements.settings.save_path - local path = yl_announcements.worldpath .. DIR_DELIM .. save_path + local save_path = yl_ticker.settings.save_path + local path = yl_ticker.worldpath .. DIR_DELIM .. save_path log("get_savepath : " .. dump(path)) return path end @@ -46,11 +46,11 @@ local function load_json(path_to_file) end -- Public functions wrap the private ones, so they can be exchanged easily -function yl_announcements.load_json(filename, ...) +function yl_ticker.load_json(filename, ...) return load_json(filename, ...) end -function yl_announcements.save_json(filename, content, ...) +function yl_ticker.save_json(filename, content, ...) return save_json(filename, content, ...) end @@ -120,24 +120,24 @@ local function load_all_data() end end - yl_announcements.data = data + yl_ticker.data = data if bad == 0 then minetest.log("action", - "[MOD] yl_announcements : bad = " .. tostring(bad) .. + "[MOD] yl_ticker : bad = " .. tostring(bad) .. ", good = " .. tostring(good) .. ", total = " .. tostring(total)) return true, good, bad else minetest.log("warning", - "[MOD] yl_announcements : bad = " .. tostring(bad) .. + "[MOD] yl_ticker : bad = " .. tostring(bad) .. ", good = " .. tostring(good) .. ", total = " .. tostring(total)) return false, good, bad end end -function yl_announcements.load_all_data() return load_all_data() end +function yl_ticker.load_all_data() return load_all_data() end -- check privs -- @@ -155,12 +155,12 @@ local function priv_exists(priv) end local function check_privs() - for key, value in pairs(yl_announcements.settings) do + for key, value in pairs(yl_ticker.settings) do if ends_with(key, "_privs") then local parts = split(value) for _, part in ipairs(parts) do assert(priv_exists(part), - "yl_announcements : configured priv " .. dump(part) .. + "yl_ticker : configured priv " .. dump(part) .. " does not exist.") end end @@ -168,7 +168,7 @@ local function check_privs() log("PASS priv check") end -function yl_announcements.check_privs() return check_privs() end +function yl_ticker.check_privs() return check_privs() end -- Remove file -- @@ -178,7 +178,7 @@ local function remove_file(filename) return os.remove(filepath) end -function yl_announcements.remove_file(filename) return remove_file(filename) end +function yl_ticker.remove_file(filename) return remove_file(filename) end -- Help -- @@ -195,7 +195,7 @@ local function register_help(chatcommand_cmd, chatcommand_definition) help_texts[chatcommand_cmd] = definition end -function yl_announcements.register_help(chatcommand_cmd, chatcommand_definition) +function yl_ticker.register_help(chatcommand_cmd, chatcommand_definition) return register_help(chatcommand_cmd, chatcommand_definition) end @@ -240,12 +240,12 @@ local function display_help() return true, s_message end -function yl_announcements.display_help() return display_help() end +function yl_ticker.display_help() return display_help() end -- Chatcommands -- -function yl_announcements.chatcommand_announcement_add(name, param) -- param is a string containing a message and more +function yl_ticker.chatcommand_ticker_add(name, param) -- param is a string containing a message and more -- defense local player = minetest.get_player_by_name(name) @@ -253,67 +253,67 @@ function yl_announcements.chatcommand_announcement_add(name, param) -- param is if (not param) or (type(param) ~= "string") or (param == "") then return false, "Requirements not met" end - -- Create announcement - local announcement = string.split(param, "$", true) + -- Create ticker + local ticker = string.split(param, "$", true) - local message = announcement[1] or "" - local frequency = tonumber(announcement[2]) or - yl_announcements.settings.frequency or 3600 - local runtime = tonumber(announcement[3]) or 7257600 -- 12 weeks + local message = ticker[1] or "" + local frequency = tonumber(ticker[2]) or + yl_ticker.settings.frequency or 3600 + local runtime = tonumber(ticker[3]) or 7257600 -- 12 weeks local owner = name - local success, announcement_id = yl_announcements.set(message, frequency, + local success, ticker_id = yl_ticker.set(message, frequency, runtime, owner) - return success, "Announcement ID " .. tostring(announcement_id) + return success, "Ticker ID " .. tostring(ticker_id) end -function yl_announcements.chatcommand_announcement_copy(name, param) -- param is a numerical a_id +function yl_ticker.chatcommand_ticker_copy(name, param) -- param is a numerical a_id -- defense local player = minetest.get_player_by_name(name) if not player then return false, "Player not online" end - if param == "" then return false, "Announcement ID missing" end - local announcement_id = tonumber(param) - if type(announcement_id) ~= "number" then - return false, "Announcement ID is not a number" + if param == "" then return false, "Ticker ID missing" end + local ticker_id = tonumber(param) + if type(ticker_id) ~= "number" then + return false, "Ticker ID is not a number" end - if (announcement_id <= 0) then - return false, "Announcement ID cannot be zero or negative" + if (ticker_id <= 0) then + return false, "Ticker ID cannot be zero or negative" end - local success, formspecstring = yl_announcements.formspec(announcement_id) + local success, formspecstring = yl_ticker.formspec(ticker_id) if (success == false) then return false, formspecstring end -- Send the formspec - minetest.show_formspec(name, "yl_announcements:copy", formspecstring) + minetest.show_formspec(name, "yl_ticker:copy", formspecstring) -- Report - return true, "Copied announcement ID " .. tostring(announcement_id) + return true, "Copied ticker ID " .. tostring(ticker_id) end -function yl_announcements.chatcommand_announcement_delete(name, param) -- param is a numerical a_id +function yl_ticker.chatcommand_ticker_delete(name, param) -- param is a numerical a_id -- defense local player = minetest.get_player_by_name(name) if not player then return false, "Player not online" end - if param == "" then return false, "Announcement ID missing" end - local announcement_id = tonumber(param) - if type(announcement_id) ~= "number" then - return false, "Announcement ID not a number" + if param == "" then return false, "Ticker ID missing" end + local ticker_id = tonumber(param) + if type(ticker_id) ~= "number" then + return false, "Ticker ID not a number" end - local success, announcement = yl_announcements.delete(announcement_id) + local success, ticker = yl_ticker.delete(ticker_id) if success == false then - return false, announcement + return false, ticker else - return true, "Deleted announcement ID " .. tostring(announcement_id) + return true, "Deleted ticker ID " .. tostring(ticker_id) end end --- List announcements +-- List ticker -- taken from yl_cinema --- TODO: Shoudl we API-fy this? +-- TODO: Should we API-fy this? local function format_table(t) -- Format of t must be {{row1,row2,row3, ...},{row1,row2,row3, ...},...} @@ -347,112 +347,112 @@ local function format_table(t) return table.concat(ret, "\n") end -function yl_announcements.chatcommand_announcement_list_all(name, param) -- param must be empty +function yl_ticker.chatcommand_ticker_list_all(name, param) -- param must be empty -- defense local player = minetest.get_player_by_name(name) if not player then return false, "Player not online" end if param ~= "" then - return false, "This command lists all announcements. " .. - "Do /announcement_list if you want to have only one." + return false, "This command lists all tickers. " .. + "Do /ticker_list if you want to have only one." end - local success, data = yl_announcements.list() + local success, data = yl_ticker.list() if (success == false) then return false, data end - local f_announcements = { + local f_ticker = { {"ID", "message", "created", "owner", "runtime", "frequency"} } - for _, announcement in pairs(data) do + for _, ticker in pairs(data) do - local id = tostring(announcement.id) or "N/A" - local message = announcement.message or "N/A" + local id = tostring(ticker.id) or "N/A" + local message = ticker.message or "N/A" local created = os.date("!%Y-%m-%d %H:%M:%S", - (announcement.creation_date or 0)) or "N/A" - local owner = announcement.owner or "N/A" - local runtime = tostring(announcement.runtime) or "N/A" - local frequency = tostring(announcement.frequency) or "N/A" + (ticker.creation_date or 0)) or "N/A" + local owner = ticker.owner or "N/A" + local runtime = tostring(ticker.runtime) or "N/A" + local frequency = tostring(ticker.frequency) or "N/A" local t = {id, message, created, owner, runtime, frequency} - table.insert(f_announcements, t) + table.insert(f_ticker, t) end - return true, format_table(f_announcements) + return true, format_table(f_ticker) end -function yl_announcements.chatcommand_announcement_list(name, param) -- param is a numerical a_id +function yl_ticker.chatcommand_ticker_list(name, param) -- param is a numerical a_id -- defense local player = minetest.get_player_by_name(name) if not player then return false, "Player not online" end - if param == "" then return false, "Announcement ID missing" end - local announcement_id = tonumber(param) - if type(announcement_id) ~= "number" then - return false, "Announcement ID not a number" + if param == "" then return false, "Ticker ID missing" end + local ticker_id = tonumber(param) + if type(ticker_id) ~= "number" then + return false, "Ticker ID not a number" end - local success, announcement = yl_announcements.get(announcement_id) + local success, ticker = yl_ticker.get(ticker_id) if ((success == false) or (success == nil)) then - return false, "Announcement not found" + return false, "Ticker not found" end - return true, dump(announcement) + return true, dump(ticker) end -function yl_announcements.chatcommand_announcement_say_all(name, param) -- param must be empty +function yl_ticker.chatcommand_ticker_say_all(name, param) -- param must be empty -- defense local player = minetest.get_player_by_name(name) if not player then return false, "Player not online" end if param ~= "" then return false, - "This command sends all announcements to the main chat. " .. - "Do /announcement_say if you want to send only one." + "This command sends all ticker to the main chat. " .. + "Do /ticker_say if you want to send only one." end - local success, data = yl_announcements.list() + local success, data = yl_ticker.list() if (success == false) then return false, "No data" end local n = 0 - for _, announcement in pairs(data) do - local s_success, s_message = yl_announcements.say(announcement.id, "*") + for _, ticker in pairs(data) do + local s_success, s_message = yl_ticker.say(ticker.id, "*") if (s_success == false) then return false, s_message end n = n + 1 end - return true, "Sent " .. tostring(n) .. " announcements to public." + return true, "Sent " .. tostring(n) .. " ticker to public." end -function yl_announcements.chatcommand_announcement_say(name, param) -- param is a numerical a_id +function yl_ticker.chatcommand_ticker_say(name, param) -- param is a numerical a_id -- defense local player = minetest.get_player_by_name(name) if not player then return false, "Player not online" end - if param == "" then return false, "Announcement ID missing" end - local announcement_id = tonumber(param) - if type(announcement_id) ~= "number" then - return false, "Announcement ID not a number" + if param == "" then return false, "Ticker ID missing" end + local ticker_id = tonumber(param) + if type(ticker_id) ~= "number" then + return false, "Ticker ID not a number" end - local s_success, s_message = yl_announcements.say(announcement_id, "*") + local s_success, s_message = yl_ticker.say(ticker_id, "*") if (s_success == false) then return false, s_message end return true, - "Sent announcement " .. tostring(announcement_id) .. " to public." + "Sent ticker " .. tostring(ticker_id) .. " to public." end -function yl_announcements.chatcommand_announcement_help(name, param) -- param must be empty +function yl_ticker.chatcommand_ticker_help(name, param) -- param must be empty -- defense local player = minetest.get_player_by_name(name) if not player then return false, "Player not online" end if param ~= "" then return false, - "This command displays the help for the announcements. " .. - "Do /announcement_help without parameters." + "This command displays the help for the ticker. " .. + "Do /ticker_help without parameters." end - local success, message = yl_announcements.display_help() + local success, message = yl_ticker.display_help() if (success == false) then return false, message end diff --git a/mod.conf b/mod.conf index eb55f3f..26e762d 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ -name = yl_announcements +name = yl_ticker description = Displays messages once per timeframe author = AliasAlreadyTaken -title = YL Announcements \ No newline at end of file +title = YL Ticker \ No newline at end of file diff --git a/settingtypes.txt b/settingtypes.txt index 7c68bd0..af18661 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -1,31 +1,31 @@ -[yl_announcements] +[yl_ticker] # Debug mode # Set this to true to enable debug mode, it will output some more values to log # Optional, default is false -yl_announcements.debug (Debug mode) bool false +yl_ticker.debug (Debug mode) bool false # Save path # Set this to where in the worldfolder you want the JSON files stored. -# Optional, default is yl_announcements -yl_announcements.save_path (Save path) string yl_announcements +# Optional, default is yl_ticker +yl_ticker.save_path (Save path) string yl_ticker # Colour -# Set this to the colour you want the announcements have in chat +# Set this to the colour you want the ticker have in chat # Optional, default is "#7676ff" ("cornflower blue") -yl_announcements.colour (Colour) string #7676ff +yl_ticker.colour (Colour) string #7676ff # Frequency -# Set this to the default repeat timer you want the announcements have in chat +# Set this to the default repeat timer you want the ticker have in chat # Optional, default is 3600 seconds (means: once per hour) -yl_announcements.frequency (Frequency) float 3600.0 1.0 +yl_ticker.frequency (Frequency) float 3600.0 1.0 # User privs -# Enable holders of these privs to list and copy announcements +# Enable holders of these privs to list and copy ticker # Optional, default: interact -yl_announcements.user_privs (User privs) string interact +yl_ticker.user_privs (User privs) string interact # Admin Privs # Enable holders of these privs to use all commands # Optional, default: server -yl_announcements.admin_privs (Admin Privs) string server +yl_ticker.admin_privs (Admin Privs) string server diff --git a/setup.lua b/setup.lua index 3e3d3b0..7dce162 100644 --- a/setup.lua +++ b/setup.lua @@ -1,6 +1,6 @@ local mkdir = minetest.mkdir -local save_path = yl_announcements.settings.save_path -local path = yl_announcements.worldpath .. DIR_DELIM .. save_path +local save_path = yl_ticker.settings.save_path +local path = yl_ticker.worldpath .. DIR_DELIM .. save_path local function run_once() local file = io.open(path, "r")