Logo

SM5 LUA Question

Register Log In Back To Forums

Post #1 · Posted at 2020-11-24 10:02:49pm 3.4 years ago

Offline s34n
s34n Avatar Member
3 Posts
United Kingdom
Reg. 2007-07-26


Last updated: 2020-11-24 10:02pm
Question Mark 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"
SOUNDTonguelayOnce(path)
end,
},
}

Thanks for help in advance.

nvm. I figured it out.
~ s34n
Register Log In Back To Forums

0 User(s) Viewing This Thread (Past 15 Minutes)

©2006-2024 Zenius -I- vanisher.com -5th style- IIPrivacy Policy
Web Server: 5% · Database: 4% · Server Time: 2024-04-20 03:44:13
This page took 0.003 seconds to execute.
Theme: starlight · Language: englishuk
Reset Theme & Language