diff options
author | sfan5 <sfan5@live.de> | 2021-01-30 14:35:34 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2021-02-01 23:00:13 +0100 |
commit | 40ad9767531beb6cf2e8bd918c9c9ed5f2749320 (patch) | |
tree | 957666f5b93f3e02de412813f0a0a6393b325333 /builtin/game | |
parent | a01a02f7a1ec915c207632085cd5f24eab28da17 (diff) | |
download | minetest-40ad9767531beb6cf2e8bd918c9c9ed5f2749320.tar.gz minetest-40ad9767531beb6cf2e8bd918c9c9ed5f2749320.tar.bz2 minetest-40ad9767531beb6cf2e8bd918c9c9ed5f2749320.zip |
Revise dynamic_add_media API to better accomodate future changes
Diffstat (limited to 'builtin/game')
-rw-r--r-- | builtin/game/misc.lua | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 96a0a2dda..b8c5e16a9 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -266,3 +266,26 @@ end function core.cancel_shutdown_requests() core.request_shutdown("", false, -1) end + + +-- Callback handling for dynamic_add_media + +local dynamic_add_media_raw = core.dynamic_add_media_raw +core.dynamic_add_media_raw = nil +function core.dynamic_add_media(filepath, callback) + local ret = dynamic_add_media_raw(filepath) + if ret == false then + return ret + end + if callback == nil then + core.log("deprecated", "Calling minetest.dynamic_add_media without ".. + "a callback is deprecated and will stop working in future versions.") + else + -- At the moment async loading is not actually implemented, so we + -- immediately call the callback ourselves + for _, name in ipairs(ret) do + callback(name) + end + end + return true +end |