forked from your-land/yl_cinema
chatcommand listmovies
This commit is contained in:
parent
50f30988f5
commit
25d2a1e76e
3
api.lua
Normal file
3
api.lua
Normal file
@ -0,0 +1,3 @@
|
||||
function yl_cinema.listmovies(searchterm)
|
||||
return yl_cinema.search_movies(yl_cinema.movies, searchterm)
|
||||
end
|
30
chatcommand_listmovies.lua
Normal file
30
chatcommand_listmovies.lua
Normal file
@ -0,0 +1,30 @@
|
||||
local chatcommand_cmd = "listmovies"
|
||||
local chatcommand_definition = {
|
||||
params = "[<searchstring>]", -- Short parameter description
|
||||
description = "Shows the whole movielist to you that match the <searchstring>, if given", -- Full description
|
||||
privs = {
|
||||
[yl_cinema.settings.admin_priv] = true
|
||||
}, -- Require the "privs" privilege to run
|
||||
func = function(name, param)
|
||||
|
||||
local args = string.split(param, " ")
|
||||
|
||||
if (#args > 1) then
|
||||
return false, "Usage: /listmovies [<searchstring>]"
|
||||
end
|
||||
|
||||
local searchterm = args[1] or ""
|
||||
|
||||
core.log("action", "[yl_cinema] Player " .. name .. " searches for movie " .. searchterm)
|
||||
|
||||
local success, msg = yl_cinema.listmovies(searchterm)
|
||||
|
||||
if success then
|
||||
return true, dump(msg)
|
||||
else
|
||||
return false, "No movies matching your criteria were found."
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition)
|
@ -1,2 +1,2 @@
|
||||
dofile(yl_template.modpath .. "chatcommand_admin.lua")
|
||||
dofile(yl_template.modpath .. "chatcommand_player.lua")
|
||||
--dofile(yl_cinema.modpath .. "chatcommand_showmovie.lua")
|
||||
dofile(yl_cinema.modpath .. "chatcommand_listmovies.lua")
|
4
init.lua
4
init.lua
@ -25,10 +25,10 @@ dofile(yl_cinema.modpath .. "dependencies.lua")
|
||||
dofile(yl_cinema.modpath .. "config.lua")
|
||||
dofile(yl_cinema.modpath .. "setup.lua")
|
||||
dofile(yl_cinema.modpath .. "internal.lua")
|
||||
--dofile(yl_cinema.modpath .. "api.lua")
|
||||
dofile(yl_cinema.modpath .. "api.lua")
|
||||
dofile(yl_cinema.modpath .. "initialize.lua")
|
||||
--dofile(yl_cinema.modpath .. "features.lua")
|
||||
--dofile(yl_cinema.modpath .. "chatcommands.lua")
|
||||
dofile(yl_cinema.modpath .. "chatcommands.lua")
|
||||
|
||||
local mod_end_time = (core.get_us_time() - mod_start_time) / 1000000
|
||||
core.log("action", "[MOD] yl_cinema loaded in [" .. mod_end_time .. "s]")
|
||||
|
16
internal.lua
16
internal.lua
@ -117,13 +117,17 @@ end
|
||||
|
||||
local function search_movies(movies, search_term)
|
||||
local results = {}
|
||||
for _, movie in ipairs(movies) do
|
||||
if string.match(movie.id, search_term) or string.match(movie.name, search_term) or
|
||||
for movie_id, movie in pairs(movies) do
|
||||
if string.match(movie_id, search_term) or string.match(movie.name, search_term) or
|
||||
string.match(movie.description, search_term) then
|
||||
table.insert(results, movie.id)
|
||||
table.insert(results, movie_id)
|
||||
end
|
||||
end
|
||||
return results
|
||||
if #results > 0 then
|
||||
return true, results
|
||||
else
|
||||
return false, results
|
||||
end
|
||||
end
|
||||
|
||||
-- Public functions wrap the private ones, so they can be exchanged easily
|
||||
@ -182,5 +186,9 @@ function yl_cinema.load_images_of_movie(movie_id, ...)
|
||||
return load_images_of_movie(movie_id, ...)
|
||||
end
|
||||
|
||||
function yl_cinema.get_movie(movie_id, ...)
|
||||
return get_movie(movie_id, ...)
|
||||
end
|
||||
|
||||
yl_cinema.action = action
|
||||
yl_cinema.warn = warn
|
Loading…
Reference in New Issue
Block a user