-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
48 lines (40 loc) · 1.15 KB
/
init.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
slideshow = {}
local slides = {}
local function showpic(imagename,playername)
local fsn = "slideshow:slides"
formspeccer:clear(fsn)
formspeccer:newform(fsn,"4,3",{
background = {
xy = "0,0",
wh = "4,3",
texture = imagename,
},
})
formspeccer:show(minetest.get_player_by_name(playername),fsn)
end
local function run_slideshow(deck,playername)
if not deck then return end
for i=1,#deck do
showpic(deck[i])
end
end
function slideshow.register_slide(deckname,imagename)
if not imagename:match(".jpg$") and not imagename:match(".jpeg$") then
-- all media needs to be loaded over the wire to each client
-- reduce load time and bandwidth usage by making sure images are less than 64KB
-- using JPEG is a start
minetest.log("error","Use only properly compressed JPEG images with slideshows in 4:3 ratio. Reduce network traffic!")
return
end
if not slide[deckname] then
slides[deckname] = {}
end
local deck = slideshow.slides[deckname]
deck[#deck+1] = imagename
end
function slideshow.clear_deck(deckname)
slides[deckname] = nil
end
function slideshow.show_deck(deckname,playername)
run_slideshow(slides[deckname],playername)
end