Formatting

This commit is contained in:
AliasAlreadyTaken 2024-05-29 03:14:39 +02:00
parent 601087e09e
commit a74021b6ce
9 changed files with 33 additions and 30 deletions

View File

@ -2,7 +2,7 @@ local chatcommand_cmd = "announcement_delete"
local chatcommand_definition = {
params = "<announcement ID>",
description = "Delete the announcement ID." ..
"\nExample: /announcement_delete 5",
"\nExample: /announcement_delete 5",
privs = {[yl_announcements.settings.admin_privs] = true},
func = function(name, param)
local success, message =

View File

@ -2,14 +2,15 @@ local chatcommand_cmd = "announcement_help"
local chatcommand_definition = {
params = "",
description = "Lists the command help for the announcements." ..
"\nExample: /announcement_help",
"\nExample: /announcement_help",
privs = {[yl_announcements.settings.user_privs] = true},
func = function(name, param)
local success, message = yl_announcements.chatcommand_announcement_help(
name, param)
if success then
minetest.log("action", "[yl_announcements] player " .. name ..
minetest.log("action",
"[yl_announcements] player " .. name ..
" displays help for announcements: " .. param)
return true, message
else
@ -23,4 +24,4 @@ local chatcommand_definition = {
}
minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition)
yl_announcements.register_help(chatcommand_cmd, chatcommand_definition)
yl_announcements.register_help(chatcommand_cmd, chatcommand_definition)

View File

@ -2,7 +2,7 @@ local chatcommand_cmd = "announcement_list"
local chatcommand_definition = {
params = "<announcement ID>",
description = "List announcement with ID to you." ..
"\nExample: /announcement_list 5",
"\nExample: /announcement_list 5",
privs = {[yl_announcements.settings.user_privs] = true},
func = function(name, param)
local success, message = yl_announcements.chatcommand_announcement_list(

View File

@ -2,7 +2,7 @@ local chatcommand_cmd = "announcement_list_all"
local chatcommand_definition = {
params = "",
description = "Lists all announcements to you." ..
"\nExample: /announcement_list_all",
"\nExample: /announcement_list_all",
privs = {[yl_announcements.settings.user_privs] = true},
func = function(name, param)
local success, message =

View File

@ -2,7 +2,7 @@ local chatcommand_cmd = "announcement_say"
local chatcommand_definition = {
params = "<announcement ID>",
description = "Say the announcement with ID in main chat." ..
"\nExample: /announcement_say 5",
"\nExample: /announcement_say 5",
privs = {[yl_announcements.settings.admin_privs] = true},
func = function(name, param)
local success, message = yl_announcements.chatcommand_announcement_say(

View File

@ -1,8 +1,8 @@
local chatcommand_cmd = "announcement_say_all"
local chatcommand_definition = {
params = "",
description = "Say all announcements in main chat." ..
"\nExample: /announcement_say_all",
description = "Say all announcements in main chat." ..
"\nExample: /announcement_say_all",
privs = {[yl_announcements.settings.admin_privs] = true},
func = function(name, param)
local success, message =

View File

@ -5,4 +5,4 @@ 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_announcements.modpath .. DIR_DELIM .. "chatcommand_help.lua")

View File

@ -70,7 +70,8 @@ local gs = function(dtime)
return
end
announcement._next_runtime =
announcement._next_runtime + (announcement.frequency or 3600)
announcement._next_runtime +
(announcement.frequency or 3600)
end
yl_announcements.log(os.date("!%H:%M:%S", os.time()) .. "=" ..

View File

@ -6,9 +6,7 @@ local function log(text)
if debug then minetest.log("action", "[MOD] yl_announcements : " .. text) end
end
function yl_announcements.log(text)
return log(text)
end
function yl_announcements.log(text) return log(text) end
-- Storage
@ -77,7 +75,9 @@ local function validate_json(content, schema)
for key, expected_type in pairs(schema) do
if type(content[key]) ~= expected_type then
log("validate_json : Validation error in key = " .. dump(key))
return false, "Validation error in " .. dump(key) .. " not of type " .. dump(expected_type)
return false,
"Validation error in " .. dump(key) .. " not of type " ..
dump(expected_type)
end
end
@ -109,7 +109,8 @@ local function load_all_data()
local filepath = get_filepath(filename)
local success, content = load_json(filepath)
if success and content.id and (validate_json(content, schema) == true) then
if success and content.id and
(validate_json(content, schema) == true) then
good = good + 1
data[content.id] = content
else
@ -202,9 +203,7 @@ local function display_help()
if (type(help_texts) ~= "table") then
return false, "Help texts not a table"
end
if (next(help_texts) == nil) then
return false, "Help text no content"
end
if (next(help_texts) == nil) then return false, "Help text no content" end
local message = {}
@ -221,25 +220,27 @@ local function display_help()
table.insert(message, minetest.colorize("#FF6700", "/" .. chatcommand))
if (definition.params and (type(definition.params) == "string")) then
table.insert(message, minetest.colorize("#FFFF00", "Params:" .. definition.params))
table.insert(message, minetest.colorize("#FFFF00", "Params:" ..
definition.params))
end
if (definition.description and (type(definition.description) == "string")) then
table.insert(message, minetest.colorize("#FFFF00", "Description:" .. definition.description))
if (definition.description and
(type(definition.description) == "string")) then
table.insert(message, minetest.colorize("#FFFF00", "Description:" ..
definition.description))
end
table.insert(message, minetest.colorize("#FFFF00", "Privs:" .. privs) .. "\n")
table.insert(message,
minetest.colorize("#FFFF00", "Privs:" .. privs) .. "\n")
end
local s_message = table.concat(message,"\n")
local s_message = table.concat(message, "\n")
return true, s_message
end
function yl_announcements.display_help()
return display_help()
end
function yl_announcements.display_help() return display_help() end
-- Chatcommands
--
@ -447,8 +448,8 @@ function yl_announcements.chatcommand_announcement_help(name, param) -- param mu
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 announcements. " ..
"Do /announcement_help without parameters."
end
local success, message = yl_announcements.display_help()
@ -456,4 +457,4 @@ function yl_announcements.chatcommand_announcement_help(name, param) -- param mu
if (success == false) then return false, message end
return true, message
end
end