generated from your-land/yl_template
Code formatting. Thank you luacheck :P
This commit is contained in:
parent
de2f010552
commit
59c25afe26
1
api.lua
1
api.lua
@ -1,4 +1,3 @@
|
||||
|
||||
function yl_announcements.get_all_anncouncements()
|
||||
return yl_announcements.data or {}
|
||||
end
|
||||
|
@ -1,8 +1,10 @@
|
||||
local chatcommand_cmd = "announcement_add"
|
||||
local chatcommand_definition = {
|
||||
params = "<message>$<frequency in minutes>$<runtime in minutes>", -- Short parameter description
|
||||
description = "Sends the message each frequency minutes for a maximum number of runtime minutes.", -- Full description
|
||||
privs = {[yl_announcements.settings.admin_priv] = true}, -- Require the "privs" privilege to run
|
||||
params = "<message>$<frequency in minutes>$<runtime in minutes>",
|
||||
description = "Sends the message each frequency minutes for a maximum number of runtime minutes.",
|
||||
privs = {
|
||||
[yl_announcements.settings.admin_priv] = true
|
||||
}, -- Require the "privs" privilege to run
|
||||
func = function(name, param)
|
||||
local success, message = yl_announcements.chatcommand_announcement_add(name, param)
|
||||
|
||||
@ -10,7 +12,8 @@ local chatcommand_definition = {
|
||||
minetest.log("action", "[yl_announcements] player " .. name .. " added new announcement: " .. param)
|
||||
return true, message
|
||||
else
|
||||
minetest.log("warning", "[yl_announcements] player " .. name .. " added new announcement: " .. param .. " unsuccessfully, message: " .. message)
|
||||
minetest.log("warning", "[yl_announcements] player " .. name .. " added new announcement: " .. param ..
|
||||
" unsuccessfully, message: " .. message)
|
||||
return false, message
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,9 @@ local chatcommand_cmd = "announcement_delete"
|
||||
local chatcommand_definition = {
|
||||
params = "<announcement ID>", -- Short parameter description
|
||||
description = "Delete the announcement ID.", -- Full description
|
||||
privs = {[yl_announcements.settings.admin_priv] = true}, -- Require the "privs" privilege to run
|
||||
privs = {
|
||||
[yl_announcements.settings.admin_priv] = true
|
||||
}, -- Require the "privs" privilege to run
|
||||
func = function(name, param)
|
||||
local success, message = yl_announcements.chatcommand_announcement_delete(name, param)
|
||||
|
||||
@ -10,7 +12,9 @@ local chatcommand_definition = {
|
||||
minetest.log("action", "[yl_announcements] player " .. name .. " deleted new announcement: " .. param)
|
||||
return true, message
|
||||
else
|
||||
minetest.log("warning", "[yl_announcements] player " .. name .. " deleted new announcement: " .. param .. " unsuccessfully, message: " .. message)
|
||||
minetest.log("warning",
|
||||
"[yl_announcements] player " .. name .. " deleted new announcement: " .. param ..
|
||||
" unsuccessfully, message: " .. message)
|
||||
return false, message
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,9 @@ local chatcommand_cmd = "announcement_list"
|
||||
local chatcommand_definition = {
|
||||
params = "<announcement ID>", -- Short parameter description
|
||||
description = "List announcement with ID to you.", -- Full description
|
||||
privs = {[yl_announcements.settings.admin_priv] = true},
|
||||
privs = {
|
||||
[yl_announcements.settings.admin_priv] = true
|
||||
},
|
||||
func = function(name, param)
|
||||
local success, message = yl_announcements.chatcommand_announcement_list(name, param)
|
||||
|
||||
@ -10,7 +12,8 @@ local chatcommand_definition = {
|
||||
minetest.log("action", "[yl_announcements] player " .. name .. " lists announcement: " .. param)
|
||||
return true, message
|
||||
else
|
||||
minetest.log("warning", "[yl_announcements] player " .. name .. " lists announcement: " .. param .. " unsuccessfully, message: " .. message)
|
||||
minetest.log("warning", "[yl_announcements] player " .. name .. " lists announcement: " .. param ..
|
||||
" unsuccessfully, message: " .. message)
|
||||
return false, message
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,9 @@ local chatcommand_cmd = "announcement_list_all"
|
||||
local chatcommand_definition = {
|
||||
params = "", -- Short parameter description
|
||||
description = "Lists all announcements to you.", -- Full description
|
||||
privs = {[yl_announcements.settings.admin_priv] = true},
|
||||
privs = {
|
||||
[yl_announcements.settings.admin_priv] = true
|
||||
},
|
||||
func = function(name, param)
|
||||
local success, message = yl_announcements.chatcommand_announcement_list_all(name, param)
|
||||
|
||||
@ -10,7 +12,9 @@ local chatcommand_definition = {
|
||||
minetest.log("action", "[yl_announcements] player " .. name .. " lists all announcements: " .. param)
|
||||
return true, message
|
||||
else
|
||||
minetest.log("warning", "[yl_announcements] player " .. name .. " lists all announcements: " .. param .. " unsuccessfully, message: " .. message)
|
||||
minetest.log("warning",
|
||||
"[yl_announcements] player " .. name .. " lists all announcements: " .. param ..
|
||||
" unsuccessfully, message: " .. message)
|
||||
return false, message
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,9 @@ local chatcommand_cmd = "announcement_say"
|
||||
local chatcommand_definition = {
|
||||
params = "<announcement ID>", -- Short parameter description
|
||||
description = "Say the announcement with ID in main chat.", -- Full description
|
||||
privs = {[yl_announcements.settings.admin_priv] = true},
|
||||
privs = {
|
||||
[yl_announcements.settings.admin_priv] = true
|
||||
},
|
||||
func = function(name, param)
|
||||
local success, message = yl_announcements.chatcommand_announcement_say(name, param)
|
||||
|
||||
@ -10,7 +12,8 @@ local chatcommand_definition = {
|
||||
minetest.log("action", "[yl_announcements] player " .. name .. " sent announcement: " .. param)
|
||||
return true, message
|
||||
else
|
||||
minetest.log("warning", "[yl_announcements] player " .. name .. " sent announcement: " .. param .. " unsuccessfully, message: " .. message)
|
||||
minetest.log("warning", "[yl_announcements] player " .. name .. " sent announcement: " .. param ..
|
||||
" unsuccessfully, message: " .. message)
|
||||
return false, message
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,9 @@ local chatcommand_cmd = "announcement_say_all"
|
||||
local chatcommand_definition = {
|
||||
params = "", -- Short parameter description
|
||||
description = "Say all announcements in main chat.", -- Full description
|
||||
privs = {[yl_announcements.settings.admin_priv] = true},
|
||||
privs = {
|
||||
[yl_announcements.settings.admin_priv] = true
|
||||
},
|
||||
func = function(name, param)
|
||||
local success, message = yl_announcements.chatcommand_announcement_say_all(name, param)
|
||||
|
||||
@ -10,7 +12,8 @@ local chatcommand_definition = {
|
||||
minetest.log("action", "[yl_announcements] player " .. name .. " sent all announcements: " .. param)
|
||||
return true, message
|
||||
else
|
||||
minetest.log("warning", "[yl_announcements] player " .. name .. " sent all announcements: " .. param .. " unsuccessfully, message: " .. message)
|
||||
minetest.log("warning", "[yl_announcements] player " .. name .. " sent all announcements: " .. param ..
|
||||
" unsuccessfully, message: " .. message)
|
||||
return false, message
|
||||
end
|
||||
end
|
||||
|
25
internal.lua
25
internal.lua
@ -1,24 +1,27 @@
|
||||
|
||||
-- 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
|
||||
|
||||
function yl_announcements.load_announcements()
|
||||
yl_announcements.data = minetest.parse_json(mod_storage:get_string("data")) or {}
|
||||
yl_announcements.data = minetest.parse_json(yl_announcements.mod_storage:get_string("data")) or {}
|
||||
end
|
||||
|
||||
function yl_announcements.save_announcements()
|
||||
mod_storage:set_string("data", minetest.write_json(yl_announcements.data))
|
||||
yl_announcements.mod_storage:set_string("data", minetest.write_json(yl_announcements.data))
|
||||
end
|
||||
|
||||
-- Chatcommands
|
||||
|
||||
yl_announcements.chatcommand_announcement_list
|
||||
function yl_announcements.chatcommand_announcement_add(name, param)
|
||||
end
|
||||
|
||||
yl_announcements.chatcommand_announcement_list_all
|
||||
function yl_announcements.chatcommand_announcement_delete(name, param)
|
||||
end
|
||||
|
||||
yl_announcements.chatcommand_announcement_delete
|
||||
function yl_announcements.chatcommand_announcement_list_all(name, param)
|
||||
end
|
||||
|
||||
yl_announcements.chatcommand_announcement_add
|
||||
function yl_announcements.chatcommand_announcement_list(name, param)
|
||||
end
|
||||
|
||||
yl_announcements.chatcommand_announcement_say
|
||||
function yl_announcements.chatcommand_announcement_say_all(name, param)
|
||||
end
|
||||
|
||||
yl_announcements.chatcommand_announcement_say_all
|
||||
function yl_announcements.chatcommand_announcement_say(name, param)
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user