Skip to content

Commit ceb1b05

Browse files
committed
Dynamically load map screenshots/custom skyboxes
1 parent 0f72cb4 commit ceb1b05

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

mods/ctf/ctf_map/map_meta.lua

+22
Original file line numberDiff line numberDiff line change
@@ -183,9 +183,31 @@ function ctf_map.load_map_meta(idx, dirname)
183183

184184
map.flag_center = calc_flag_center(map)
185185

186+
for _, e in pairs(minetest.get_dir_list(ctf_map.map_path[dirname], false)) do
187+
if e:match("%.png") then
188+
if core.features.dynamic_add_media_startup then
189+
minetest.dynamic_add_media({
190+
filename = dirname .. "_" .. e,
191+
filepath = ctf_map.map_path[dirname] .. "/" .. e}
192+
)
193+
end
194+
end
195+
end
196+
186197
if ctf_map.skybox_exists(ctf_map.map_path[dirname]) then
187198
skybox.add({dirname, "#ffffff", [5] = "png"})
188199

200+
for _, e in pairs(minetest.get_dir_list(ctf_map.map_path[dirname] .. "/skybox/", false)) do
201+
if e:match("%.png") then
202+
if core.features.dynamic_add_media_startup then
203+
minetest.dynamic_add_media({
204+
filename = dirname .. e,
205+
filepath = ctf_map.map_path[dirname] .. "/skybox/" .. e}
206+
)
207+
end
208+
end
209+
end
210+
189211
map.skybox = dirname
190212
map.skybox_forced = true
191213
end

scripts/setup_maps.sh

-16
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,8 @@ fi
88

99
cd mods/ctf/ctf_map/maps/
1010

11-
# Copy textures from map sub-dirs to ctf_map_core/textures
1211
for f in *; do
1312
if [ -d ${f} ]; then
14-
# Copy map screenshot to textures dir
15-
if [ -f ${f}/screenshot.png ]; then
16-
cp ${f}/screenshot.png ../textures/${f}_screenshot.png
17-
fi
18-
1913
# Move skybox textures into map skybox folder if they aren't already there
2014
if [ -f ${f}/skybox_1.png ]; then
2115
if ![ -d ${f}/skybox/ ]; then
@@ -30,15 +24,5 @@ for f in *; do
3024
cp ${f}/skybox_6.png ${f}/skybox/Right.png
3125
rm ${f}/skybox_*.png
3226
fi
33-
34-
# Move skybox textures to textures dir where Minetest can find them
35-
if [ -d ${f}/skybox/ ]; then
36-
cp ${f}/skybox/Up.png ../textures/${f}Up.png
37-
cp ${f}/skybox/Down.png ../textures/${f}Down.png
38-
cp ${f}/skybox/Front.png ../textures/${f}Front.png
39-
cp ${f}/skybox/Back.png ../textures/${f}Back.png
40-
cp ${f}/skybox/Left.png ../textures/${f}Left.png
41-
cp ${f}/skybox/Right.png ../textures/${f}Right.png
42-
fi
4327
fi
4428
done

0 commit comments

Comments
 (0)