Fixing item

This commit is contained in:
AliasAlreadyTaken 2023-07-26 07:20:38 +02:00
parent 0b564fc78a
commit d4b17755c6
8 changed files with 66 additions and 19 deletions

View File

@ -0,0 +1,11 @@
local chatcommand_cmd = "movie_reload"
local chatcommand_definition = {
params = "[<movie_id>]", -- Short parameter description
description = "Reload specific <movie_id> or all movies, but does not create movie reel items.",
privs = {
[yl_cinema.settings.admin_priv] = true
},
func = yl_cinema.cmd_movie_reload
}
minetest.register_chatcommand(chatcommand_cmd, chatcommand_definition)

View File

@ -1,2 +1,3 @@
dofile(yl_cinema.modpath .. "chatcommand_movie_show.lua") dofile(yl_cinema.modpath .. "chatcommand_movie_show.lua")
dofile(yl_cinema.modpath .. "chatcommand_movie_list.lua") dofile(yl_cinema.modpath .. "chatcommand_movie_list.lua")
dofile(yl_cinema.modpath .. "chatcommand_movie_reload.lua")

View File

@ -78,6 +78,11 @@ local function showpage(ent_obj, movie_id, pagenum)
local movie = yl_cinema.get_movie(movie_id) local movie = yl_cinema.get_movie(movie_id)
local pages = movie.pages local pages = movie.pages
if not ent_obj then
warn("Cinema Screen Object not found, movie_id=" .. dump(movie_id))
return ""
end
if pagenum <= #pages then if pagenum <= #pages then
table.sort(pages, yl_cinema.orderpages) table.sort(pages, yl_cinema.orderpages)
@ -94,7 +99,8 @@ local function showpage(ent_obj, movie_id, pagenum)
local properties = { local properties = {
textures = {movie.title_texture}, textures = {movie.title_texture},
infotext = movie.name, infotext = movie.name,
nametag = movie.description nametag = movie.description,
_playing = true
} }
ent_obj:set_properties(properties) ent_obj:set_properties(properties)
else else
@ -106,13 +112,21 @@ local function showpage(ent_obj, movie_id, pagenum)
local properties = { local properties = {
textures = {page.texture}, textures = {page.texture},
infotext = movie.name, infotext = movie.name,
nametag = page.caption nametag = page.caption,
_playing = true
} }
ent_obj:set_properties(properties) ent_obj:set_properties(properties)
end end
else -- Fin
local properties = {
textures = {"yl_cinema_block_bigscreen.png^yl_cinema_icon_movie_inv.png"},
infotext = "Fin",
nametag = "Fin",
_playing = false
}
ent_obj:set_properties(properties)
end end
end end

View File

@ -1,24 +1,30 @@
if yl_cinema.settings.enable_movieitems ~= true then return end if yl_cinema.settings.enable_movieitems ~= true then return end
--
local movie_item_name_empty = yl_cinema.settings.movie_item_name_empty
local movie_item_definition_empty = {
groups = {movie = 1, not_in_creative_inventory = 1, media = 1},
inventory_image = "yl_cinema_icon_movie_inv.png",
wield_image = "yl_cinema_icon_movie_inv.png",
stack_max = 1,
range = 4,
liquids_pointable = false,
_yl_cinema_movie_id = ""
}
minetest.register_craftitem(movie_item_name_empty, movie_item_definition_empty)
local movie_item_string = yl_cinema.settings.movie_item_name_written
local movie_item_definition = { local movie_item_definition = {
groups = {movie = 1, not_in_creative_inventory = 1, media = 1}, groups = {movie = 1, not_in_creative_inventory = 1, media = 1},
inventory_image = "yl_cinema_icon_movie_inv.png", inventory_image = "yl_cinema_icon_movie_inv.png",
wield_image = "yl_cinema_icon_movie_inv.png", wield_image = "yl_cinema_icon_movie_inv.png",
stack_max = 1, stack_max = 1,
range = 4, range = 4,
liquids_pointable = false liquids_pointable = false,
_yl_cinema_movie_id = ""
} }
for movie_id, movie in pairs(yl_cinema.movies) do minetest.register_craftitem(movie_item_string, movie_item_definition)
if movie.item and (movie.item == true) then
local item_definition = movie_item_definition
item_definition._yl_cinema_movie_id = movie_id
core.log("action", "item_definition._yl_cinema_movie_id=" ..
item_definition._yl_cinema_movie_id)
item_definition.short_description = minetest.formspec_escape(movie.name)
item_definition.description =
minetest.formspec_escape(movie.description)
local item_string = yl_cinema.get_itemstring(movie_id)
minetest.register_craftitem(item_string, item_definition)
end
end

View File

@ -192,7 +192,7 @@ local function search_movies(movies, search_term)
string.match(movie.description, search_term) then string.match(movie.description, search_term) then
local item_string = "" local item_string = ""
if movie.item == true then if movie.item == true then
item_string = get_itemstring(movie_id) item_string = "yes"
end end
table.insert(results, {movie_id, movie.name, item_string or ""}) table.insert(results, {movie_id, movie.name, item_string or ""})
end end
@ -355,6 +355,21 @@ function yl_cinema.cmd_show_movie(name, param)
end end
end end
function yl_cinema.cmd_movie_reload(name, param)
local args = string.split(param, " ")
if (#args >= 2) then
return false, "Usage: /movie_reload [<movie_id>]"
end
local movie_id = args[1] or ""
minetest.log("action", "[yl_cinema] Player " .. name .. " reloads movie " .. movie_id)
end
function yl_cinema.listmovies(searchterm) function yl_cinema.listmovies(searchterm)
return search_movies(yl_cinema.movies, searchterm) return search_movies(yl_cinema.movies, searchterm)
end end

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB