generated from your-land/yl_template
Implements legacy import
This commit is contained in:
parent
d9fce0231c
commit
6c6ef1123c
@ -1,7 +1,7 @@
|
||||
-- Use this file to initialize variables once after server start and check everything is in place
|
||||
local function run_each_serverstart()
|
||||
yl_skinsdb_addon.data = {}
|
||||
yl_skinsdb_addon.load_skins("", yl_skinsdb_addon.settings.path_textures)
|
||||
yl_skinsdb_addon.detect_version()
|
||||
end
|
||||
|
||||
run_each_serverstart()
|
||||
|
58
internal.lua
58
internal.lua
@ -28,25 +28,32 @@ local function load_skins(name, path_textures, callback_available)
|
||||
end
|
||||
|
||||
for _, filename in pairs(dir_list) do
|
||||
core.log("action","meow1")
|
||||
if (yl_skinsdb_addon.data[filename] == nil) then
|
||||
core.log("action","meow2")
|
||||
local dam_options = {filepath = path_skins .. DIR_DELIM .. filename}
|
||||
delivered[filename] = {}
|
||||
requested[filename] = name
|
||||
local do_callback
|
||||
|
||||
if (callback_available == true) then
|
||||
core.log("action","meow8")
|
||||
do_callback = function(p_name)
|
||||
yl_skinsdb_addon.callback_dam(p_name, path_skins, filename)
|
||||
end
|
||||
else
|
||||
yl_skinsdb_addon.callback_dam(name, path_skins, filename)
|
||||
core.log("action","meow9")
|
||||
yl_skinsdb_addon.callback_dam("", path_skins, filename)
|
||||
end
|
||||
local success_dam = minetest.dynamic_add_media(dam_options,
|
||||
do_callback)
|
||||
if (success_dam == true) then
|
||||
core.log("action","meow 10")
|
||||
yl_skinsdb_addon.data[filename] = true
|
||||
imported_skins_list[filename] = true
|
||||
good = good + 1
|
||||
else
|
||||
core.log("action","meow 11")
|
||||
imported_skins_list[filename] = false
|
||||
bad = bad + 1
|
||||
end
|
||||
@ -79,7 +86,7 @@ function yl_skinsdb_addon.load_skins(name, path_textures, callback)
|
||||
end
|
||||
|
||||
function yl_skinsdb_addon.callback_dam(name, path_skins, filename)
|
||||
|
||||
core.log("action","meow callback")
|
||||
delivered[filename][name] = true
|
||||
|
||||
local players = minetest.get_connected_players()
|
||||
@ -92,7 +99,7 @@ function yl_skinsdb_addon.callback_dam(name, path_skins, filename)
|
||||
true)
|
||||
if (can_receive and not_delivered) then return false end
|
||||
end
|
||||
|
||||
core.log("action","meow callback")
|
||||
delivered[filename] = nil
|
||||
|
||||
-- Now every connected player received the file.
|
||||
@ -115,3 +122,48 @@ function yl_skinsdb_addon.callback_dam(name, path_skins, filename)
|
||||
requested[filename] = nil
|
||||
|
||||
end
|
||||
|
||||
-- legacy, pre 5.9.0
|
||||
|
||||
local function load_skins_legacy(path_textures)
|
||||
-- Load skins from the current mod directory
|
||||
local path_skins = yl_skinsdb_addon.worldpath .. path_textures
|
||||
local dir_list = minetest.get_dir_list(path_skins)
|
||||
local imported_skins_list = {}
|
||||
|
||||
if (not next(dir_list)) then
|
||||
log("Skins not found in " .. dump(path_skins))
|
||||
return false, "Skins not found in " .. dump(path_skins)
|
||||
end
|
||||
|
||||
for _, filename in pairs(dir_list) do
|
||||
local dam_options = {filepath = path_skins .. DIR_DELIM .. filename}
|
||||
|
||||
local success_dam = minetest.dynamic_add_media(dam_options,
|
||||
do_callback)
|
||||
if (success_dam == true) then
|
||||
yl_skinsdb_addon.data[filename] = true
|
||||
local success_rs, message_rs = skins.register_skin(path_skins, filename)
|
||||
if (success_rs ~= true) then
|
||||
log("Legacy import failed: " .. filename)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- /legacy, pre 5.9.0
|
||||
|
||||
local function detect_version()
|
||||
if (true == true) then
|
||||
--if (minetest.features.dynamic_add_media_startup ~= true) then
|
||||
-- 5.8.0 and lower:
|
||||
minetest.after(0, load_skins_legacy, "", yl_skinsdb_addon.settings.path_textures, false)
|
||||
else
|
||||
-- After 5.9.0:
|
||||
yl_skinsdb_addon.load_skins("", yl_skinsdb_addon.settings.path_textures)
|
||||
end
|
||||
end
|
||||
|
||||
function yl_skinsdb_addon.detect_version()
|
||||
return detect_version()
|
||||
end
|
Loading…
Reference in New Issue
Block a user