generated from your-land/yl_template
58 lines
1.5 KiB
Lua
58 lines
1.5 KiB
Lua
|
|
-- Storage
|
|
|
|
function yl_announcements.load_announcements()
|
|
yl_announcements.data = minetest.parse_json(yl_announcements.mod_storage:get_string("data")) or {}
|
|
end
|
|
|
|
function yl_announcements.save_announcements(data)
|
|
yl_announcements.mod_storage:set_string("data", minetest.write_json(data))
|
|
end
|
|
|
|
-- Chatcommands
|
|
|
|
function yl_announcements.chatcommand_announcement_add(name, param)
|
|
-- defense
|
|
|
|
end
|
|
|
|
function yl_announcements.chatcommand_announcement_delete(name, param)
|
|
-- 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 n_param = tonumber(param)
|
|
if type(n_param) ~= "number" then
|
|
return false, "Announcement ID not a number"
|
|
end
|
|
local announcement = yl_announcements.get_announcement(n_param)
|
|
if announcement == yl_announcements.error then
|
|
return false, "Cannot find announcement with given ID"
|
|
end
|
|
-- Delete the entry
|
|
local success, data = yl_announcements.delete(n_param)
|
|
-- Save
|
|
if success == false then
|
|
return false, data
|
|
else
|
|
yl_announcements.save_announcements(data)
|
|
return true, "Deleted announcement ID " .. param
|
|
end
|
|
end
|
|
|
|
function yl_announcements.chatcommand_announcement_list_all(name, param)
|
|
end
|
|
|
|
function yl_announcements.chatcommand_announcement_list(name, param)
|
|
end
|
|
|
|
function yl_announcements.chatcommand_announcement_say_all(name, param)
|
|
end
|
|
|
|
function yl_announcements.chatcommand_announcement_say(name, param)
|
|
end
|