So If I have single Audio file that I'd like to Hear it looping Only As long as I'm pressing down Up OR Down Arrow Keys
Simulating player's footsteps or Breath.
Thanks,

Last edited by zeno00 on Mon Apr 13, 2009 12:53 pm; edited 1 time in total

Vincent

Joined: 25 Dec 2006

Posts: 297

Posted: Sat Apr 11, 2009 5:49 am

Code:

local soundlen=1 -- assume the sound time length is 1 second
local lastsoundtime=0

function FrameMove()
if GetAppTime()-lastsoundtime > soundlen then
lastsoundtime=GetAppTime()
PlaySound('swim')
end
end

For keys pressing detection, you can see the wnd.IsKeyDown() function.

zeno00

Joined: 06 Apr 2009

Posts: 16

Posted: Sat Apr 11, 2009 7:03 am

Alright Thanks Very much Vincent,
And these techniques are applicable to control Some ambient sounds.

zeno00

Joined: 06 Apr 2009

Posts: 16

Posted: Sat Apr 11, 2009 10:01 am

Hey,
I've been trying to do wnd.IskeyDown() Function to apply sound loop when the Up key is pressed
So I Wrote at first line :

Code:

function wnd.IsVK_UPDown()

Then I listed the whole function with the lines above it In the Keybord input messages section But It didn't work

So Is this the Right syntax and should I list in the App flow section.
also Can this function be used IF the FrameMove() function was already devoted for different sound.
Thanks,

Vincent

Joined: 25 Dec 2006

Posts: 297

Posted: Sat Apr 11, 2009 1:31 pm

you should use the function like this:

Code:

function FrameMove()
if wnd.IsKeyDown(VK_UP) then
if GetAppTime()-lastsoundtime > soundlen then
lastsoundtime=GetAppTime()
PlaySound('swim')
end
end
end

zeno00

Joined: 06 Apr 2009

Posts: 16

Posted: Sat Apr 11, 2009 3:39 pm

Ok, Thanks Vincent It Works, But What if I wanted to trigger Another sound loop in the same scene Throw
An overlay usually when we Trigger it By an overlay it doesn't loop what can I do then to make it loop.
Thank You,

nigec

Joined: 04 Jul 2007

Posts: 212

Posted: Sat Apr 11, 2009 5:24 pm

You can do timeline looped sound, use wav, create a shot that cycles and doesn't effect the camera..
thats the way I'd do it, but I don't need it hard wired into scripts

zeno00

Joined: 06 Apr 2009

Posts: 16

Posted: Sat Apr 11, 2009 9:58 pm

Well thanks nigec but I really need know this Code ,
Also I'd like to know how can I assign the wnd.IsKeyDown() function to more keys
SO That it can triggered by More Than one key
how do we make that?
Thanks,

Vincent

Joined: 25 Dec 2006

Posts: 297

Posted: Sun Apr 12, 2009 11:16 am

You had better spend some time to learn LUA language first, then scripting.