Post #1 · Posted at 2020-11-24 10:02:49pm 3.4 years ago
it's been a while!
I'm trying to get a countdown background video to display at certain intervals and a sound to play alongside it. The sound and video are both 5 seconds long.
This code works, but the video just gets hidden in the background until it's next call (the lua is never unloaded). Then because the video is a graphical timer, it'll just appear on it's next call and will start halfway through the timer until its hidden again.
Ideally I want the video and sound to play just once, then the script is unloaded until its next called. Is this possible?
or is there a better way doing this?
SM File
#BGCHANGES:
000.000=./lua/bg.lua=1.000=0=0=1=====,
34.000=./lua/bg.lua=1.000=0=0=1=====,
78.000=./lua/bg.lua=1.000=0=0=1=====,
92.000=./lua/bg.lua=1.000=0=0=1=====,
and the lua
return Def.ActorFrame{
Name= "af_countdown",
Def.Sprite{
Name= "s_countdown_video", -- Make bg video appear semi-transparent for 5 seconds
OnCommand= cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;zoomtowidth,SCREEN_WIDTH;zoomtoheight,SCREEN_HEIGHT;diffusealpha,0;linear,0.3;diffusealpha,0.5;sleep,5;linear,0.4;diffusealpha,0),
Texture= "countdown.mp4",
},
Def.Actor{
Name= "s_countdown_audio", -- Play audio at the same time
OnCommand=function(self)
local directory = GAMESTATE:GetCurrentSong():GetSongDir()
local path = directory .. "lua/countdown.ogg"
SOUNDlayOnce(path)
end,
},
}
Thanks for help in advance.
nvm. I figured it out.
I'm trying to get a countdown background video to display at certain intervals and a sound to play alongside it. The sound and video are both 5 seconds long.
This code works, but the video just gets hidden in the background until it's next call (the lua is never unloaded). Then because the video is a graphical timer, it'll just appear on it's next call and will start halfway through the timer until its hidden again.
Ideally I want the video and sound to play just once, then the script is unloaded until its next called. Is this possible?
or is there a better way doing this?
SM File
#BGCHANGES:
000.000=./lua/bg.lua=1.000=0=0=1=====,
34.000=./lua/bg.lua=1.000=0=0=1=====,
78.000=./lua/bg.lua=1.000=0=0=1=====,
92.000=./lua/bg.lua=1.000=0=0=1=====,
and the lua
return Def.ActorFrame{
Name= "af_countdown",
Def.Sprite{
Name= "s_countdown_video", -- Make bg video appear semi-transparent for 5 seconds
OnCommand= cmd(x,SCREEN_CENTER_X;y,SCREEN_CENTER_Y;zoomtowidth,SCREEN_WIDTH;zoomtoheight,SCREEN_HEIGHT;diffusealpha,0;linear,0.3;diffusealpha,0.5;sleep,5;linear,0.4;diffusealpha,0),
Texture= "countdown.mp4",
},
Def.Actor{
Name= "s_countdown_audio", -- Play audio at the same time
OnCommand=function(self)
local directory = GAMESTATE:GetCurrentSong():GetSongDir()
local path = directory .. "lua/countdown.ogg"
SOUNDlayOnce(path)
end,
},
}
Thanks for help in advance.
nvm. I figured it out.