forked from your-land/yl_cinema
34 lines
1.1 KiB
Lua
34 lines
1.1 KiB
Lua
if yl_cinema.settings.enable_movieitems ~= true then
|
|
return
|
|
end
|
|
|
|
local function remove_forbidden_characters(str)
|
|
local pattern = "[^%w_]"
|
|
return string.gsub(str, pattern, "_")
|
|
end
|
|
|
|
local movie_item_name = "yl_cinema:movie"
|
|
local movie_item_definition = {
|
|
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
|
|
}
|
|
|
|
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)
|
|
minetest.register_craftitem(movie_item_name .. "_" .. remove_forbidden_characters(movie.name), item_definition)
|
|
end
|
|
end
|