your-land/bugtracker#4668 29 Remove different items, have only one item with the movie_id as meta

This commit is contained in:
AliasAlreadyTaken 2023-07-30 10:04:55 +02:00
parent 0b564fc78a
commit 4b927e6119
6 changed files with 79 additions and 20 deletions

View File

@ -9,11 +9,15 @@ yl_cinema.settings.admin_priv = minetest.settings:get("yl_cinema.admin_priv") or
yl_cinema.settings.enable_movieitems = minetest.settings:get("yl_cinema.enable_movieitems") or true
yl_cinema.settings.enable_bigscreen = minetest.settings:get("yl_cinema.enable_bigscreen") or true
yl_cinema.settings.enable_screens = minetest.settings:get("yl_cinema.enable_screens") or true
yl_cinema.settings.enable_craft_bigscreen = minetest.settings:get("yl_cinema.enable_craft_bigscreen") or true
yl_cinema.settings.enable_craft_screens = minetest.settings:get("yl_cinema.enable_craft_screens") or true
yl_cinema.settings.enable_craft_bigscreen_recipe = minetest.settings:get("yl_cinema.enable_craft_bigscreen_recipe") or
"wool:grey,wool:grey,wool:grey,wool:grey,wool:grey,wool:grey,wool:black,,wool:black"
yl_cinema.settings.movie_item_name = minetest.settings:get("yl_cinema.movie_item_name") or "yl_cinema:movie"
yl_cinema.settings.enable_craft_flatscreen_recipe = minetest.settings:get("yl_cinema.enable_craft_flatscreen_recipe") or
"wool:grey,wool:grey,wool:grey,wool:grey,wool:grey,wool:grey,wool:black,,wool:black"
yl_cinema.settings.enable_craft_moviereel_recipe = minetest.settings:get("yl_cinema.enable_craft_moviereel_recipe") or
"default:steel_ingot,cottages:wagon_wheel,default:steel_ingot,default:mese_crystal_fragment,basic_materials:empty_spool,default:paper,default:steel_ingot,cottages:wagon_wheel,default:steel_ingot"

View File

@ -1,24 +1,50 @@
if yl_cinema.settings.enable_movieitems ~= true then return end
if yl_cinema.settings.enable_movieitems ~= true then
return
end
-- Empty reel
local movie_item_name_empty = "yl_cinema:movie_reel"
local movie_item_definition_empty = {
groups = {
movie = 1,
media = 1
},
inventory_image = "yl_cinema_icon_movie_empty_inv.png",
wield_image = "yl_cinema_icon_movie_empty_inv.png",
_yl_cinema_movie_id = ""
}
minetest.register_craftitem(movie_item_name_empty, movie_item_definition_empty)
-- Written reel
local movie_item_name_written = "yl_cinema:movie_print"
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",
wield_image = "yl_cinema_icon_movie_inv.png",
stack_max = 1,
range = 4,
liquids_pointable = false
_yl_cinema_movie_id = ""
}
for movie_id, movie in pairs(yl_cinema.movies) do
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
minetest.register_craftitem(movie_item_name_written, movie_item_definition)
-- Craft the empty reel
local recipe = yl_cinema.string_to_recipe(yl_cinema.settings.enable_craft_moviereel_recipe)
if type(recipe) == "table" then
minetest.register_craft({
type = "shaped",
output = movie_item_name_empty,
recipe = recipe
})
else
yl_cinema.warn("Cannot register crafting recipe for Reel Item: " ..
dump(yl_cinema.settings.enable_craft_moviereel_recipe))
end

View File

@ -185,6 +185,18 @@ local function load_movies(movies_directory)
return movies, loaded_count, #movie_files
end
function yl_cinema.load_movies()
local movie_save_path = yl_cinema.worldpath .. yl_cinema.settings.save_path
local movies, loaded_count, total_count = yl_cinema.load_movies(movie_save_path)
if loaded_count ~= total_count then
yl_cinema.warn(loaded_count .. "/" .. total_count .. " movies loaded.")
else
yl_cinema.action(loaded_count .. "/" .. total_count .. " movies loaded.")
end
return movies
end
local function search_movies(movies, search_term)
local results = {}
for movie_id, movie in pairs(movies) do
@ -192,7 +204,7 @@ local function search_movies(movies, search_term)
string.match(movie.description, search_term) then
local item_string = ""
if movie.item == true then
item_string = get_itemstring(movie_id)
item_string = "yes"
end
table.insert(results, {movie_id, movie.name, item_string or ""})
end
@ -355,6 +367,23 @@ function yl_cinema.cmd_show_movie(name, param)
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 ""
action("[yl_cinema] Player " .. name .. " reloads movie " .. movie_id)
end
function yl_cinema.listmovies(searchterm)
return search_movies(yl_cinema.movies, searchterm)
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