From 566a51f80137277e60e696e465b2bafa6d4eca29 Mon Sep 17 00:00:00 2001 From: Sokomine Date: Wed, 27 Apr 2016 23:27:09 +0200 Subject: [PATCH] if secure.enable_security is disabled, schems from all worlds are offered --- build_chest_add_schems_by_directory.lua | 41 +++++++++++++++---------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/build_chest_add_schems_by_directory.lua b/build_chest_add_schems_by_directory.lua index 4359d64..e383d05 100644 --- a/build_chest_add_schems_by_directory.lua +++ b/build_chest_add_schems_by_directory.lua @@ -75,6 +75,28 @@ local build_chest_check_all_directories_mods_and_modpacks = function( path, menu end end +build_chest.add_files_from_path = function( worldpath, worldname ) + -- get list of subdirectories + local path = worldpath..'/'..worldname; + local subdir_list = minetest.get_dir_list( path, true ); + if( not( subdir_list )) then + return; + end + for _,subdir in ipairs( subdir_list ) do + if( subdir=='schems' ) then + local file_list = minetest.get_dir_list( path..'/schems', false ); + for _,filename in ipairs( file_list ) do + build_chest_add_files_to_menu_from_directory( + filename, + path..'/schems/', + 'import from world', + 'landscape backups', + {'OVERWRITE THIS', worldname }); + end + end + end +end + local build_chest_check_all_directories = function() -- find the name of the directory directly above the current worldpath @@ -106,27 +128,12 @@ local build_chest_check_all_directories = function() end end --]] - worldpath = string.sub( worldpath, 1, string.len( worldpath )-p ); - +-- worldpath = string.sub( worldpath, 1, string.len( worldpath )-p ); -- locate .mts, .wem and .we files in the worlds/WORLDNAME/schems/* folders local d1 = minetest.get_dir_list( worldpath, true ); for _,worldname in ipairs( d1 ) do - -- get list of subdirectories - local d2 = minetest.get_dir_list( worldpath..'/'..worldname, true ); - for _,subdir in ipairs( d2 ) do - if( subdir=='schems' ) then - local d3 = minetest.get_dir_list( worldpath..'/'..worldname..'/schems', false ); - for _,filename in ipairs( d3 ) do - build_chest_add_files_to_menu_from_directory( - filename, - worldpath..'/'..worldname..'/schems/', - 'import from world', - 'landscape backups', - {'OVERWRITE THIS', worldname }); - end - end - end + build_chest.add_files_from_path( worldpath, worldname ); end local main_path = string.sub( worldpath, 1, string.len(worldpath)-string.len('/worlds'));